Search in sources :

Example 16 with LogisticsModule

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

the class GuiChassisPipe method actionPerformed.

@Override
protected void actionPerformed(GuiButton guibutton) {
    if (guibutton.id >= 0 && guibutton.id <= _chassiPipe.getChassisSize()) {
        LogisticsModule module = _chassiPipe.getSubModule(guibutton.id);
        if (module != null) {
            final ModernPacket packet = PacketHandler.getPacket(ChassisGUI.class).setButtonID(guibutton.id).setPosX(_chassiPipe.getX()).setPosY(_chassiPipe.getY()).setPosZ(_chassiPipe.getZ());
            MainProxy.sendPacketToServer(packet);
        }
    }
    for (int i = 0; i < upgradeConfig.length; i++) {
        if (upgradeConfig[i] == guibutton) {
            MainProxy.sendPacketToServer(PacketHandler.getPacket(OpenUpgradePacket.class).setSlot(upgradeslot[i]));
        }
    }
}
Also used : ModernPacket(logisticspipes.network.abstractpackets.ModernPacket) LogisticsModule(logisticspipes.modules.LogisticsModule)

Example 17 with LogisticsModule

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

the class SneakyModuleInSlotGuiProvider method getClientGui.

@Override
public Object getClientGui(EntityPlayer player) {
    LogisticsModule module = this.getLogisticsModule(player.getEntityWorld(), LogisticsModule.class);
    if (!(module instanceof SneakyDirection && module instanceof Gui)) {
        return null;
    }
    ((SneakyDirection) module).setSneakyDirection(sneakyOrientation);
    return new GuiSneakyConfigurator(player.inventory, module);
}
Also used : LogisticsModule(logisticspipes.modules.LogisticsModule) GuiSneakyConfigurator(logisticspipes.gui.modules.GuiSneakyConfigurator) SneakyDirection(network.rs485.logisticspipes.module.SneakyDirection) Gui(network.rs485.logisticspipes.module.Gui)

Example 18 with LogisticsModule

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

the class ModuleCoordinatesGuiProvider method getLogisticsModule.

@SuppressWarnings("unchecked")
public <T> T getLogisticsModule(World world, Class<T> clazz) {
    LogisticsTileGenericPipe pipe = getTileAs(world, LogisticsTileGenericPipe.class);
    if (!(pipe.pipe instanceof CoreRoutedPipe)) {
        if (LogisticsPipes.isDEBUG() && pipe.isInitialized()) {
            LogisticsPipes.log.fatal(toString());
            new RuntimeException("Couldn't find " + clazz.getName() + ", pipe didn't exsist").printStackTrace();
        }
        return null;
    }
    LogisticsModule module;
    if (slot == ModulePositionType.IN_PIPE) {
        module = ((CoreRoutedPipe) pipe.pipe).getLogisticsModule();
    } else if (slot == ModulePositionType.IN_HAND) {
        throw new UnsupportedOperationException("NO IN_HAND FOR THIS PACKET TYPE");
    } else {
        if (!(pipe.pipe instanceof PipeLogisticsChassis)) {
            if (LogisticsPipes.isDEBUG()) {
                LogisticsPipes.log.fatal(toString());
                new RuntimeException("Couldn't find " + clazz.getName() + ", pipe wasn't a chassi pipe").printStackTrace();
            }
            return null;
        }
        module = ((PipeLogisticsChassis) pipe.pipe).getSubModule(positionInt);
    }
    if (module != null) {
        if (!(clazz.isAssignableFrom(module.getClass()))) {
            if (LogisticsPipes.isDEBUG()) {
                LogisticsPipes.log.fatal(toString());
                new RuntimeException("Couldn't find " + clazz.getName() + ", found " + module.getClass()).printStackTrace();
            }
            return null;
        }
    } else {
        if (LogisticsPipes.isDEBUG()) {
            LogisticsPipes.log.fatal(toString());
            new RuntimeException("Couldn't find " + clazz.getName()).printStackTrace();
        }
    }
    return (T) module;
}
Also used : LogisticsModule(logisticspipes.modules.LogisticsModule) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) PipeLogisticsChassis(logisticspipes.pipes.PipeLogisticsChassis) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe)

Example 19 with LogisticsModule

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

the class ModuleCoordinatesPacket method getLogisticsModule.

@SuppressWarnings("unchecked")
public <T> T getLogisticsModule(EntityPlayer player, Class<T> clazz) {
    LogisticsModule module;
    if (type == ModulePositionType.IN_PIPE) {
        moduleBased = true;
        LogisticsTileGenericPipe pipe = this.getPipe(player.getEntityWorld(), LTGPCompletionCheck.NONE);
        moduleBased = false;
        if (!(pipe.pipe instanceof CoreRoutedPipe)) {
            throw new TargetNotFoundException("Couldn't find " + clazz.getName() + ", pipe didn't exsist", this);
        }
        module = ((CoreRoutedPipe) pipe.pipe).getLogisticsModule();
    } else if (type == ModulePositionType.IN_HAND) {
        if (MainProxy.isServer(player.getEntityWorld())) {
            if (player.openContainer instanceof DummyModuleContainer) {
                DummyModuleContainer dummy = (DummyModuleContainer) player.openContainer;
                module = dummy.getModule();
            } else if (player.openContainer instanceof ContainerPlayer) {
                module = ItemModule.getLogisticsModule(player, getPositionInt());
                if (module == null) {
                    throw new TargetNotFoundException("Couldn't find " + clazz.getName() + ", module not found at slot " + getPositionInt(), this);
                }
            } else {
                throw new TargetNotFoundException("Couldn't find " + clazz.getName() + ", no DummyModuleContainer open and the player is in another GUI", this);
            }
        } else {
            module = MainProxy.proxy.getModuleFromGui();
            if (module == null) {
                module = ItemModule.getLogisticsModule(player, getPositionInt());
            }
            if (module == null) {
                throw new TargetNotFoundException("Couldn't find " + clazz.getName() + ", GUI didn't provide the module and module not found at slot " + getPositionInt(), this);
            }
        }
    } else {
        moduleBased = true;
        LogisticsTileGenericPipe pipe = this.getPipe(player.getEntityWorld(), LTGPCompletionCheck.NONE);
        moduleBased = false;
        if (!(pipe.pipe instanceof CoreRoutedPipe)) {
            throw new TargetNotFoundException("Couldn't find " + clazz.getName() + ", pipe didn't exsist", this);
        } else if (!pipe.isInitialized()) {
            return null;
        }
        if (!(pipe.pipe instanceof PipeLogisticsChassis)) {
            throw new TargetNotFoundException("Couldn't find " + clazz.getName() + ", pipe wasn't a chassi pipe", this);
        }
        module = ((PipeLogisticsChassis) pipe.pipe).getSubModule(positionInt);
    }
    if (module != null) {
        if (!(clazz.isAssignableFrom(module.getClass()))) {
            throw new TargetNotFoundException("Couldn't find " + clazz.getName() + ", found " + module.getClass(), this);
        }
    } else {
        throw new TargetNotFoundException("Couldn't find " + clazz.getName(), this);
    }
    return (T) module;
}
Also used : ContainerPlayer(net.minecraft.inventory.ContainerPlayer) DummyModuleContainer(logisticspipes.utils.gui.DummyModuleContainer) LogisticsModule(logisticspipes.modules.LogisticsModule) TargetNotFoundException(logisticspipes.network.exception.TargetNotFoundException) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) PipeLogisticsChassis(logisticspipes.pipes.PipeLogisticsChassis) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe)

Example 20 with LogisticsModule

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

the class ChassisTransportLayer method stillWantItem.

@Override
public boolean stillWantItem(IRoutedItem item) {
    LogisticsModule module = _chassiPipe.getLogisticsModule();
    if (module == null) {
        _chassiPipe.notifyOfItemArival(item.getInfo());
        return false;
    }
    if (!_chassiPipe.isEnabled()) {
        _chassiPipe.notifyOfItemArival(item.getInfo());
        return false;
    }
    final ItemIdentifierStack itemidStack = item.getItemIdentifierStack();
    SinkReply reply = module.sinksItem(itemidStack.makeNormalStack(), itemidStack.getItem(), -1, 0, true, false, false);
    if (reply == null || reply.maxNumberOfItems < 0) {
        _chassiPipe.notifyOfItemArival(item.getInfo());
        return false;
    }
    if (reply.maxNumberOfItems > 0 && itemidStack.getStackSize() > reply.maxNumberOfItems) {
        EnumFacing o = _chassiPipe.getPointedOrientation();
        if (o == null) {
            o = EnumFacing.UP;
        }
        item.split(reply.maxNumberOfItems, o);
    }
    return true;
}
Also used : SinkReply(logisticspipes.utils.SinkReply) LogisticsModule(logisticspipes.modules.LogisticsModule) EnumFacing(net.minecraft.util.EnumFacing) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack)

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