Fixed not being able to change the Exporter filter slot count with regulator mode without closing and re-opening the container.

This commit is contained in:
raoulvdberge
2020-11-11 20:06:05 +01:00
parent e87184d2c8
commit 8e8c1ab04f
2 changed files with 19 additions and 0 deletions

View File

@@ -11,15 +11,33 @@ import net.minecraftforge.items.SlotItemHandler;
public class ExporterContainer extends BaseContainer {
private final ExporterTile exporter;
private boolean hasRegulatorMode;
public ExporterContainer(ExporterTile exporter, PlayerEntity player, int windowId) {
super(RSContainers.EXPORTER, exporter, player, windowId);
this.exporter = exporter;
this.hasRegulatorMode = hasRegulatorMode();
initSlots();
}
private boolean hasRegulatorMode() {
return exporter.getNode().getUpgrades().hasUpgrade(UpgradeItem.Type.REGULATOR);
}
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
boolean updatedHasRegulatorMode = hasRegulatorMode();
if (hasRegulatorMode != updatedHasRegulatorMode) {
hasRegulatorMode = updatedHasRegulatorMode;
initSlots();
}
}
public void initSlots() {
this.inventorySlots.clear();
this.inventoryItemStacks.clear();