mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-10 03:52:45 +01:00
b3a8254758
By: md_5 <git@md-5.net>
137 lines
5.9 KiB
Diff
137 lines
5.9 KiB
Diff
--- a/net/minecraft/world/entity/raid/Raid.java
|
|
+++ b/net/minecraft/world/entity/raid/Raid.java
|
|
@@ -174,6 +174,12 @@
|
|
return this.status == Raid.Status.LOSS;
|
|
}
|
|
|
|
+ // CraftBukkit start
|
|
+ public boolean isInProgress() {
|
|
+ return this.status == Status.ONGOING;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
+
|
|
public float g() {
|
|
return this.totalHealth;
|
|
}
|
|
@@ -270,6 +276,7 @@
|
|
|
|
this.active = this.level.isLoaded(this.center);
|
|
if (this.level.getDifficulty() == EnumDifficulty.PEACEFUL) {
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.PEACE); // CraftBukkit
|
|
this.stop();
|
|
return;
|
|
}
|
|
@@ -289,13 +296,16 @@
|
|
if (!this.level.b(this.center)) {
|
|
if (this.groupsSpawned > 0) {
|
|
this.status = Raid.Status.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;
|
|
}
|
|
@@ -369,6 +379,7 @@
|
|
}
|
|
|
|
if (j > 3) {
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.UNSPAWNABLE); // CraftBukkit
|
|
this.stop();
|
|
break;
|
|
}
|
|
@@ -381,6 +392,7 @@
|
|
this.status = Raid.Status.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);
|
|
@@ -394,9 +406,11 @@
|
|
|
|
entityplayer.a(StatisticList.RAID_WIN);
|
|
CriterionTriggers.RAID_WIN.a(entityplayer);
|
|
+ winners.add(entityplayer.getBukkitEntity()); // CraftBukkit
|
|
}
|
|
}
|
|
}
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidFinishEvent(this, winners); // CraftBukkit
|
|
}
|
|
}
|
|
|
|
@@ -404,6 +418,7 @@
|
|
} else if (this.a()) {
|
|
++this.celebrationTicks;
|
|
if (this.celebrationTicks >= 600) {
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.FINISHED); // CraftBukkit
|
|
this.stop();
|
|
return;
|
|
}
|
|
@@ -538,6 +553,10 @@
|
|
Raid.Wave[] araid_wave = Raid.Wave.VALUES;
|
|
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];
|
|
int l = this.a(raid_wave, i, flag1) + this.a(raid_wave, this.random, i, difficultydamagescaler, flag1);
|
|
@@ -550,9 +569,11 @@
|
|
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.entityType == EntityTypes.RAVAGER) {
|
|
EntityRaider entityraider1 = null;
|
|
|
|
@@ -571,6 +592,7 @@
|
|
this.a(i, entityraider1, blockposition, false);
|
|
entityraider1.setPositionRotation(blockposition, 0.0F, 0.0F);
|
|
entityraider1.startRiding(entityraider);
|
|
+ raiders.add(entityraider); // CraftBukkit
|
|
}
|
|
}
|
|
}
|
|
@@ -580,6 +602,7 @@
|
|
++this.groupsSpawned;
|
|
this.updateProgress();
|
|
this.H();
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidSpawnWaveEvent(this, leader, raiders); // CraftBukkit
|
|
}
|
|
|
|
public void a(int i, EntityRaider entityraider, @Nullable BlockPosition blockposition, boolean flag) {
|
|
@@ -595,7 +618,7 @@
|
|
entityraider.prepare(this.level, this.level.getDamageScaler(blockposition), EnumMobSpawn.EVENT, (GroupDataEntity) null, (NBTTagCompound) null);
|
|
entityraider.a(i, false);
|
|
entityraider.setOnGround(true);
|
|
- this.level.addAllEntities(entityraider);
|
|
+ this.level.addAllEntities(entityraider, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.RAID); // CraftBukkit
|
|
}
|
|
}
|
|
|
|
@@ -844,6 +867,12 @@
|
|
this.heroesOfTheVillage.add(entity.getUniqueID());
|
|
}
|
|
|
|
+ // CraftBukkit start - a method to get all raiders
|
|
+ public java.util.Collection<EntityRaider> getRaiders() {
|
|
+ return this.groupRaiderMap.values().stream().flatMap(Set::stream).collect(java.util.stream.Collectors.toSet());
|
|
+ }
|
|
+ // CraftBukkit end
|
|
+
|
|
private static enum Status {
|
|
|
|
ONGOING, VICTORY, LOSS, STOPPED;
|