Files
Purpur/patches/server/0254-Dont-eat-blocks-in-non-ticking-chunks.patch
William Blake Galbreath 4a049149c0 Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@99aa5f2 Fixes parsing tags in selectors in command functions
PaperMC/Paper@698b315 Improve migration file errors (#7929)
PaperMC/Paper@8bca919 Remove unneeded patch
PaperMC/Paper@a8a01bb port Significantly improve performance of the end generation (#7919)
PaperMC/Paper@cf384f5 Don't print stacktrace when client with invalid signature logs in
PaperMC/Paper@9b6fb2f Remove bad warning
PaperMC/Paper@0754819 Updated Upstream (CraftBukkit)
PaperMC/Paper@9a75a79 Readd PlayerAnimationEvent constructor removed by upstream
2022-06-10 12:40:16 -05:00

50 lines
3.2 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 8a36478ae555d3becf6e210092854221d3428cd2..1f73174c097695afbd63b01b2ecbceaa3bbbc77e 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1826,7 +1826,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/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index a6bd9ced7805d4c0f0185feca2afe87e198b6f98..bd2b4cbb3286ef72e40a8089aa41230826203959 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -286,7 +286,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
public double yo;
public double zo;
private Vec3 position;
- private BlockPos blockPosition;
+ public BlockPos blockPosition; // Purpur - private->public
private ChunkPos chunkPosition;
private Vec3 deltaMovement;
public float yRot; // Paper - private->public
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..a7b878f97128e530c5b47873dd226490d471406b 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 {