Skip to content

Commit

Permalink
Fix Stocking Buses running recipes while offline (#2608)
Browse files Browse the repository at this point in the history
  • Loading branch information
ALongStringOfNumbers authored Nov 24, 2024
1 parent 7509825 commit 7141fcf
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public abstract class MetaTileEntityAEHostablePart<T extends IAEStack<T>> extend
private int meUpdateTick;
protected boolean isOnline;
private boolean allowExtraConnections;
protected boolean meStatusChanged = false;

public MetaTileEntityAEHostablePart(ResourceLocation metaTileEntityId, int tier, boolean isExportHatch,
Class<? extends IStorageChannel<T>> storageChannel) {
Expand Down Expand Up @@ -158,6 +159,9 @@ public boolean updateMEStatus() {
if (this.isOnline != isOnline) {
writeCustomData(UPDATE_ONLINE_STATUS, buf -> buf.writeBoolean(isOnline));
this.isOnline = isOnline;
this.meStatusChanged = true;
} else {
this.meStatusChanged = false;
}
}
return this.isOnline;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,22 @@ protected ExportOnlyAEStockingItemList getAEItemHandler() {
@Override
public void update() {
super.update();
if (!getWorld().isRemote && isWorkingEnabled() && autoPull && getOffsetTimer() % 100 == 0) {
refreshList();
syncME();
if (!getWorld().isRemote) {
if (isWorkingEnabled() && autoPull && getOffsetTimer() % 100 == 0) {
refreshList();
syncME();
}

// Immediately clear cached items if the status changed, to prevent running recipes while offline
if (this.meStatusChanged && !this.isOnline) {
if (autoPull) {
clearInventory(0);
} else {
for (int i = 0; i < CONFIG_SIZE; i++) {
getAEItemHandler().getInventory()[i].setStack(null);
}
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,22 @@ protected ExportOnlyAEStockingFluidList getAEFluidHandler() {
@Override
public void update() {
super.update();
if (!getWorld().isRemote && isWorkingEnabled() && autoPull && getOffsetTimer() % 100 == 0) {
refreshList();
syncME();
if (!getWorld().isRemote) {
if (isWorkingEnabled() && autoPull && getOffsetTimer() % 100 == 0) {
refreshList();
syncME();
}

// Immediately clear cached fluids if the status changed, to prevent running recipes while offline
if (this.meStatusChanged && !this.isOnline) {
if (autoPull) {
this.getAEFluidHandler().clearConfig();
} else {
for (int i = 0; i < CONFIG_SIZE; i++) {
getAEFluidHandler().getInventory()[i].setStack(null);
}
}
}
}
}

Expand Down

0 comments on commit 7141fcf

Please sign in to comment.