Search in sources :

Example 6 with LogisticsModule

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

the class PipeLogisticsChassi method itemArrived.

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

Example 7 with LogisticsModule

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

the class PipeLogisticsChassi method onAllowedRemoval.

@Override
public void onAllowedRemoval() {
    _moduleInventory.removeListener(this);
    if (MainProxy.isServer(getWorld())) {
        for (int i = 0; i < getChassiSize(); i++) {
            LogisticsModule x = _module.getSubModule(i);
            if (x instanceof ILegacyActiveModule) {
                ILegacyActiveModule y = (ILegacyActiveModule) x;
                y.onBlockRemoval();
            }
        }
        for (int i = 0; i < _moduleInventory.getSizeInventory(); i++) {
            ItemIdentifierStack ms = _moduleInventory.getIDStackInSlot(i);
            if (ms != null) {
                ItemStack s = ms.makeNormalStack();
                ItemModuleInformationManager.saveInfotmation(s, getLogisticsModule().getSubModule(i));
                _moduleInventory.setInventorySlotContents(i, s);
            }
        }
        _moduleInventory.dropContents(getWorld(), getX(), getY(), getZ());
    }
}
Also used : ILegacyActiveModule(logisticspipes.interfaces.ILegacyActiveModule) LogisticsModule(logisticspipes.modules.abstractmodules.LogisticsModule) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) ItemStack(net.minecraft.item.ItemStack)

Example 8 with LogisticsModule

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

the class PipeLogisticsChassi 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 < getChassiSize(); i++) {
        LogisticsModule x = _module.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.abstractmodules.LogisticsModule)

Example 9 with LogisticsModule

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

the class PipeLogisticsChassi method getAllItems.

@Override
public void getAllItems(Map<ItemIdentifier, Integer> list, List<IFilter> filter) {
    if (!isEnabled()) {
        return;
    }
    for (int i = 0; i < getChassiSize(); i++) {
        LogisticsModule x = _module.getSubModule(i);
        if (x instanceof ILegacyActiveModule) {
            ILegacyActiveModule y = (ILegacyActiveModule) x;
            y.getAllItems(list, filter);
        }
    }
}
Also used : ILegacyActiveModule(logisticspipes.interfaces.ILegacyActiveModule) LogisticsModule(logisticspipes.modules.abstractmodules.LogisticsModule)

Example 10 with LogisticsModule

use of logisticspipes.modules.abstractmodules.LogisticsModule 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

LogisticsModule (logisticspipes.modules.abstractmodules.LogisticsModule)16 ILegacyActiveModule (logisticspipes.interfaces.ILegacyActiveModule)4 ItemStack (net.minecraft.item.ItemStack)4 SinkReply (logisticspipes.utils.SinkReply)3 IInventoryUtil (logisticspipes.interfaces.IInventoryUtil)2 IRequireReliableTransport (logisticspipes.interfaces.routing.IRequireReliableTransport)2 TreeSet (java.util.TreeSet)1 GuiChassiPipe (logisticspipes.gui.GuiChassiPipe)1 IBufferItems (logisticspipes.interfaces.IBufferItems)1 IFilter (logisticspipes.interfaces.routing.IFilter)1 ItemModule (logisticspipes.items.ItemModule)1 LogisticsGuiModule (logisticspipes.modules.abstractmodules.LogisticsGuiModule)1 ModernPacket (logisticspipes.network.abstractpackets.ModernPacket)1 ChassiePipeModuleContent (logisticspipes.network.packets.pipe.ChassiePipeModuleContent)1 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)1 LogisticsOrder (logisticspipes.routing.order.LogisticsOrder)1 DummyWorldProvider (logisticspipes.utils.DummyWorldProvider)1 ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)1 ItemIdentifierStack (logisticspipes.utils.item.ItemIdentifierStack)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1