use of logisticspipes.gui.GuiChassiPipe in project LogisticsPipes by RS485.
the class PipeLogisticsChassi 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 == null) {
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);
next.registerPosition(ModulePositionType.SLOT, i);
next.registerCCEventQueuer(this);
if (current != next) {
_module.installModule(i, next);
if (!MainProxy.isClient()) {
ItemModuleInformationManager.readInformation(stack, next);
}
ItemModuleInformationManager.removeInformation(stack);
}
inventory.setInventorySlotContents(i, stack);
}
}
if (reInitGui) {
if (MainProxy.isClient(getWorld())) {
if (FMLClientHandler.instance().getClient().currentScreen instanceof GuiChassiPipe) {
FMLClientHandler.instance().getClient().currentScreen.initGui();
}
}
}
if (MainProxy.isServer()) {
if (!localModeWatchers.isEmpty()) {
MainProxy.sendToPlayerList(PacketHandler.getPacket(ChassiePipeModuleContent.class).setIdentList(ItemIdentifierStack.getListFromInventory(_moduleInventory)).setPosX(getX()).setPosY(getY()).setPosZ(getZ()), localModeWatchers);
}
}
}
Aggregations