9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2025-12-30 20:29:10 +00:00

Improve BlockEntity ticking isRemoved check

This commit is contained in:
NONPLAYT
2025-03-26 01:47:54 +03:00
parent b307ae4fc3
commit 7246aec0a9

View File

@@ -0,0 +1,50 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
Date: Wed, 26 Mar 2025 01:46:49 +0300
Subject: [PATCH] Leaf: Improve BlockEntity ticking isRemoved check
diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java
index 0337f4b9ca3c9c9a1e2a7cf19fcbad5e78b949dc..1820069a7c5833b0a13e034c232f06af234788e3 100644
--- a/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/net/minecraft/world/level/chunk/LevelChunk.java
@@ -989,13 +989,26 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
public static class RebindableTickingBlockEntityWrapper implements TickingBlockEntity {
public TickingBlockEntity ticker;
+ private @Nullable BlockEntity blockEntityReference = null; // DivineMC - Improve BlockEntity ticking isRemoved check
RebindableTickingBlockEntityWrapper(TickingBlockEntity ticker) {
this.ticker = ticker;
+ // DivineMC start - Improve BlockEntity ticking isRemoved check
+ if (ticker instanceof BoundTickingBlockEntity<?> boundTicker) {
+ blockEntityReference = boundTicker.blockEntity;
+ }
+ // DivineMC end - Improve BlockEntity ticking isRemoved check
}
public void rebind(TickingBlockEntity ticker) {
this.ticker = ticker;
+ // DivineMC start - Improve BlockEntity ticking isRemoved check
+ if (ticker instanceof BoundTickingBlockEntity<?> boundTicker) {
+ blockEntityReference = boundTicker.blockEntity;
+ } else {
+ blockEntityReference = null;
+ }
+ // DivineMC end - Improve BlockEntity ticking isRemoved check
}
@Override
@@ -1005,6 +1018,12 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
@Override
public boolean isRemoved() {
+ // DivineMC start - Improve BlockEntity ticking isRemoved check
+ if (blockEntityReference != null) {
+ return blockEntityReference.isRemoved();
+ }
+ // DivineMC end - Improve BlockEntity ticking isRemoved check
+
return this.ticker.isRemoved();
}