Fixed drawer controllers not being aware of void drawer slot changes, closes #73

This commit is contained in:
Buuz135 2022-08-19 19:23:22 +02:00
parent 765631ea99
commit 2686143de3
2 changed files with 9 additions and 3 deletions

View File

@ -99,7 +99,13 @@ public abstract class ControllableDrawerTile<T extends ControllableDrawerTile<T>
} }
this.addInventory((InventoryComponent<T>) (this.utilityUpgrades = new InventoryComponent<ControllableDrawerTile<T>>("utility_upgrades", 114, 70, 3) this.addInventory((InventoryComponent<T>) (this.utilityUpgrades = new InventoryComponent<ControllableDrawerTile<T>>("utility_upgrades", 114, 70, 3)
.setInputFilter((stack, integer) -> stack.getItem() instanceof UpgradeItem && ((UpgradeItem) stack.getItem()).getType() == UpgradeItem.Type.UTILITY) .setInputFilter((stack, integer) -> stack.getItem() instanceof UpgradeItem && ((UpgradeItem) stack.getItem()).getType() == UpgradeItem.Type.UTILITY)
.setSlotLimit(1)) .setSlotLimit(1)
.setOnSlotChanged((itemStack, integer) -> {
if (controllerPos != null && this.level.getBlockEntity(controllerPos) instanceof DrawerControllerTile controllerTile) {
controllerTile.getConnectedDrawers().rebuild();
}
})
)
); );
} }

View File

@ -214,7 +214,7 @@ public class DrawerControllerTile extends ControllableDrawerTile<DrawerControlle
this.level = level; this.level = level;
} }
private void rebuild() { public void rebuild() {
this.handlers = new ArrayList<>(); this.handlers = new ArrayList<>();
if (level != null && !level.isClientSide()) { if (level != null && !level.isClientSide()) {
for (Long connectedDrawer : this.connectedDrawers) { for (Long connectedDrawer : this.connectedDrawers) {