craftbukkit/nms-patches/net/minecraft/world/entity/raid/Raid.patch

138 lines
6.1 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/entity/raid/Raid.java
+++ b/net/minecraft/world/entity/raid/Raid.java
2021-06-11 15:00:00 +10:00
@@ -174,6 +174,12 @@
2019-12-11 09:00:00 +11:00
return this.status == Raid.Status.LOSS;
2019-08-12 18:43:10 +07:00
}
+ // CraftBukkit start
+ public boolean isInProgress() {
2019-12-11 09:00:00 +11:00
+ return this.status == Status.ONGOING;
2019-08-12 18:43:10 +07:00
+ }
+ // CraftBukkit end
+
2021-11-22 09:00:00 +11:00
public float getTotalHealth() {
2021-06-11 15:00:00 +10:00
return this.totalHealth;
2019-08-12 18:43:10 +07:00
}
2021-06-11 15:00:00 +10:00
@@ -270,6 +276,7 @@
2019-08-12 18:43:10 +07:00
2021-11-22 09:00:00 +11:00
this.active = this.level.hasChunkAt(this.center);
2021-06-11 15:00:00 +10:00
if (this.level.getDifficulty() == EnumDifficulty.PEACEFUL) {
2019-08-12 18:43:10 +07:00
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.PEACE); // CraftBukkit
2019-12-11 09:00:00 +11:00
this.stop();
2019-08-12 18:43:10 +07:00
return;
}
2021-06-11 15:00:00 +10:00
@@ -289,13 +296,16 @@
2021-11-22 09:00:00 +11:00
if (!this.level.isVillage(this.center)) {
2019-12-11 09:00:00 +11:00
if (this.groupsSpawned > 0) {
this.status = Raid.Status.LOSS;
2019-08-12 18:43:10 +07: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-11 09:00:00 +11:00
this.stop();
2019-08-12 18:43:10 +07:00
}
}
2019-12-11 09:00:00 +11:00
++this.ticksActive;
if (this.ticksActive >= 48000L) {
2019-08-12 18:43:10 +07:00
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.TIMEOUT); // CraftBukkit
2019-12-11 09:00:00 +11:00
this.stop();
2019-08-12 18:43:10 +07:00
return;
}
2021-06-11 15:00:00 +10:00
@@ -369,6 +379,7 @@
2019-08-12 18:43:10 +07:00
}
if (j > 3) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.UNSPAWNABLE); // CraftBukkit
2019-12-11 09:00:00 +11:00
this.stop();
2019-08-12 18:43:10 +07:00
break;
}
2021-06-11 15:00:00 +10:00
@@ -381,6 +392,7 @@
2019-12-11 09:00:00 +11:00
this.status = Raid.Status.VICTORY;
2021-06-11 15:00:00 +10:00
Iterator iterator = this.heroesOfTheVillage.iterator();
2019-08-12 18:43:10 +07:00
+ List<org.bukkit.entity.Player> winners = new java.util.ArrayList<>(); // CraftBukkit
while (iterator.hasNext()) {
UUID uuid = (UUID) iterator.next();
2021-06-11 15:00:00 +10:00
Entity entity = this.level.getEntity(uuid);
@@ -394,9 +406,11 @@
2019-08-12 18:43:10 +07:00
2021-11-22 09:00:00 +11:00
entityplayer.awardStat(StatisticList.RAID_WIN);
CriterionTriggers.RAID_WIN.trigger(entityplayer);
2019-08-12 18:43:10 +07:00
+ winners.add(entityplayer.getBukkitEntity()); // CraftBukkit
}
}
}
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidFinishEvent(this, winners); // CraftBukkit
}
}
2021-06-11 15:00:00 +10:00
@@ -404,6 +418,7 @@
2021-11-22 09:00:00 +11:00
} else if (this.isOver()) {
2021-06-11 15:00:00 +10:00
++this.celebrationTicks;
if (this.celebrationTicks >= 600) {
2019-08-12 18:43:10 +07:00
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.FINISHED); // CraftBukkit
2019-12-11 09:00:00 +11:00
this.stop();
2019-08-12 18:43:10 +07:00
return;
}
2021-06-11 15:00:00 +10:00
@@ -538,6 +553,10 @@
Raid.Wave[] araid_wave = Raid.Wave.VALUES;
2019-08-12 18:43:10 +07:00
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];
2021-11-22 09:00:00 +11:00
int l = this.getDefaultNumSpawns(raid_wave, i, flag1) + this.getPotentialBonusSpawns(raid_wave, this.random, i, difficultydamagescaler, flag1);
2021-06-11 15:00:00 +10:00
@@ -550,9 +569,11 @@
2019-08-12 18:43:10 +07:00
entityraider.setPatrolLeader(true);
2021-11-22 09:00:00 +11:00
this.setLeader(i, entityraider);
2019-08-12 18:43:10 +07:00
flag = true;
+ leader = entityraider; // CraftBukkit
}
2021-11-22 09:00:00 +11:00
this.joinRaid(i, entityraider, blockposition, false);
2019-08-12 18:43:10 +07:00
+ raiders.add(entityraider); // CraftBukkit
2021-06-11 15:00:00 +10:00
if (raid_wave.entityType == EntityTypes.RAVAGER) {
2019-08-12 18:43:10 +07:00
EntityRaider entityraider1 = null;
2021-06-11 15:00:00 +10:00
@@ -571,6 +592,7 @@
2021-11-22 09:00:00 +11:00
this.joinRaid(i, entityraider1, blockposition, false);
entityraider1.moveTo(blockposition, 0.0F, 0.0F);
2019-08-12 18:43:10 +07:00
entityraider1.startRiding(entityraider);
+ raiders.add(entityraider); // CraftBukkit
}
}
}
2021-06-11 15:00:00 +10:00
@@ -580,6 +602,7 @@
2019-12-11 09:00:00 +11:00
++this.groupsSpawned;
2021-11-22 09:00:00 +11:00
this.updateBossbar();
this.setDirty();
2019-08-12 18:43:10 +07:00
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidSpawnWaveEvent(this, leader, raiders); // CraftBukkit
}
2021-11-22 09:00:00 +11:00
public void joinRaid(int i, EntityRaider entityraider, @Nullable BlockPosition blockposition, boolean flag) {
2021-06-11 15:00:00 +10:00
@@ -595,7 +618,7 @@
2021-11-22 09:00:00 +11:00
entityraider.finalizeSpawn(this.level, this.level.getCurrentDifficultyAt(blockposition), EnumMobSpawn.EVENT, (GroupDataEntity) null, (NBTTagCompound) null);
entityraider.applyRaidBuffs(i, false);
2020-08-12 07:00:00 +10:00
entityraider.setOnGround(true);
2021-11-22 09:00:00 +11:00
- this.level.addFreshEntityWithPassengers(entityraider);
+ this.level.addFreshEntityWithPassengers(entityraider, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.RAID); // CraftBukkit
}
}
2021-11-22 09:00:00 +11:00
@@ -845,6 +868,12 @@
this.heroesOfTheVillage.add(entity.getUUID());
2019-08-12 18:43:10 +07:00
}
+ // CraftBukkit start - a method to get all raiders
+ public java.util.Collection<EntityRaider> getRaiders() {
2021-06-11 15:00:00 +10:00
+ return this.groupRaiderMap.values().stream().flatMap(Set::stream).collect(java.util.stream.Collectors.toSet());
2019-08-12 18:43:10 +07:00
+ }
+ // CraftBukkit end
+
2021-06-11 15:00:00 +10:00
private static enum Status {
2019-08-12 18:43:10 +07:00
2021-06-11 15:00:00 +10:00
ONGOING, VICTORY, LOSS, STOPPED;