diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/entity/raid/Raids.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/entity/raid/Raids.java.patch | 232 |
1 files changed, 232 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/entity/raid/Raids.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/entity/raid/Raids.java.patch new file mode 100644 index 0000000000..9eda1a872a --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/entity/raid/Raids.java.patch @@ -0,0 +1,232 @@ +--- a/net/minecraft/world/entity/raid/Raids.java ++++ b/net/minecraft/world/entity/raid/Raids.java +@@ -27,14 +27,19 @@ + import net.minecraft.world.phys.Vec3; + + public class Raids extends SavedData { ++ + private static final String RAID_FILE_ID = "raids"; +- private final Map<Integer, Raid> raidMap = Maps.newHashMap(); ++ public final Map<Integer, Raid> raidMap = Maps.newHashMap(); + private final ServerLevel level; + private int nextAvailableID; + private int tick; + +- public static SavedData.Factory<Raids> factory(ServerLevel serverLevel) { +- return new SavedData.Factory<>(() -> new Raids(serverLevel), compoundTag -> load(serverLevel, compoundTag), DataFixTypes.SAVED_DATA_RAIDS); ++ public static SavedData.a<Raids> factory(ServerLevel worldserver) { ++ return new SavedData.a<>(() -> { ++ return new Raids(worldserver); ++ }, (nbttagcompound) -> { ++ return load(worldserver, nbttagcompound); ++ }, DataFixTypes.SAVED_DATA_RAIDS); + } + + public Raids(ServerLevel level) { +@@ -44,15 +49,16 @@ + } + + public Raid get(int id) { +- return this.raidMap.get(id); ++ return (Raid) this.raidMap.get(id); + } + + public void tick() { +- this.tick++; +- Iterator<Raid> iterator = this.raidMap.values().iterator(); ++ ++this.tick; ++ Iterator iterator = this.raidMap.values().iterator(); + + while (iterator.hasNext()) { +- Raid raid = iterator.next(); ++ Raid raid = (Raid) iterator.next(); ++ + if (this.level.getGameRules().getBoolean(GameRules.RULE_DISABLE_RAIDS)) { + raid.stop(); + } +@@ -73,13 +79,7 @@ + } + + public static boolean canJoinRaid(Raider raider, Raid raid) { +- return raider != null +- && raid != null +- && raid.getLevel() != null +- && raider.isAlive() +- && raider.canJoinRaid() +- && raider.getNoActionTime() <= 2400 +- && raider.level().dimensionType() == raid.getLevel().dimensionType(); ++ return raider != null && raid != null && raid.getLevel() != null ? raider.isAlive() && raider.canJoinRaid() && raider.getNoActionTime() <= 2400 && raider.level().dimensionType() == raid.getLevel().dimensionType() : false; + } + + @Nullable +@@ -89,50 +89,67 @@ + } else if (this.level.getGameRules().getBoolean(GameRules.RULE_DISABLE_RAIDS)) { + return null; + } else { +- DimensionType dimensionType = serverPlayer.level().dimensionType(); +- if (!dimensionType.hasRaids()) { ++ DimensionType dimensionmanager = serverPlayer.level().dimensionType(); ++ ++ if (!dimensionmanager.hasRaids()) { + return null; + } else { +- BlockPos blockPos = serverPlayer.blockPosition(); +- List<PoiRecord> list = this.level +- .getPoiManager() +- .getInRange(holder -> holder.is(PoiTypeTags.VILLAGE), blockPos, 64, PoiManager.Occupancy.IS_OCCUPIED) +- .toList(); ++ BlockPos blockposition = serverPlayer.blockPosition(); ++ List<PoiRecord> list = this.level.getPoiManager().getInRange((holder) -> { ++ return holder.is(PoiTypeTags.VILLAGE); ++ }, blockposition, 64, PoiManager.Occupancy.IS_OCCUPIED).toList(); + int i = 0; +- Vec3 vec3 = Vec3.ZERO; ++ Vec3 vec3d = Vec3.ZERO; + +- for (PoiRecord poiRecord : list) { +- BlockPos pos = poiRecord.getPos(); +- vec3 = vec3.add((double)pos.getX(), (double)pos.getY(), (double)pos.getZ()); +- i++; ++ for (Iterator iterator = list.iterator(); iterator.hasNext(); ++i) { ++ PoiRecord villageplacerecord = (PoiRecord) iterator.next(); ++ BlockPos blockposition1 = villageplacerecord.getPos(); ++ ++ vec3d = vec3d.add((double) blockposition1.getX(), (double) blockposition1.getY(), (double) blockposition1.getZ()); + } + +- BlockPos blockPos1; ++ BlockPos blockposition2; ++ + if (i > 0) { +- vec3 = vec3.scale(1.0 / (double)i); +- blockPos1 = BlockPos.containing(vec3); ++ vec3d = vec3d.scale(1.0D / (double) i); ++ blockposition2 = BlockPos.containing(vec3d); + } else { +- blockPos1 = blockPos; ++ blockposition2 = blockposition; + } + +- Raid raid = this.getOrCreateRaid(serverPlayer.serverLevel(), blockPos1); ++ Raid raid = this.getOrCreateRaid(serverPlayer.serverLevel(), blockposition2); + boolean flag = false; ++ + if (!raid.isStarted()) { ++ /* CraftBukkit - moved down + if (!this.raidMap.containsKey(raid.getId())) { + this.raidMap.put(raid.getId(), raid); + } ++ */ + + flag = true; +- } else if (raid.getBadOmenLevel() < raid.getMaxBadOmenLevel()) { ++ // CraftBukkit start - fixed a bug with raid: players could add up Bad Omen level even when the raid had finished ++ } else if (raid.isInProgress() && raid.getBadOmenLevel() < raid.getMaxBadOmenLevel()) { + flag = true; ++ // CraftBukkit end + } else { + serverPlayer.removeEffect(MobEffects.BAD_OMEN); +- serverPlayer.connection.send(new ClientboundEntityEventPacket(serverPlayer, (byte)43)); ++ serverPlayer.connection.send(new ClientboundEntityEventPacket(serverPlayer, (byte) 43)); + } + + if (flag) { ++ // CraftBukkit start ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callRaidTriggerEvent(raid, serverPlayer)) { ++ serverPlayer.removeEffect(MobEffects.BAD_OMEN); ++ return null; ++ } ++ ++ if (!this.raidMap.containsKey(raid.getId())) { ++ this.raidMap.put(raid.getId(), raid); ++ } ++ // CraftBukkit end + raid.absorbBadOmen(serverPlayer); +- serverPlayer.connection.send(new ClientboundEntityEventPacket(serverPlayer, (byte)43)); ++ serverPlayer.connection.send(new ClientboundEntityEventPacket(serverPlayer, (byte) 43)); + if (!raid.hasFirstWaveSpawned()) { + serverPlayer.awardStat(Stats.RAID_TRIGGER); + CriteriaTriggers.BAD_OMEN.trigger(serverPlayer); +@@ -146,38 +163,44 @@ + } + + private Raid getOrCreateRaid(ServerLevel serverLevel, BlockPos pos) { +- Raid raidAt = serverLevel.getRaidAt(pos); +- return raidAt != null ? raidAt : new Raid(this.getUniqueId(), serverLevel, pos); ++ Raid raid = serverLevel.getRaidAt(pos); ++ ++ return raid != null ? raid : new Raid(this.getUniqueId(), serverLevel, pos); + } + + public static Raids load(ServerLevel level, CompoundTag tag) { +- Raids raids = new Raids(level); +- raids.nextAvailableID = tag.getInt("NextAvailableID"); +- raids.tick = tag.getInt("Tick"); +- ListTag list = tag.getList("Raids", 10); ++ Raids persistentraid = new Raids(level); + +- for (int i = 0; i < list.size(); i++) { +- CompoundTag compound = list.getCompound(i); +- Raid raid = new Raid(level, compound); +- raids.raidMap.put(raid.getId(), raid); ++ persistentraid.nextAvailableID = tag.getInt("NextAvailableID"); ++ persistentraid.tick = tag.getInt("Tick"); ++ ListTag nbttaglist = tag.getList("Raids", 10); ++ ++ for (int i = 0; i < nbttaglist.size(); ++i) { ++ CompoundTag nbttagcompound1 = nbttaglist.getCompound(i); ++ Raid raid = new Raid(level, nbttagcompound1); ++ ++ persistentraid.raidMap.put(raid.getId(), raid); + } + +- return raids; ++ return persistentraid; + } + + @Override + public CompoundTag save(CompoundTag compound) { + compound.putInt("NextAvailableID", this.nextAvailableID); + compound.putInt("Tick", this.tick); +- ListTag list = new ListTag(); ++ ListTag nbttaglist = new ListTag(); ++ Iterator iterator = this.raidMap.values().iterator(); + +- for (Raid raid : this.raidMap.values()) { +- CompoundTag compoundTag = new CompoundTag(); +- raid.save(compoundTag); +- list.add(compoundTag); ++ while (iterator.hasNext()) { ++ Raid raid = (Raid) iterator.next(); ++ CompoundTag nbttagcompound1 = new CompoundTag(); ++ ++ raid.save(nbttagcompound1); ++ nbttaglist.add(nbttagcompound1); + } + +- compound.put("Raids", list); ++ compound.put("Raids", nbttaglist); + return compound; + } + +@@ -192,13 +215,16 @@ + @Nullable + public Raid getNearbyRaid(BlockPos pos, int distance) { + Raid raid = null; +- double d = (double)distance; ++ double d0 = (double) distance; ++ Iterator iterator = this.raidMap.values().iterator(); + +- for (Raid raid1 : this.raidMap.values()) { ++ while (iterator.hasNext()) { ++ Raid raid1 = (Raid) iterator.next(); + double d1 = raid1.getCenter().distSqr(pos); +- if (raid1.isActive() && d1 < d) { ++ ++ if (raid1.isActive() && d1 < d0) { + raid = raid1; +- d = d1; ++ d0 = d1; + } + } + |