geforkt von Mirrors/Paper
net.minecraft.world.entity.raid
Dieser Commit ist enthalten in:
Ursprung
aa7204fd62
Commit
368d2116ba
@ -1,30 +1,30 @@
|
||||
--- a/net/minecraft/world/entity/raid/Raid.java
|
||||
+++ b/net/minecraft/world/entity/raid/Raid.java
|
||||
@@ -107,6 +107,11 @@
|
||||
@@ -104,6 +_,11 @@
|
||||
private Raid.RaidStatus status;
|
||||
private int celebrationTicks;
|
||||
private Optional<BlockPos> waveSpawnPos;
|
||||
private Optional<BlockPos> waveSpawnPos = Optional.empty();
|
||||
+ // Paper start
|
||||
+ private static final String PDC_NBT_KEY = "BukkitValues";
|
||||
+ private static final org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry PDC_TYPE_REGISTRY = new org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry();
|
||||
+ public final org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer persistentDataContainer = new org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer(PDC_TYPE_REGISTRY);
|
||||
+ // Paper end
|
||||
|
||||
public Raid(int id, ServerLevel world, BlockPos pos) {
|
||||
this.raidEvent = new ServerBossEvent(Raid.RAID_NAME_COMPONENT, BossEvent.BossBarColor.RED, BossEvent.BossBarOverlay.NOTCHED_10);
|
||||
@@ -150,6 +155,11 @@
|
||||
this.heroesOfTheVillage.add(NbtUtils.loadUUID(nbtbase));
|
||||
public Raid(int id, ServerLevel level, BlockPos center) {
|
||||
this.id = id;
|
||||
@@ -136,6 +_,11 @@
|
||||
this.heroesOfTheVillage.add(NbtUtils.loadUUID(tag));
|
||||
}
|
||||
}
|
||||
+ // Paper start
|
||||
+ if (nbt.contains(PDC_NBT_KEY, net.minecraft.nbt.Tag.TAG_COMPOUND)) {
|
||||
+ this.persistentDataContainer.putAll(nbt.getCompound(PDC_NBT_KEY));
|
||||
+ if (compound.contains(PDC_NBT_KEY, net.minecraft.nbt.Tag.TAG_COMPOUND)) {
|
||||
+ this.persistentDataContainer.putAll(compound.getCompound(PDC_NBT_KEY));
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
}
|
||||
|
||||
@@ -177,6 +187,12 @@
|
||||
public boolean isOver() {
|
||||
@@ -162,6 +_,12 @@
|
||||
return this.status == Raid.RaidStatus.LOSS;
|
||||
}
|
||||
|
||||
@ -37,15 +37,15 @@
|
||||
public float getTotalHealth() {
|
||||
return this.totalHealth;
|
||||
}
|
||||
@@ -281,6 +297,7 @@
|
||||
|
||||
@@ -252,6 +_,7 @@
|
||||
boolean flag = this.active;
|
||||
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;
|
||||
}
|
||||
@@ -300,13 +317,16 @@
|
||||
@@ -271,13 +_,16 @@
|
||||
if (!this.level.isVillage(this.center)) {
|
||||
if (this.groupsSpawned > 0) {
|
||||
this.status = Raid.RaidStatus.LOSS;
|
||||
@ -56,33 +56,33 @@
|
||||
}
|
||||
}
|
||||
|
||||
++this.ticksActive;
|
||||
this.ticksActive++;
|
||||
if (this.ticksActive >= 48000L) {
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.TIMEOUT); // CraftBukkit
|
||||
this.stop();
|
||||
return;
|
||||
}
|
||||
@@ -374,6 +394,7 @@
|
||||
@@ -346,6 +_,7 @@
|
||||
}
|
||||
|
||||
if (j > 5) {
|
||||
if (i > 5) {
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.UNSPAWNABLE); // CraftBukkit
|
||||
this.stop();
|
||||
break;
|
||||
}
|
||||
@@ -386,6 +407,7 @@
|
||||
@@ -357,6 +_,7 @@
|
||||
} else {
|
||||
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();
|
||||
for (UUID uuid : this.heroesOfTheVillage) {
|
||||
Entity entity = this.level.getEntity(uuid);
|
||||
@@ -400,10 +422,12 @@
|
||||
|
||||
entityplayer.awardStat(Stats.RAID_WIN);
|
||||
CriteriaTriggers.RAID_WIN.trigger(entityplayer);
|
||||
+ winners.add(entityplayer.getBukkitEntity()); // CraftBukkit
|
||||
if (entity instanceof LivingEntity) {
|
||||
@@ -368,10 +_,12 @@
|
||||
if (livingEntity instanceof ServerPlayer serverPlayer) {
|
||||
serverPlayer.awardStat(Stats.RAID_WIN);
|
||||
CriteriaTriggers.RAID_WIN.trigger(serverPlayer);
|
||||
+ winners.add(serverPlayer.getBukkitEntity()); // CraftBukkit
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -91,84 +91,84 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -411,6 +435,7 @@
|
||||
@@ -379,6 +_,7 @@
|
||||
} else if (this.isOver()) {
|
||||
++this.celebrationTicks;
|
||||
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 +569,10 @@
|
||||
int j = araid_wave.length;
|
||||
int k = 0;
|
||||
@@ -491,6 +_,10 @@
|
||||
DifficultyInstance currentDifficultyAt = this.level.getCurrentDifficultyAt(pos);
|
||||
boolean shouldSpawnBonusGroup = this.shouldSpawnBonusGroup();
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ Raider leader = null;
|
||||
+ List<Raider> raiders = new java.util.ArrayList<>();
|
||||
+ // CraftBukkit end
|
||||
while (k < j) {
|
||||
Raid.RaiderType raid_wave = araid_wave[k];
|
||||
int l = this.getDefaultNumSpawns(raid_wave, i, flag1) + this.getPotentialBonusSpawns(raid_wave, this.random, i, difficultydamagescaler, flag1);
|
||||
@@ -559,9 +588,11 @@
|
||||
entityraider.setPatrolLeader(true);
|
||||
this.setLeader(i, entityraider);
|
||||
flag = true;
|
||||
+ leader = entityraider; // CraftBukkit
|
||||
}
|
||||
for (Raid.RaiderType raiderType : Raid.RaiderType.VALUES) {
|
||||
int i1 = this.getDefaultNumSpawns(raiderType, i, shouldSpawnBonusGroup)
|
||||
+ this.getPotentialBonusSpawns(raiderType, this.random, i, currentDifficultyAt, shouldSpawnBonusGroup);
|
||||
@@ -506,9 +_,11 @@
|
||||
raider.setPatrolLeader(true);
|
||||
this.setLeader(i, raider);
|
||||
flag = true;
|
||||
+ leader = raider; // CraftBukkit
|
||||
}
|
||||
|
||||
this.joinRaid(i, entityraider, pos, false);
|
||||
+ raiders.add(entityraider); // CraftBukkit
|
||||
if (raid_wave.entityType == EntityType.RAVAGER) {
|
||||
Raider entityraider1 = null;
|
||||
|
||||
@@ -580,6 +611,7 @@
|
||||
this.joinRaid(i, entityraider1, pos, false);
|
||||
entityraider1.moveTo(pos, 0.0F, 0.0F);
|
||||
entityraider1.startRiding(entityraider);
|
||||
+ raiders.add(entityraider); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -597,6 +629,7 @@
|
||||
++this.groupsSpawned;
|
||||
this.joinRaid(i, raider, pos, false);
|
||||
+ raiders.add(raider); // CraftBukkit
|
||||
if (raiderType.entityType == EntityType.RAVAGER) {
|
||||
Raider raider1 = null;
|
||||
if (i == this.getNumGroups(Difficulty.NORMAL)) {
|
||||
@@ -526,6 +_,7 @@
|
||||
this.joinRaid(i, raider1, pos, false);
|
||||
raider1.moveTo(pos, 0.0F, 0.0F);
|
||||
raider1.startRiding(raider);
|
||||
+ raiders.add(raider); // CraftBukkit
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -535,6 +_,7 @@
|
||||
this.groupsSpawned++;
|
||||
this.updateBossbar();
|
||||
this.setDirty();
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidSpawnWaveEvent(this, leader, raiders); // CraftBukkit
|
||||
}
|
||||
|
||||
public void joinRaid(int wave, Raider raider, @Nullable BlockPos pos, boolean existing) {
|
||||
@@ -612,7 +645,7 @@
|
||||
raider.finalizeSpawn(this.level, this.level.getCurrentDifficultyAt(pos), EntitySpawnReason.EVENT, (SpawnGroupData) null);
|
||||
public void joinRaid(int wave, Raider raider, @Nullable BlockPos pos, boolean isRecruited) {
|
||||
@@ -549,7 +_,7 @@
|
||||
raider.finalizeSpawn(this.level, this.level.getCurrentDifficultyAt(pos), EntitySpawnReason.EVENT, null);
|
||||
raider.applyRaidBuffs(this.level, wave, false);
|
||||
raider.setOnGround(true);
|
||||
- this.level.addFreshEntityWithPassengers(raider);
|
||||
+ this.level.addFreshEntityWithPassengers(raider, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.RAID); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -839,6 +872,11 @@
|
||||
}
|
||||
@@ -770,6 +_,11 @@
|
||||
}
|
||||
|
||||
nbt.put("HeroesOfTheVillage", nbttaglist);
|
||||
compound.put("HeroesOfTheVillage", listTag);
|
||||
+ // Paper start
|
||||
+ if (!this.persistentDataContainer.isEmpty()) {
|
||||
+ nbt.put(PDC_NBT_KEY, this.persistentDataContainer.toTagCompound());
|
||||
+ compound.put(PDC_NBT_KEY, this.persistentDataContainer.toTagCompound());
|
||||
+ }
|
||||
+ // Paper end
|
||||
return nbt;
|
||||
return compound;
|
||||
}
|
||||
|
||||
@@ -865,6 +903,12 @@
|
||||
this.heroesOfTheVillage.add(entity.getUUID());
|
||||
@@ -802,6 +_,12 @@
|
||||
public void addHeroOfTheVillage(Entity player) {
|
||||
this.heroesOfTheVillage.add(player.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;
|
||||
static enum RaidStatus {
|
||||
ONGOING,
|
@ -0,0 +1,54 @@
|
||||
--- a/net/minecraft/world/entity/raid/Raider.java
|
||||
+++ b/net/minecraft/world/entity/raid/Raider.java
|
||||
@@ -212,17 +_,24 @@
|
||||
if (this.hasActiveRaid()
|
||||
&& !flag
|
||||
&& ItemStack.matches(item, Raid.getOminousBannerInstance(this.registryAccess().lookupOrThrow(Registries.BANNER_PATTERN)))) {
|
||||
+ // Paper start - EntityPickupItemEvent fixes
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entity, 0, false).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end - EntityPickupItemEvent fixes
|
||||
EquipmentSlot equipmentSlot = EquipmentSlot.HEAD;
|
||||
ItemStack itemBySlot = this.getItemBySlot(equipmentSlot);
|
||||
double d = this.getEquipmentDropChance(equipmentSlot);
|
||||
if (!itemBySlot.isEmpty() && Math.max(this.random.nextFloat() - 0.1F, 0.0F) < d) {
|
||||
+ this.forceDrops = true; // Paper - Add missing forceDrop toggles
|
||||
this.spawnAtLocation(level, itemBySlot);
|
||||
+ this.forceDrops = false; // Paper - Add missing forceDrop toggles
|
||||
}
|
||||
|
||||
this.onItemPickup(entity);
|
||||
this.setItemSlot(equipmentSlot, item);
|
||||
this.take(entity, item.getCount());
|
||||
- entity.discard();
|
||||
+ entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
|
||||
this.getCurrentRaid().setLeader(this.getWave(), this);
|
||||
this.setPatrolLeader(true);
|
||||
} else {
|
||||
@@ -296,7 +_,7 @@
|
||||
|
||||
for (Raider raider : getServerLevel(this.mob)
|
||||
.getNearbyEntities(Raider.class, this.shoutTargeting, this.mob, this.mob.getBoundingBox().inflate(8.0, 8.0, 8.0))) {
|
||||
- raider.setTarget(this.mob.getTarget());
|
||||
+ raider.setTarget(this.mob.getTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.FOLLOW_LEADER, true); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,7 +_,7 @@
|
||||
if (target != null) {
|
||||
for (Raider raider : getServerLevel(this.mob)
|
||||
.getNearbyEntities(Raider.class, this.shoutTargeting, this.mob, this.mob.getBoundingBox().inflate(8.0, 8.0, 8.0))) {
|
||||
- raider.setTarget(target);
|
||||
+ raider.setTarget(target, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FOLLOW_LEADER, true); // CraftBukkit
|
||||
raider.setAggressive(true);
|
||||
}
|
||||
|
||||
@@ -392,6 +_,7 @@
|
||||
}
|
||||
|
||||
private boolean cannotPickUpBanner() {
|
||||
+ if (!getServerLevel(this.mob).getGameRules().getBoolean(net.minecraft.world.level.GameRules.RULE_MOBGRIEFING) || !this.mob.canPickUpLoot()) return false; // Paper - respect game and entity rules for picking up items
|
||||
if (!this.mob.hasActiveRaid()) {
|
||||
return true;
|
||||
} else if (this.mob.getCurrentRaid().isOver()) {
|
@ -1,16 +1,17 @@
|
||||
--- a/net/minecraft/world/entity/raid/Raids.java
|
||||
+++ b/net/minecraft/world/entity/raid/Raids.java
|
||||
@@ -115,11 +115,23 @@
|
||||
|
||||
Raid raid = this.getOrCreateRaid(player.serverLevel(), blockposition2);
|
||||
@@ -112,11 +_,23 @@
|
||||
}
|
||||
|
||||
Raid raid = this.getOrCreateRaid(player.serverLevel(), blockPos);
|
||||
+ /* CraftBukkit - moved down
|
||||
if (!raid.isStarted() && !this.raidMap.containsKey(raid.getId())) {
|
||||
this.raidMap.put(raid.getId(), raid);
|
||||
}
|
||||
+ */
|
||||
|
||||
-
|
||||
- if (!raid.isStarted() || raid.getRaidOmenLevel() < raid.getMaxRaidOmenLevel()) {
|
||||
+ */
|
||||
+
|
||||
+ if (!raid.isStarted() || (raid.isInProgress() && raid.getRaidOmenLevel() < raid.getMaxRaidOmenLevel())) { // CraftBukkit - fixed a bug with raid: players could add up Bad Omen level even when the raid had finished
|
||||
+ // CraftBukkit start
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callRaidTriggerEvent(raid, player)) {
|
@ -1,83 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/raid/Raider.java
|
||||
+++ b/net/minecraft/world/entity/raid/Raider.java
|
||||
@@ -40,6 +40,9 @@
|
||||
import net.minecraft.world.level.ServerLevelAccessor;
|
||||
import net.minecraft.world.level.pathfinder.Path;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityRemoveEvent;
|
||||
+// CraftBukkit end
|
||||
|
||||
public abstract class Raider extends PatrollingMonster {
|
||||
|
||||
@@ -225,18 +228,25 @@
|
||||
boolean flag = this.hasActiveRaid() && this.getCurrentRaid().getLeader(this.getWave()) != null;
|
||||
|
||||
if (this.hasActiveRaid() && !flag && ItemStack.matches(itemstack, Raid.getOminousBannerInstance(this.registryAccess().lookupOrThrow(Registries.BANNER_PATTERN)))) {
|
||||
+ // Paper start - EntityPickupItemEvent fixes
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, itemEntity, 0, false).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end - EntityPickupItemEvent fixes
|
||||
EquipmentSlot enumitemslot = EquipmentSlot.HEAD;
|
||||
ItemStack itemstack1 = this.getItemBySlot(enumitemslot);
|
||||
double d0 = (double) this.getEquipmentDropChance(enumitemslot);
|
||||
|
||||
if (!itemstack1.isEmpty() && (double) Math.max(this.random.nextFloat() - 0.1F, 0.0F) < d0) {
|
||||
+ this.forceDrops = true; // Paper - Add missing forceDrop toggles
|
||||
this.spawnAtLocation(world, itemstack1);
|
||||
+ this.forceDrops = false; // Paper - Add missing forceDrop toggles
|
||||
}
|
||||
|
||||
this.onItemPickup(itemEntity);
|
||||
this.setItemSlot(enumitemslot, itemstack);
|
||||
this.take(itemEntity, itemstack.getCount());
|
||||
- itemEntity.discard();
|
||||
+ itemEntity.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
|
||||
this.getCurrentRaid().setLeader(this.getWave(), this);
|
||||
this.setPatrolLeader(true);
|
||||
} else {
|
||||
@@ -290,7 +300,7 @@
|
||||
@Nullable
|
||||
private ItemEntity pursuedBannerItemEntity;
|
||||
|
||||
- public ObtainRaidLeaderBannerGoal(final Raider entityraider) {
|
||||
+ public ObtainRaidLeaderBannerGoal(final T entityraider) { // CraftBukkit - decompile error
|
||||
this.mob = entityraider;
|
||||
this.setFlags(EnumSet.of(Goal.Flag.MOVE));
|
||||
}
|
||||
@@ -335,6 +345,7 @@
|
||||
}
|
||||
|
||||
private boolean cannotPickUpBanner() {
|
||||
+ if (!getServerLevel(this.mob).getGameRules().getBoolean(net.minecraft.world.level.GameRules.RULE_MOBGRIEFING) || !this.mob.canPickUpLoot()) return false; // Paper - respect game and entity rules for picking up items
|
||||
if (!this.mob.hasActiveRaid()) {
|
||||
return true;
|
||||
} else if (this.mob.getCurrentRaid().isOver()) {
|
||||
@@ -518,7 +529,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- protected static class HoldGroundAttackGoal extends Goal {
|
||||
+ public static class HoldGroundAttackGoal extends Goal {
|
||||
|
||||
private final Raider mob;
|
||||
private final float hostileRadiusSqr;
|
||||
@@ -547,7 +558,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
Raider entityraider = (Raider) iterator.next();
|
||||
|
||||
- entityraider.setTarget(this.mob.getTarget());
|
||||
+ entityraider.setTarget(this.mob.getTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.FOLLOW_LEADER, true); // CraftBukkit
|
||||
}
|
||||
|
||||
}
|
||||
@@ -564,7 +575,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
Raider entityraider = (Raider) iterator.next();
|
||||
|
||||
- entityraider.setTarget(entityliving);
|
||||
+ entityraider.setTarget(this.mob.getTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.FOLLOW_LEADER, true); // CraftBukkit
|
||||
entityraider.setAggressive(true);
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren