Files
Purpur/patches/server/0249-Dont-eat-blocks-in-non-ticking-chunks.patch
Encode42 fe3250cfec Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@c1bca9a Add exploded block state to BlockExplodeEvent (#6818)
PaperMC/Paper@94373f0 Fix OfflinePlayer#getPlayerProfile returning deprecated type (#8543)
PaperMC/Paper@7b52db5 Fix buffer-joins-to-world patch
PaperMC/Paper@048ee58 Fix OfflinePlayer getPlayerProfile return type (#8710)
PaperMC/Paper@e05ba98 Avoid to spam the transform event for hoglin->zoglin conversion (#8712)
PaperMC/Paper@8e83c3c Deprecate ProjectileCollideEvent (#8678)
PaperMC/Paper@c59922d Expose signed message in chat events (#8694)
PaperMC/Paper@5717b84 Add config option for spider worldborder climbing (#6448)
PaperMC/Paper@e6f61f7 fix ArmorStandMeta not applying false flags (#8632)
PaperMC/Paper@47abd1c Add EntityPushedByEntityEvent (#7704)
PaperMC/Paper@f26e9cc Tadpole lock API (#8297)
PaperMC/Paper@3331501 Use team display name for quit message (#7127)
PaperMC/Paper@1975fbe Respect SpigotConfig logCommands & fix stopDancing() NPE (#8715)
PaperMC/Paper@78a91df Fix (again) Player#getPlayerProfile no such method error (#8722)
PaperMC/Paper@52718db Updated Upstream (Bukkit/CraftBukkit) (#8714)
PaperMC/Paper@2040c1e Player Flying Fall Damage API (#5357)
2022-12-27 15:55:36 -05:00

37 lines
2.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: BillyGalbreath <Blake.Galbreath@Gmail.com>
Date: Sat, 15 Jan 2022 06:23:04 -0600
Subject: [PATCH] Dont eat blocks in non ticking chunks
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index d939b1e3bc101e66bc1019cf49d8079665dadfcc..3d78c10a5442bfa5d4beae2546378b3822f0465d 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -995,7 +995,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
return this.anyPlayerCloseEnoughForSpawning(this.getUpdatingChunkIfPresent(chunkcoordintpair.toLong()), chunkcoordintpair, reducedRange);
}
- final boolean anyPlayerCloseEnoughForSpawning(ChunkHolder playerchunk, ChunkPos chunkcoordintpair, boolean reducedRange) {
+ public final boolean anyPlayerCloseEnoughForSpawning(ChunkHolder playerchunk, ChunkPos chunkcoordintpair, boolean reducedRange) { // Purpur - package -> public
// this function is so hot that removing the map lookup call can have an order of magnitude impact on its performance
// tested and confirmed via System.nanoTime()
com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> playersInRange = reducedRange ? playerchunk.playersInMobSpawnRange : playerchunk.playersInChunkTickRange;
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/EatBlockGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/EatBlockGoal.java
index 3a633f369af8005de3c06cfa715a42e3b248b2f0..c55118a4d2237a33039b63dc797ccdb86b63344f 100644
--- a/src/main/java/net/minecraft/world/entity/ai/goal/EatBlockGoal.java
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/EatBlockGoal.java
@@ -31,6 +31,12 @@ public class EatBlockGoal extends Goal {
@Override
public boolean canUse() {
+ // Purpur start
+ net.minecraft.world.level.chunk.LevelChunk chunk = this.mob.level.getChunkIfLoaded(this.mob.blockPosition());
+ if (chunk == null || chunk.playerChunk == null || !((net.minecraft.server.level.ServerLevel) this.mob.level).getChunkSource().chunkMap.anyPlayerCloseEnoughForSpawning(chunk.playerChunk, this.mob.chunkPosition(), false)) {
+ return false;
+ }
+ // Purpur end
if (this.mob.getRandom().nextInt(this.mob.isBaby() ? 50 : 1000) != 0) {
return false;
} else {