Skip to content

Commit

Permalink
Clean up AEHostable part fix (GregTechCEu#2488)
Browse files Browse the repository at this point in the history
  • Loading branch information
M-W-K authored Jun 4, 2024
1 parent ec756bb commit 97dd250
Showing 1 changed file with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public abstract class MetaTileEntityAEHostablePart<T extends IAEStack<T>> extend
private AENetworkProxy aeProxy;
private int meUpdateTick;
protected boolean isOnline;
protected boolean lastOnline;

public MetaTileEntityAEHostablePart(ResourceLocation metaTileEntityId, int tier, boolean isExportHatch,
Class<? extends IStorageChannel<T>> storageChannel) {
Expand Down Expand Up @@ -102,8 +101,11 @@ public void receiveInitialSyncData(PacketBuffer buf) {
public void receiveCustomData(int dataId, PacketBuffer buf) {
super.receiveCustomData(dataId, buf);
if (dataId == UPDATE_ONLINE_STATUS) {
this.isOnline = buf.readBoolean();
scheduleRenderUpdate();
boolean isOnline = buf.readBoolean();
if (this.isOnline != isOnline) {
this.isOnline = isOnline;
scheduleRenderUpdate();
}
}
}

Expand Down Expand Up @@ -140,19 +142,17 @@ public void setFrontFacing(EnumFacing frontFacing) {
public void gridChanged() {}

/**
* Update me network connection status.
* Get the me network connection status, updating it if on serverside.
*
* @return the updated status.
*/
public boolean updateMEStatus() {
if (this.aeProxy != null) {
this.isOnline = this.aeProxy.isActive() && this.aeProxy.isPowered();
} else {
this.isOnline = false;
}
if (!getWorld().isRemote && this.isOnline != this.lastOnline) {
writeCustomData(UPDATE_ONLINE_STATUS, buf -> buf.writeBoolean(this.isOnline));
this.lastOnline = this.isOnline;
if (!getWorld().isRemote) {
boolean isOnline = this.aeProxy != null && this.aeProxy.isActive() && this.aeProxy.isPowered();
if (this.isOnline != isOnline) {
writeCustomData(UPDATE_ONLINE_STATUS, buf -> buf.writeBoolean(isOnline));
this.isOnline = isOnline;
}
}
return this.isOnline;
}
Expand Down

0 comments on commit 97dd250

Please sign in to comment.