Search in sources :

Example 11 with LogisticsModule

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

the class PipeLogisticsChassis method getAllItems.

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

Example 12 with LogisticsModule

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

the class PipeLogisticsChassis method itemLost.

@Override
public void itemLost(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).itemLost(item, info);
            }
        } else {
            if (LogisticsPipes.isDEBUG()) {
                System.out.println(item);
                new RuntimeException("[ItemLost] Information weren't ment for a chassi pipe").printStackTrace();
            }
        }
    }
}
Also used : LogisticsModule(logisticspipes.modules.LogisticsModule) IRequireReliableTransport(logisticspipes.interfaces.routing.IRequireReliableTransport)

Example 13 with LogisticsModule

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

the class PipeLogisticsChassis method fullFill.

@Override
public LogisticsOrder fullFill(LogisticsPromise promise, IRequestItems destination, IAdditionalTargetInformation info) {
    if (!isEnabled()) {
        return null;
    }
    for (int i = 0; i < getChassisSize(); i++) {
        LogisticsModule x = getSubModule(i);
        if (x instanceof ILegacyActiveModule) {
            ILegacyActiveModule y = (ILegacyActiveModule) x;
            LogisticsOrder result = y.fullFill(promise, destination, info);
            if (result != null) {
                spawnParticle(Particles.WhiteParticle, 2);
                return result;
            }
        }
    }
    return null;
}
Also used : ILegacyActiveModule(logisticspipes.interfaces.ILegacyActiveModule) LogisticsOrder(logisticspipes.routing.order.LogisticsOrder) LogisticsModule(logisticspipes.modules.LogisticsModule)

Example 14 with LogisticsModule

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

the class AdvancedExtractorSneakyGuiPacket method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    if (getType() == ModulePositionType.IN_HAND) {
        if (player.openContainer instanceof DummyModuleContainer) {
            DummyModuleContainer dummy = (DummyModuleContainer) player.openContainer;
            if (dummy.getModule() instanceof AsyncAdvancedExtractor) {
                player.closeScreen();
                NewGuiHandler.getGui(SneakyModuleInHandGuiProvider.class).setInvSlot(getPositionInt()).open(player);
            }
        }
        return;
    }
    PipeLogisticsChassis pipe = getTileOrPipe(player.world, PipeLogisticsChassis.class);
    LogisticsModule subModule = pipe.getSubModule(getPositionInt());
    if (subModule instanceof AsyncAdvancedExtractor) {
        NewGuiHandler.getGui(SneakyModuleInSlotGuiProvider.class).setSneakyOrientation(((AsyncAdvancedExtractor) subModule).getSneakyDirection()).setSlot(getType()).setPositionInt(getPositionInt()).setPosX(getPosX()).setPosY(getPosY()).setPosZ(getPosZ()).open(player);
    }
}
Also used : DummyModuleContainer(logisticspipes.utils.gui.DummyModuleContainer) LogisticsModule(logisticspipes.modules.LogisticsModule) PipeLogisticsChassis(logisticspipes.pipes.PipeLogisticsChassis) AsyncAdvancedExtractor(network.rs485.logisticspipes.module.AsyncAdvancedExtractor) SneakyModuleInSlotGuiProvider(logisticspipes.network.guis.module.inpipe.SneakyModuleInSlotGuiProvider)

Example 15 with LogisticsModule

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

the class ModulePropertiesUpdate method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    final LogisticsModule module = this.getLogisticsModule(player, LogisticsModule.class);
    if (module == null) {
        return;
    }
    // sync updated properties
    module.readFromNBT(tag);
    if (!getType().isInWorld() && player.openContainer instanceof ContainerPlayer) {
        // FIXME: saveInformation & markDirty on module property change? should be called only once
        // sync slot in player inventory and mark player inventory dirty
        ItemModuleInformationManager.saveInformation(player.inventory.mainInventory.get(getPositionInt()), module);
        player.inventory.markDirty();
    }
    MainProxy.runOnServer(player.world, () -> () -> {
        // resync client; always
        MainProxy.sendPacketToPlayer(fromPropertyHolder(module).setModulePos(module), player);
    });
}
Also used : ContainerPlayer(net.minecraft.inventory.ContainerPlayer) LogisticsModule(logisticspipes.modules.LogisticsModule)

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