aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/raid
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/raid')
-rw-r--r--patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/raid/Raid.java.patch155
-rw-r--r--patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/raid/Raider.java.patch31
-rw-r--r--patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/raid/Raids.java.patch40
3 files changed, 226 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/raid/Raid.java.patch b/patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/raid/Raid.java.patch
new file mode 100644
index 0000000000..8db1d9c988
--- /dev/null
+++ b/patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/raid/Raid.java.patch
@@ -0,0 +1,155 @@
+--- a/net/minecraft/world/entity/raid/Raid.java
++++ b/net/minecraft/world/entity/raid/Raid.java
+@@ -176,6 +176,12 @@
+ return this.status == Raid.RaidStatus.LOSS;
+ }
+
++ // CraftBukkit start
++ public boolean isInProgress() {
++ return this.status == RaidStatus.ONGOING;
++ }
++ // CraftBukkit end
++
+ public float getTotalHealth() {
+ return this.totalHealth;
+ }
+@@ -272,6 +278,7 @@
+
+ this.active = this.level.hasChunkAt(this.center);
+ if (this.level.getDifficulty() == Difficulty.PEACEFUL) {
++ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.PEACE); // CraftBukkit
+ this.stop();
+ return;
+ }
+@@ -291,13 +298,16 @@
+ if (!this.level.isVillage(this.center)) {
+ if (this.groupsSpawned > 0) {
+ this.status = Raid.RaidStatus.LOSS;
++ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidFinishEvent(this, new java.util.ArrayList<>()); // CraftBukkit
+ } else {
++ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.NOT_IN_VILLAGE); // CraftBukkit
+ this.stop();
+ }
+ }
+
+ ++this.ticksActive;
+ if (this.ticksActive >= 48000L) {
++ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.TIMEOUT); // CraftBukkit
+ this.stop();
+ return;
+ }
+@@ -371,6 +381,7 @@
+ }
+
+ if (j > 3) {
++ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.UNSPAWNABLE); // CraftBukkit
+ this.stop();
+ break;
+ }
+@@ -383,6 +394,7 @@
+ this.status = Raid.RaidStatus.VICTORY;
+ Iterator iterator = this.heroesOfTheVillage.iterator();
+
++ List<org.bukkit.entity.Player> winners = new java.util.ArrayList<>(); // CraftBukkit
+ while (iterator.hasNext()) {
+ UUID uuid = (UUID) iterator.next();
+ Entity entity = this.level.getEntity(uuid);
+@@ -395,12 +407,14 @@
+ if (livingentity instanceof ServerPlayer) {
+ ServerPlayer serverplayer = (ServerPlayer) livingentity;
+
+- serverplayer.awardStat(Stats.RAID_WIN);
+- CriteriaTriggers.RAID_WIN.trigger(serverplayer);
++ entityplayer.awardStat(Stats.RAID_WIN);
++ CriteriaTriggers.RAID_WIN.trigger(entityplayer);
++ winners.add(entityplayer.getBukkitEntity()); // CraftBukkit
+ }
+ }
+ }
+ }
++ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidFinishEvent(this, winners); // CraftBukkit
+ }
+ }
+
+@@ -408,6 +422,7 @@
+ } else if (this.isOver()) {
+ ++this.celebrationTicks;
+ if (this.celebrationTicks >= 600) {
++ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.FINISHED); // CraftBukkit
+ this.stop();
+ return;
+ }
+@@ -544,6 +559,10 @@
+ int j = araid_raidertype.length;
+ int k = 0;
+
++ // CraftBukkit start
++ Raider leader = null;
++ List<Raider> raiders = new java.util.ArrayList<>();
++ // CraftBukkit end
+ while (k < j) {
+ Raid.RaiderType raid_raidertype = araid_raidertype[k];
+ int l = this.getDefaultNumSpawns(raid_raidertype, i, flag1) + this.getPotentialBonusSpawns(raid_raidertype, this.random, i, difficultyinstance, flag1);
+@@ -559,11 +578,13 @@
+ raider.setPatrolLeader(true);
+ this.setLeader(i, raider);
+ flag = true;
++ leader = entityraider; // CraftBukkit
+ }
+
+- this.joinRaid(i, raider, blockpos, false);
+- if (raid_raidertype.entityType == EntityType.RAVAGER) {
+- Raider raider1 = null;
++ this.joinRaid(i, entityraider, pos, false);
++ raiders.add(entityraider); // CraftBukkit
++ if (raid_wave.entityType == EntityType.RAVAGER) {
++ Raider entityraider1 = null;
+
+ if (i == this.getNumGroups(Difficulty.NORMAL)) {
+ raider1 = (Raider) EntityType.PILLAGER.create(this.level);
+@@ -576,10 +597,11 @@
+ }
+
+ ++i1;
+- if (raider1 != null) {
+- this.joinRaid(i, raider1, blockpos, false);
+- raider1.moveTo(blockpos, 0.0F, 0.0F);
+- raider1.startRiding(raider);
++ if (entityraider1 != null) {
++ this.joinRaid(i, entityraider1, pos, false);
++ entityraider1.moveTo(pos, 0.0F, 0.0F);
++ entityraider1.startRiding(entityraider);
++ raiders.add(entityraider); // CraftBukkit
+ }
+ }
+
+@@ -597,6 +619,7 @@
+ ++this.groupsSpawned;
+ this.updateBossbar();
+ this.setDirty();
++ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidSpawnWaveEvent(this, leader, raiders); // CraftBukkit
+ }
+
+ public void joinRaid(int i, Raider raider, @Nullable BlockPos blockpos, boolean flag) {
+@@ -612,7 +635,7 @@
+ raider.finalizeSpawn(this.level, this.level.getCurrentDifficultyAt(blockpos), MobSpawnType.EVENT, (SpawnGroupData) null, (CompoundTag) null);
+ raider.applyRaidBuffs(i, false);
+ raider.setOnGround(true);
+- this.level.addFreshEntityWithPassengers(raider);
++ this.level.addFreshEntityWithPassengers(raider, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.RAID); // CraftBukkit
+ }
+ }
+
+@@ -862,6 +885,12 @@
+ this.heroesOfTheVillage.add(entity.getUUID());
+ }
+
++ // CraftBukkit start - a method to get all raiders
++ public java.util.Collection<Raider> getRaiders() {
++ return this.groupRaiderMap.values().stream().flatMap(Set::stream).collect(java.util.stream.Collectors.toSet());
++ }
++ // CraftBukkit end
++
+ private static enum RaidStatus {
+
+ ONGOING, VICTORY, LOSS, STOPPED;
diff --git a/patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/raid/Raider.java.patch b/patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/raid/Raider.java.patch
new file mode 100644
index 0000000000..17f7705f6e
--- /dev/null
+++ b/patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/raid/Raider.java.patch
@@ -0,0 +1,31 @@
+--- a/net/minecraft/world/entity/raid/Raider.java
++++ b/net/minecraft/world/entity/raid/Raider.java
+@@ -170,7 +165,7 @@
+ MobEffectInstance mobeffectinstance1 = new MobEffectInstance(MobEffects.BAD_OMEN, 120000, i, false, false, true);
+
+ if (!this.level().getGameRules().getBoolean(GameRules.RULE_DISABLE_RAIDS)) {
+- player.addEffect(mobeffectinstance1);
++ entityhuman.addEffect(mobeffect1, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.PATROL_CAPTAIN); // CraftBukkit
+ }
+ }
+ }
+@@ -547,7 +521,7 @@
+ while (iterator.hasNext()) {
+ Raider raider = (Raider) iterator.next();
+
+- raider.setTarget(this.mob.getTarget());
++ entityraider.setTarget(this.mob.getTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.FOLLOW_LEADER, true); // CraftBukkit
+ }
+
+ }
+@@ -565,8 +538,8 @@
+ while (iterator.hasNext()) {
+ Raider raider = (Raider) iterator.next();
+
+- raider.setTarget(livingentity);
+- raider.setAggressive(true);
++ entityraider.setTarget(this.mob.getTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.FOLLOW_LEADER, true); // CraftBukkit
++ entityraider.setAggressive(true);
+ }
+
+ this.mob.setAggressive(true);
diff --git a/patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/raid/Raids.java.patch b/patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/raid/Raids.java.patch
new file mode 100644
index 0000000000..e1975b1818
--- /dev/null
+++ b/patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/raid/Raids.java.patch
@@ -0,0 +1,40 @@
+--- a/net/minecraft/world/entity/raid/Raids.java
++++ b/net/minecraft/world/entity/raid/Raids.java
+@@ -121,21 +121,34 @@
+ boolean flag = false;
+
+ if (!raid.isStarted()) {
++ /* CraftBukkit - moved down
+ if (!this.raidMap.containsKey(raid.getId())) {
+ this.raidMap.put(raid.getId(), raid);
+ }
+
+ flag = true;
+- } else if (raid.getBadOmenLevel() < raid.getMaxBadOmenLevel()) {
++ // CraftBukkit start - fixed a bug with raid: players could add up Bad Omen level even when the raid had finished
++ } else if (raid.isInProgress() && raid.getBadOmenLevel() < raid.getMaxBadOmenLevel()) {
+ flag = true;
++ // CraftBukkit end
+ } else {
+ serverplayer.removeEffect(MobEffects.BAD_OMEN);
+ serverplayer.connection.send(new ClientboundEntityEventPacket(serverplayer, (byte) 43));
+ }
+
+ if (flag) {
+- raid.absorbBadOmen(serverplayer);
+- serverplayer.connection.send(new ClientboundEntityEventPacket(serverplayer, (byte) 43));
++ // CraftBukkit start
++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callRaidTriggerEvent(raid, serverPlayer)) {
++ serverPlayer.removeEffect(MobEffects.BAD_OMEN);
++ return null;
++ }
++
++ if (!this.raidMap.containsKey(raid.getId())) {
++ this.raidMap.put(raid.getId(), raid);
++ }
++ // CraftBukkit end
++ raid.absorbBadOmen(serverPlayer);
++ serverPlayer.connection.send(new ClientboundEntityEventPacket(serverPlayer, (byte) 43));
+ if (!raid.hasFirstWaveSpawned()) {
+ serverplayer.awardStat(Stats.RAID_TRIGGER);
+ CriteriaTriggers.BAD_OMEN.trigger(serverplayer);