9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00
Files
Leaf/leaf-archived-patches/unapplied/server/minecraft-patches/features/0094-Cache-tile-entity-position.patch
Dreeam 236010caba Cooking Tutorial
1. Wet the drys
2. Dry the wets
3. Wet the drys
4. Dry the wets
5. Wet the drys
6. Now dust the wets
2025-03-28 03:11:27 -04: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 290163335cf3967e2745442fd7d4d4fa16fb7bc0..238e015d4ff5fabb99e569118f253366d545d269 100644
--- a/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/net/minecraft/world/level/chunk/LevelChunk.java
@@ -936,10 +936,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
@@ -980,7 +982,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
@@ -1007,13 +1009,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
@@ -1028,7 +1033,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