mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-20 09:57:43 +01:00
50 lines
3.2 KiB
Diff
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 9f07b6bb89b2f7424d874aca8399c9a31f3bf669..c4677bac7a09133513cbeed9c712b93100783183 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
|
@@ -1830,7 +1830,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 53d0ccf95a6e07a00918f05ddaeeca699737d2eb..0e06db15572bf7d23d61f93c0b6de1b78ea4f990 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 {
|