From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> Date: Fri, 25 Oct 2024 22:27:07 -0400 Subject: [PATCH] Cache tile entity position Check if there is a way to cache isRemoved without problem diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java index d97d8e79034eb1484d4e3646faacc6f11289bb28..a58a36a8a473e610f604fa778df860470caf7176 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java @@ -938,10 +938,12 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p private final T blockEntity; private final BlockEntityTicker ticker; private boolean loggedInvalidBlockState; + private BlockPos cachedPos; // Leaf - Cache tile entity position BoundTickingBlockEntity(final T blockEntity, final BlockEntityTicker ticker) { this.blockEntity = blockEntity; this.ticker = ticker; + this.cachedPos = this.blockEntity.getBlockPos(); // Leaf - Cache tile entity position } @Override @@ -982,7 +984,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p @Override public BlockPos getPos() { - return this.blockEntity.getBlockPos(); + return this.cachedPos; // Leaf - Cache tile entity position } @Override @@ -1009,13 +1011,16 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p static class RebindableTickingBlockEntityWrapper implements TickingBlockEntity { private TickingBlockEntity ticker; + private BlockPos cachedPos; // Leaf - Cache tile entity position RebindableTickingBlockEntityWrapper(TickingBlockEntity ticker) { this.ticker = ticker; + this.cachedPos = this.ticker.getPos(); // Leaf - Cache tile entity position } void rebind(TickingBlockEntity ticker) { this.ticker = ticker; + this.cachedPos = this.ticker.getPos(); // Leaf - Cache tile entity position } @Override @@ -1030,7 +1035,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p @Override public BlockPos getPos() { - return this.ticker.getPos(); + return this.cachedPos; // Leaf - Cache tile entity position } @Override