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

139 lines
6.2 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
2024-06-14 01:05:00 +10:00
@@ -177,6 +177,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
}
2024-06-14 01:05:00 +10:00
@@ -281,6 +287,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;
}
2024-06-14 01:05:00 +10:00
@@ -300,13 +307,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;
}
2024-10-23 02:15:00 +11:00
@@ -374,6 +384,7 @@
2019-08-12 18:43:10 +07:00
}
2024-10-23 02:15:00 +11:00
if (j > 5) {
2019-08-12 18:43:10 +07:00
+ 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;
}
2024-10-23 02:15:00 +11:00
@@ -386,6 +397,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);
2024-10-23 02:15:00 +11:00
@@ -400,10 +412,12 @@
2019-08-12 18:43:10 +07:00
2023-09-22 02:40:00 +10:00
entityplayer.awardStat(StatisticList.RAID_WIN);
CriterionTriggers.RAID_WIN.trigger(entityplayer);
+ winners.add(entityplayer.getBukkitEntity()); // CraftBukkit
}
2019-08-12 18:43:10 +07:00
}
}
}
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidFinishEvent(this, winners); // CraftBukkit
}
}
2024-10-23 02:15:00 +11:00
@@ -411,6 +425,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;
}
2024-10-23 02:15:00 +11:00
@@ -544,6 +559,10 @@
2019-08-12 18:43:10 +07:00
int j = araid_wave.length;
2022-12-08 03:00:00 +11:00
int k = 0;
2019-08-12 18:43:10 +07:00
+ // CraftBukkit start
+ EntityRaider leader = null;
+ List<EntityRaider> raiders = new java.util.ArrayList<>();
+ // CraftBukkit end
2022-12-08 03:00:00 +11:00
while (k < j) {
2019-08-12 18:43:10 +07:00
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);
2024-10-23 02:15:00 +11:00
@@ -559,9 +578,11 @@
2022-12-08 03:00:00 +11:00
entityraider.setPatrolLeader(true);
this.setLeader(i, entityraider);
flag = true;
+ leader = entityraider; // CraftBukkit
}
2019-08-12 18:43:10 +07:00
2022-12-08 03:00:00 +11:00
this.joinRaid(i, entityraider, blockposition, false);
2019-08-12 18:43:10 +07:00
+ raiders.add(entityraider); // CraftBukkit
2022-12-08 03:00:00 +11:00
if (raid_wave.entityType == EntityTypes.RAVAGER) {
EntityRaider entityraider1 = null;
2024-10-23 02:15:00 +11:00
@@ -580,6 +601,7 @@
2022-12-08 03:00:00 +11:00
this.joinRaid(i, entityraider1, blockposition, false);
entityraider1.moveTo(blockposition, 0.0F, 0.0F);
entityraider1.startRiding(entityraider);
+ raiders.add(entityraider); // CraftBukkit
}
}
2024-10-23 02:15:00 +11:00
@@ -597,6 +619,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) {
2024-10-23 02:15:00 +11:00
@@ -612,7 +635,7 @@
entityraider.finalizeSpawn(this.level, this.level.getCurrentDifficultyAt(blockposition), EntitySpawnReason.EVENT, (GroupDataEntity) null);
2024-06-14 01:05:00 +10:00
entityraider.applyRaidBuffs(this.level, 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
}
}
2024-10-23 02:15:00 +11:00
@@ -865,6 +888,12 @@
2021-11-22 09:00:00 +11:00
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;