Search in sources :

Example 1 with GuiChassiPipe

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);
        }
    }
}
Also used : GuiChassiPipe(logisticspipes.gui.GuiChassiPipe) LogisticsModule(logisticspipes.modules.abstractmodules.LogisticsModule) ItemStack(net.minecraft.item.ItemStack) ItemModule(logisticspipes.items.ItemModule) ChassiePipeModuleContent(logisticspipes.network.packets.pipe.ChassiePipeModuleContent)

Aggregations

GuiChassiPipe (logisticspipes.gui.GuiChassiPipe)1 ItemModule (logisticspipes.items.ItemModule)1 LogisticsModule (logisticspipes.modules.abstractmodules.LogisticsModule)1 ChassiePipeModuleContent (logisticspipes.network.packets.pipe.ChassiePipeModuleContent)1 ItemStack (net.minecraft.item.ItemStack)1