Search in sources :

Example 1 with LogisticsModule

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

the class LogisticsManager method canSink.

public static SinkReply canSink(@Nonnull ItemStack stack, @Nonnull IRouter destination, IRouter sourceRouter, boolean excludeSource, ItemIdentifier item, SinkReply result, boolean activeRequest, boolean allowDefault, boolean forcePassive) {
    SinkReply reply;
    LogisticsModule module = destination.getLogisticsModule();
    CoreRoutedPipe crp = destination.getPipe();
    if (module == null) {
        return null;
    }
    if (!(module.recievePassive() || activeRequest)) {
        return null;
    }
    if (crp == null || !crp.isEnabled()) {
        return null;
    }
    if (excludeSource && sourceRouter != null) {
        if (destination.getPipe().isOnSameContainer(sourceRouter.getPipe())) {
            return null;
        }
    }
    if (result == null) {
        reply = module.sinksItem(stack, item, -1, 0, allowDefault, true, forcePassive);
    } else {
        reply = module.sinksItem(stack, item, result.fixedPriority.ordinal(), result.customPriority, allowDefault, true, forcePassive);
    }
    if (result != null && result.maxNumberOfItems < 0) {
        return null;
    }
    return reply;
}
Also used : SinkReply(logisticspipes.utils.SinkReply) FluidSinkReply(logisticspipes.utils.FluidSinkReply) LogisticsModule(logisticspipes.modules.LogisticsModule) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe)

Example 2 with LogisticsModule

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

the class ItemModule method getLogisticsModule.

@Nullable
public static LogisticsModule getLogisticsModule(@Nonnull EntityPlayer player, int invSlot) {
    ItemStack item = player.inventory.mainInventory.get(invSlot);
    if (item.isEmpty() || !(item.getItem() instanceof ItemModule))
        return null;
    LogisticsModule module = ((ItemModule) item.getItem()).getModuleForItem(item, null, new DummyWorldProvider(player.getEntityWorld()), null);
    if (module == null)
        return null;
    module.registerPosition(ModulePositionType.IN_HAND, invSlot);
    ItemModuleInformationManager.readInformation(item, module);
    return module;
}
Also used : DummyWorldProvider(logisticspipes.utils.DummyWorldProvider) LogisticsModule(logisticspipes.modules.LogisticsModule) ItemStack(net.minecraft.item.ItemStack) Nullable(javax.annotation.Nullable)

Example 3 with LogisticsModule

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

the class ItemModule method getModule.

@Nullable
public LogisticsModule getModule(@Nullable LogisticsModule currentModule, @Nullable IWorldProvider world, @Nullable IPipeServiceProvider service) {
    if (currentModule != null) {
        if (moduleType.getILogisticsModuleClass().equals(currentModule.getClass())) {
            return currentModule;
        }
    }
    LogisticsModule newmodule = moduleType.getILogisticsModule();
    if (newmodule == null) {
        return null;
    }
    newmodule.registerHandler(world, service);
    return newmodule;
}
Also used : LogisticsModule(logisticspipes.modules.LogisticsModule) Nullable(javax.annotation.Nullable)

Example 4 with LogisticsModule

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

the class ItemModule method openConfigGui.

private void openConfigGui(@Nonnull ItemStack stack, EntityPlayer player, World world) {
    LogisticsModule module = getModuleForItem(stack, null, new DummyWorldProvider(world), null);
    if (module instanceof Gui && !stack.isEmpty()) {
        module.registerPosition(ModulePositionType.IN_HAND, player.inventory.currentItem);
        ItemModuleInformationManager.readInformation(stack, module);
        Gui.getInHandGuiProvider((Gui) module).open(player);
    }
}
Also used : DummyWorldProvider(logisticspipes.utils.DummyWorldProvider) LogisticsModule(logisticspipes.modules.LogisticsModule) Gui(network.rs485.logisticspipes.module.Gui)

Example 5 with LogisticsModule

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

the class HudChassisPipe method renderHeadUpDisplay.

@Override
public void renderHeadUpDisplay(double distance, boolean day, boolean shifted, Minecraft mc, IHUDConfig config) {
    if (day) {
        GL11.glColor4b((byte) 64, (byte) 64, (byte) 64, (byte) 64);
    } else {
        GL11.glColor4b((byte) 127, (byte) 127, (byte) 127, (byte) 64);
    }
    GuiGraphics.drawGuiBackGround(mc, -50, -50, 50, 50, 0, false);
    if (day) {
        GL11.glColor4b((byte) 64, (byte) 64, (byte) 64, (byte) 127);
    } else {
        GL11.glColor4b((byte) 127, (byte) 127, (byte) 127, (byte) 127);
    }
    GL11.glTranslatef(0.0F, 0.0F, (float) (-0.00005F * distance));
    super.renderHeadUpDisplay(distance, day, shifted, mc, config);
    if (selected != -1) {
        LogisticsModule selectedmodule = pipe.getSubModule(selected);
        if (selectedmodule == null) {
            return;
        }
        GL11.glColor4b((byte) 127, (byte) 127, (byte) 127, (byte) 64);
        GuiGraphics.drawGuiBackGround(mc, -23, -35, 45, 45, 0, false);
        GL11.glColor4b((byte) 127, (byte) 127, (byte) 127, (byte) 127);
        if (selectedmodule instanceof IHUDModuleHandler && ((IHUDModuleHandler) selectedmodule).getHUDRenderer() != null) {
            GL11.glTranslatef(11.0F, 5.0F, (float) (-0.00005F * distance));
            ((IHUDModuleHandler) selectedmodule).getHUDRenderer().renderContent(shifted);
            if (((IHUDModuleHandler) selectedmodule).getHUDRenderer().getButtons() != null) {
                for (IHUDButton button : ((IHUDModuleHandler) selectedmodule).getHUDRenderer().getButtons()) {
                    button.renderAlways(shifted);
                    if (button.shouldRenderButton()) {
                        button.renderButton(button.isFocused(), button.isblockFocused(), shifted);
                    }
                    if (!button.buttonEnabled() || !button.shouldRenderButton()) {
                        continue;
                    }
                    if ((button.getX() - 1 < (xCursor - 11) && (xCursor - 11) < (button.getX() + button.sizeX() + 1)) && (button.getY() - 1 < (yCursor - 5) && (yCursor - 5) < (button.getY() + button.sizeY() + 1))) {
                        if (!button.isFocused() && !button.isblockFocused()) {
                            button.setFocused();
                        } else if (button.focusedTime() > 400 && !button.isblockFocused()) {
                            button.clicked();
                            button.blockFocused();
                        }
                    } else if (button.isFocused() || button.isblockFocused()) {
                        button.clearFocused();
                    }
                }
            }
            GL11.glTranslatef(-11.0F, -5.0F, (float) (0.00005F * distance));
        } else {
            GL11.glTranslatef(0.0F, 0.0F, (float) (-0.00005F * distance));
            mc.fontRenderer.drawString("Nothing", -5, -15, 0);
            mc.fontRenderer.drawString("to", 9, -5, 0);
            mc.fontRenderer.drawString("display", -5, 5, 0);
            GL11.glTranslatef(0.0F, 0.0F, (float) (0.00005F * distance));
        }
    } else {
        GL11.glTranslatef(0.0F, 0.0F, (float) (-0.005F * distance));
        GL11.glScalef(1.5F, 1.5F, 0.0001F);
        GL11.glScalef(0.8F, 0.8F, -1F);
        ItemStackRenderer.renderItemIdentifierStackListIntoGui(pipe.displayList, null, 0, -15, -35, 3, 12, 18, 18, 100.0F, DisplayAmount.ALWAYS, false, shifted);
    }
    GL11.glTranslatef(0.0F, 0.0F, (float) (0.00005F * distance));
}
Also used : IHUDButton(logisticspipes.interfaces.IHUDButton) LogisticsModule(logisticspipes.modules.LogisticsModule) IHUDModuleHandler(logisticspipes.interfaces.IHUDModuleHandler)

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