-
-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dont eat blocks in non ticking chunks
- Loading branch information
1 parent
3d6e58c
commit 84028e2
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
patches/server/0259-Dont-eat-blocks-in-non-ticking-chunks.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
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 35bb7a3502c90462eb2d67e23bddb18030f40ad1..892d4914efe022619d061fc3e4b8a29a0adf6b68 100644 | ||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java | ||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java | ||
@@ -1748,7 +1748,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 8a4080a77bd5b73ac812e3ae67c6f21dcd270215..16e66ae7cf761fabb74a035e2fd8c28615365dc2 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 | ||
@@ -32,6 +32,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 { |