3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-23 14:50:08 +01:00
Paper/nms-patches/Raid.patch

138 Zeilen
6.1 KiB
Diff

2019-08-12 13:43:10 +02:00
--- a/net/minecraft/server/Raid.java
+++ b/net/minecraft/server/Raid.java
2020-06-25 02:00:00 +02:00
@@ -111,6 +111,12 @@
2019-12-10 23:00:00 +01:00
return this.status == Raid.Status.LOSS;
2019-08-12 13:43:10 +02:00
}
+ // CraftBukkit start
+ public boolean isInProgress() {
2019-12-10 23:00:00 +01:00
+ return this.status == Status.ONGOING;
2019-08-12 13:43:10 +02:00
+ }
+ // CraftBukkit end
+
2019-12-10 23:00:00 +01:00
public World getWorld() {
return this.world;
2019-08-12 13:43:10 +02:00
}
2020-06-25 02:00:00 +02:00
@@ -186,6 +192,7 @@
2019-08-12 13:43:10 +02:00
2019-12-10 23:00:00 +01:00
this.active = this.world.isLoaded(this.center);
if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL) {
2019-08-12 13:43:10 +02:00
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.PEACE); // CraftBukkit
2019-12-10 23:00:00 +01:00
this.stop();
2019-08-12 13:43:10 +02:00
return;
}
2020-06-25 02:00:00 +02:00
@@ -205,13 +212,16 @@
2019-12-10 23:00:00 +01:00
if (!this.world.b_(this.center)) {
if (this.groupsSpawned > 0) {
this.status = Raid.Status.LOSS;
2019-08-12 13:43:10 +02:00
+ 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
2019-12-10 23:00:00 +01:00
this.stop();
2019-08-12 13:43:10 +02:00
}
}
2019-12-10 23:00:00 +01:00
++this.ticksActive;
if (this.ticksActive >= 48000L) {
2019-08-12 13:43:10 +02:00
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.TIMEOUT); // CraftBukkit
2019-12-10 23:00:00 +01:00
this.stop();
2019-08-12 13:43:10 +02:00
return;
}
2020-06-25 02:00:00 +02:00
@@ -285,6 +295,7 @@
2019-08-12 13:43:10 +02:00
}
if (j > 3) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.UNSPAWNABLE); // CraftBukkit
2019-12-10 23:00:00 +01:00
this.stop();
2019-08-12 13:43:10 +02:00
break;
}
2020-06-25 02:00:00 +02:00
@@ -297,6 +308,7 @@
2019-12-10 23:00:00 +01:00
this.status = Raid.Status.VICTORY;
Iterator iterator = this.heroes.iterator();
2019-08-12 13:43:10 +02:00
+ List<org.bukkit.entity.Player> winners = new java.util.ArrayList<>(); // CraftBukkit
while (iterator.hasNext()) {
UUID uuid = (UUID) iterator.next();
2019-12-10 23:00:00 +01:00
Entity entity = this.world.getEntity(uuid);
2020-06-25 02:00:00 +02:00
@@ -310,9 +322,11 @@
2019-08-12 13:43:10 +02:00
entityplayer.a(StatisticList.RAID_WIN);
CriterionTriggers.H.a(entityplayer);
+ winners.add(entityplayer.getBukkitEntity()); // CraftBukkit
}
}
}
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidFinishEvent(this, winners); // CraftBukkit
}
}
2020-06-25 02:00:00 +02:00
@@ -320,6 +334,7 @@
2019-08-12 13:43:10 +02:00
} else if (this.a()) {
++this.x;
if (this.x >= 600) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.FINISHED); // CraftBukkit
2019-12-10 23:00:00 +01:00
this.stop();
2019-08-12 13:43:10 +02:00
return;
}
2020-06-25 02:00:00 +02:00
@@ -454,6 +469,10 @@
2019-08-12 13:43:10 +02:00
Raid.Wave[] araid_wave = Raid.Wave.f;
int j = araid_wave.length;
+ // CraftBukkit start
+ EntityRaider leader = null;
+ List<EntityRaider> raiders = new java.util.ArrayList<>();
+ // CraftBukkit end
for (int k = 0; k < j; ++k) {
Raid.Wave raid_wave = araid_wave[k];
2019-12-10 23:00:00 +01:00
int l = this.a(raid_wave, i, flag1) + this.a(raid_wave, this.random, i, difficultydamagescaler, flag1);
2020-06-25 02:00:00 +02:00
@@ -466,9 +485,11 @@
2019-08-12 13:43:10 +02:00
entityraider.setPatrolLeader(true);
this.a(i, entityraider);
flag = true;
+ leader = entityraider; // CraftBukkit
}
this.a(i, entityraider, blockposition, false);
+ raiders.add(entityraider); // CraftBukkit
if (raid_wave.g == EntityTypes.RAVAGER) {
EntityRaider entityraider1 = null;
2020-06-25 02:00:00 +02:00
@@ -487,6 +508,7 @@
2019-08-12 13:43:10 +02:00
this.a(i, entityraider1, blockposition, false);
entityraider1.setPositionRotation(blockposition, 0.0F, 0.0F);
entityraider1.startRiding(entityraider);
+ raiders.add(entityraider); // CraftBukkit
}
}
}
2020-06-25 02:00:00 +02:00
@@ -496,6 +518,7 @@
2019-12-10 23:00:00 +01:00
++this.groupsSpawned;
this.updateProgress();
2019-08-12 13:43:10 +02:00
this.H();
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidSpawnWaveEvent(this, leader, raiders); // CraftBukkit
}
public void a(int i, EntityRaider entityraider, @Nullable BlockPosition blockposition, boolean flag) {
2020-06-25 02:00:00 +02:00
@@ -511,7 +534,7 @@
2019-12-10 23:00:00 +01:00
entityraider.prepare(this.world, this.world.getDamageScaler(blockposition), EnumMobSpawn.EVENT, (GroupDataEntity) null, (NBTTagCompound) null);
entityraider.a(i, false);
2020-06-25 02:00:00 +02:00
entityraider.c(true);
2019-12-10 23:00:00 +01:00
- this.world.addEntity(entityraider);
+ this.world.addEntity(entityraider, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.RAID); // CraftBukkit
}
}
2020-06-25 02:00:00 +02:00
@@ -756,6 +779,12 @@
2019-12-10 23:00:00 +01:00
this.heroes.add(entity.getUniqueID());
2019-08-12 13:43:10 +02:00
}
+ // CraftBukkit start - a method to get all raiders
+ public java.util.Collection<EntityRaider> getRaiders() {
2019-12-10 23:00:00 +01:00
+ return this.raiders.values().stream().flatMap(Set::stream).collect(java.util.stream.Collectors.toSet());
2019-08-12 13:43:10 +02:00
+ }
+ // CraftBukkit end
+
static enum Wave {
VINDICATOR(EntityTypes.VINDICATOR, new int[]{0, 0, 2, 0, 1, 4, 2, 5}), EVOKER(EntityTypes.EVOKER, new int[]{0, 0, 0, 0, 0, 1, 1, 2}), PILLAGER(EntityTypes.PILLAGER, new int[]{0, 4, 3, 3, 4, 4, 4, 2}), WITCH(EntityTypes.WITCH, new int[]{0, 0, 0, 0, 3, 0, 0, 1}), RAVAGER(EntityTypes.RAVAGER, new int[]{0, 0, 0, 1, 0, 1, 0, 2});