Skip to content

Commit

Permalink
clear weakref on data sync
Browse files Browse the repository at this point in the history
move comments to javadoc for controller and controller pos
  • Loading branch information
ghzdude committed Dec 8, 2023
1 parent b888d0b commit 5548d2b
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@

public abstract class MetaTileEntityQuantumStorage<T> extends MetaTileEntity implements IQuantumStorage<T> {

private WeakReference<IQuantumController> controller = new WeakReference<>(null); // not synced, server only. lazily
// initialized from pos
private BlockPos controllerPos; // synced, server and client
/** not synced, server only. lazily initialized from pos */
private WeakReference<IQuantumController> controller = new WeakReference<>(null);

/** synced, server and client */
private BlockPos controllerPos;

public MetaTileEntityQuantumStorage(ResourceLocation metaTileEntityId) {
super(metaTileEntityId);
Expand Down Expand Up @@ -158,8 +160,10 @@ public void receiveCustomData(int dataId, PacketBuffer buf) {
super.receiveCustomData(dataId, buf);
if (dataId == UPDATE_CONTROLLER_POS) {
this.controllerPos = buf.readBlockPos();
this.controller.clear();
} else if (dataId == REMOVE_CONTROLLER) {
this.controllerPos = null;
this.controller.clear();
}
}

Expand Down

0 comments on commit 5548d2b

Please sign in to comment.