use of logisticspipes.gui.GuiChassisPipe in project LogisticsPipes by RS485.
the class PipeLogisticsChassis method InventoryChanged.
@Override
public void InventoryChanged(IInventory inventory) {
boolean reInitGui = false;
for (int i = 0; i < inventory.getSizeInventory(); i++) {
ItemStack stack = inventory.getStackInSlot(i);
if (stack.isEmpty()) {
if (_module.hasModule(i)) {
_module.removeModule(i);
reInitGui = true;
}
continue;
}
if (stack.getItem() instanceof ItemModule) {
LogisticsModule current = _module.getModule(i);
LogisticsModule next = ((ItemModule) stack.getItem()).getModuleForItem(stack, _module.getModule(i), this, this);
Objects.requireNonNull(next, "getModuleForItem returned null for " + stack.toString());
next.registerPosition(ModulePositionType.SLOT, i);
next.registerCCEventQueuer(this);
if (current != next) {
_module.installModule(i, next);
if (!MainProxy.isClient(getWorld())) {
ItemModuleInformationManager.readInformation(stack, next);
}
}
inventory.setInventorySlotContents(i, stack);
}
}
if (reInitGui) {
if (MainProxy.isClient(getWorld())) {
if (FMLClientHandler.instance().getClient().currentScreen instanceof GuiChassisPipe) {
FMLClientHandler.instance().getClient().currentScreen.initGui();
}
}
}
if (MainProxy.isServer(getWorld())) {
if (!localModeWatchers.isEmpty()) {
MainProxy.sendToPlayerList(PacketHandler.getPacket(ChassisPipeModuleContent.class).setIdentList(ItemIdentifierStack.getListFromInventory(_moduleInventory)).setPosX(getX()).setPosY(getY()).setPosZ(getZ()), localModeWatchers);
}
}
}
Aggregations