From 7fccdb6e53b3deba00a3f81dfd61647780540bd1 Mon Sep 17 00:00:00 2001 From: Cubicake <74905@stpeters.sa.edu.au> Date: Mon, 20 Jul 2026 18:54:16 +0930 Subject: [PATCH] VarHandler --- .../core/tracked/NettyTileEntity.java | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/core/src/main/java/games/cubi/raycastedantiesp/core/tracked/NettyTileEntity.java b/core/src/main/java/games/cubi/raycastedantiesp/core/tracked/NettyTileEntity.java index 83f059af..e6f45868 100644 --- a/core/src/main/java/games/cubi/raycastedantiesp/core/tracked/NettyTileEntity.java +++ b/core/src/main/java/games/cubi/raycastedantiesp/core/tracked/NettyTileEntity.java @@ -3,25 +3,16 @@ package games.cubi.raycastedantiesp.core.tracked; import games.cubi.locatables.api.BlockSpatial; import games.cubi.raycastedantiesp.core.utils.Clearable; import games.cubi.raycastedantiesp.core.utils.InvasivelyLinkedSWMRList; +import games.cubi.raycastedantiesp.core.utils.VarHandler; -import java.lang.invoke.MethodHandles; import java.lang.invoke.VarHandle; +/** Tile visibility and lifecycle are shared with the engine; block and replay data are packet-thread-only. */ public abstract class NettyTileEntity extends InvasivelyLinkedSWMRList> implements TrackedTileEntity { - private static final VarHandle LAST_CHECKED; - - static { - try { - LAST_CHECKED = MethodHandles.lookup().findVarHandle(NettyTileEntity.class, "lastChecked", int.class); - } catch (ReflectiveOperationException exception) { - throw new ExceptionInInitializerError(exception); - } - } - private volatile boolean visible; - private volatile int lastChecked; - private volatile char blockID; - private volatile PacketReplayData extraData; + private volatile int lastChecked; private static final VarHandle LAST_CHECKED = VarHandler.get(NettyTileEntity.class, "lastChecked", int.class); + private char blockID; + private PacketReplayData extraData; private static final int REMOVED = Integer.MIN_VALUE + 11; @@ -32,7 +23,6 @@ public abstract class NettyTileEntity extend z = position.blockZ(); this.blockID = blockID; - this.visible = visible; LAST_CHECKED.set(this, lastChecked); }