9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0184-Cache-tile-entity-position.patch
2025-06-03 09:49:56 +08:00

60 lines
2.5 KiB
Diff

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
Dreeam TODO: 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 800fc055024c176d1830e1d2686f5d96131c8712..5325989f46bd288c5a6f1362ec17d3354d55abfd 100644
--- a/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/net/minecraft/world/level/chunk/LevelChunk.java
@@ -940,10 +940,12 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
private final T blockEntity;
private final BlockEntityTicker<T> ticker;
private boolean loggedInvalidBlockState;
+ private final BlockPos cachedPos; // Leaf - Cache tile entity position
BoundTickingBlockEntity(final T blockEntity, final BlockEntityTicker<T> ticker) {
this.blockEntity = blockEntity;
this.ticker = ticker;
+ this.cachedPos = this.blockEntity.getBlockPos(); // Leaf - Cache tile entity position
}
@Override
@@ -984,7 +986,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
@@ -1011,13 +1013,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
@@ -1032,7 +1037,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