Search in sources :

Example 6 with LogisticsModule

use of logisticspipes.modules.LogisticsModule in project LogisticsPipes by RS485.

the class GuiChassisPipe method updateModuleConfigButtonVisibility.

private void updateModuleConfigButtonVisibility(int slot) {
    ItemStack module = _moduleInventory.getStackInSlot(slot);
    LogisticsModule subModule = _chassiPipe.getSubModule(slot);
    if (module.isEmpty() || subModule == null) {
        moduleConfigButtons.get(slot).visible = false;
    } else {
        moduleConfigButtons.get(slot).visible = subModule instanceof Gui;
    }
}
Also used : LogisticsModule(logisticspipes.modules.LogisticsModule) Gui(network.rs485.logisticspipes.module.Gui) ItemStack(net.minecraft.item.ItemStack)

Example 7 with LogisticsModule

use of logisticspipes.modules.LogisticsModule in project LogisticsPipes by RS485.

the class StringBasedItemSinkModuleGuiSlot method getClientGui.

@Override
public Object getClientGui(EntityPlayer player) {
    LogisticsModule module = this.getLogisticsModule(player.getEntityWorld(), LogisticsModule.class);
    if (!(module instanceof IStringBasedModule)) {
        return null;
    }
    module.readFromNBT(getNbt());
    return new GuiStringBasedItemSink(player.inventory, module);
}
Also used : IStringBasedModule(logisticspipes.interfaces.IStringBasedModule) LogisticsModule(logisticspipes.modules.LogisticsModule) GuiStringBasedItemSink(logisticspipes.gui.modules.GuiStringBasedItemSink)

Example 8 with LogisticsModule

use of logisticspipes.modules.LogisticsModule in project LogisticsPipes by RS485.

the class PipeLogisticsChassis method canProvide.

/**
 * IProvideItems **
 */
@Override
public void canProvide(RequestTreeNode tree, RequestTree root, List<IFilter> filters) {
    if (!isEnabled()) {
        return;
    }
    for (IFilter filter : filters) {
        if (filter.isBlocked() == filter.isFilteredItem(tree.getRequestType()) || filter.blockProvider()) {
            return;
        }
    }
    for (int i = 0; i < getChassisSize(); i++) {
        LogisticsModule x = getSubModule(i);
        if (x instanceof ILegacyActiveModule) {
            ILegacyActiveModule y = (ILegacyActiveModule) x;
            y.canProvide(tree, root, filters);
        }
    }
}
Also used : ILegacyActiveModule(logisticspipes.interfaces.ILegacyActiveModule) IFilter(logisticspipes.interfaces.routing.IFilter) LogisticsModule(logisticspipes.modules.LogisticsModule)

Example 9 with LogisticsModule

use of logisticspipes.modules.LogisticsModule in project LogisticsPipes by RS485.

the class PipeLogisticsChassis method itemArrived.

@Override
public void itemArrived(ItemIdentifierStack item, IAdditionalTargetInformation info) {
    if (MainProxy.isServer(getWorld())) {
        if (info instanceof ChassiTargetInformation) {
            ChassiTargetInformation target = (ChassiTargetInformation) info;
            LogisticsModule module = getSubModule(target.moduleSlot);
            if (module instanceof IRequireReliableTransport) {
                ((IRequireReliableTransport) module).itemArrived(item, info);
            }
        } else {
            if (LogisticsPipes.isDEBUG() && info != null) {
                System.out.println(item);
                new RuntimeException("[ItemArrived] Information weren't ment for a chassi pipe").printStackTrace();
            }
        }
    }
}
Also used : LogisticsModule(logisticspipes.modules.LogisticsModule) IRequireReliableTransport(logisticspipes.interfaces.routing.IRequireReliableTransport)

Example 10 with LogisticsModule

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

Aggregations

LogisticsModule (logisticspipes.modules.LogisticsModule)24 ItemStack (net.minecraft.item.ItemStack)5 ILegacyActiveModule (logisticspipes.interfaces.ILegacyActiveModule)4 PipeLogisticsChassis (logisticspipes.pipes.PipeLogisticsChassis)3 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)3 Gui (network.rs485.logisticspipes.module.Gui)3 Nullable (javax.annotation.Nullable)2 IRequireReliableTransport (logisticspipes.interfaces.routing.IRequireReliableTransport)2 ItemModule (logisticspipes.items.ItemModule)2 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)2 DummyWorldProvider (logisticspipes.utils.DummyWorldProvider)2 SinkReply (logisticspipes.utils.SinkReply)2 DummyModuleContainer (logisticspipes.utils.gui.DummyModuleContainer)2 ItemIdentifierStack (logisticspipes.utils.item.ItemIdentifierStack)2 ContainerPlayer (net.minecraft.inventory.ContainerPlayer)2 GuiChassisPipe (logisticspipes.gui.GuiChassisPipe)1 GuiSneakyConfigurator (logisticspipes.gui.modules.GuiSneakyConfigurator)1 GuiStringBasedItemSink (logisticspipes.gui.modules.GuiStringBasedItemSink)1 IBufferItems (logisticspipes.interfaces.IBufferItems)1 IHUDButton (logisticspipes.interfaces.IHUDButton)1