Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Stocking Buses running recipes while offline #2608

Merged
merged 3 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this use getAEItemHandler().clearConfig()? If so maybe this and other occurrences of clearInventory(0) should move to it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They do basically the same thing, so I don't see a particular reason to switch.

} 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