Search in sources :

Example 1 with PipeItemsSystemDestinationLogistics

use of logisticspipes.pipes.PipeItemsSystemDestinationLogistics in project LogisticsPipes by RS485.

the class GuiHandler method getClientGuiElement.

@Override
public Object getClientGuiElement(int ID, EntityPlayer player, final World world, int x, int y, int z) {
    TileEntity tile = world.getTileEntity(x, y, z);
    LogisticsTileGenericPipe pipe = null;
    if (tile instanceof LogisticsTileGenericPipe) {
        pipe = (LogisticsTileGenericPipe) tile;
    }
    if (ID == -1) {
        return getClientGuiElement(-100 * 20 + x, player, world, 0, -1, z);
    }
    if (ID < 110 && ID > 0) {
        switch(ID) {
            case GuiIDs.GUI_FluidSupplier_ID:
                if (pipe == null || pipe.pipe == null || !(pipe.pipe instanceof PipeItemsFluidSupplier)) {
                    return null;
                }
                return new GuiFluidSupplierPipe(player.inventory, ((PipeItemsFluidSupplier) pipe.pipe).getDummyInventory(), (PipeItemsFluidSupplier) pipe.pipe);
            case GuiIDs.GUI_FluidSupplier_MK2_ID:
                if (pipe == null || pipe.pipe == null || !(pipe.pipe instanceof PipeFluidSupplierMk2)) {
                    return null;
                }
                return new GuiFluidSupplierMk2Pipe(player.inventory, ((PipeFluidSupplierMk2) pipe.pipe).getDummyInventory(), (PipeFluidSupplierMk2) pipe.pipe);
            case GuiIDs.GUI_ProviderPipe_ID:
                if (pipe == null || pipe.pipe == null || !(pipe.pipe instanceof PipeItemsProviderLogistics)) {
                    return null;
                }
                return new GuiProviderPipe(player.inventory, ((PipeItemsProviderLogistics) pipe.pipe).getprovidingInventory(), (PipeItemsProviderLogistics) pipe.pipe);
            case GuiIDs.GUI_SatellitePipe_ID:
                if (pipe != null && pipe.pipe != null && pipe.pipe instanceof PipeItemsSatelliteLogistics) {
                    return new GuiSatellitePipe((PipeItemsSatelliteLogistics) pipe.pipe, player);
                }
                if (pipe != null && pipe.pipe != null && pipe.pipe instanceof PipeFluidSatellite) {
                    return new GuiSatellitePipe((PipeFluidSatellite) pipe.pipe, player);
                }
                return null;
            case GuiIDs.GUI_Normal_Orderer_ID:
                return new NormalGuiOrderer(x, y, z, MainProxy.getDimensionForWorld(world), player);
            case GuiIDs.GUI_Normal_Mk2_Orderer_ID:
                if (pipe == null || pipe.pipe == null || !(pipe.pipe instanceof PipeItemsRequestLogisticsMk2)) {
                    return null;
                }
                return new NormalMk2GuiOrderer(((PipeItemsRequestLogisticsMk2) pipe.pipe), player);
            case GuiIDs.GUI_Fluid_Orderer_ID:
                if (pipe == null || pipe.pipe == null || !(pipe.pipe instanceof PipeFluidRequestLogistics)) {
                    return null;
                }
                return new FluidGuiOrderer(((PipeFluidRequestLogistics) pipe.pipe), player);
            case GuiIDs.GUI_Inv_Sys_Connector_ID:
                if (pipe == null || pipe.pipe == null || !(pipe.pipe instanceof PipeItemsInvSysConnector)) {
                    return null;
                }
                return new GuiInvSysConnector(player, (PipeItemsInvSysConnector) pipe.pipe);
            case GuiIDs.GUI_Freq_Card_ID:
                if (pipe == null || pipe.pipe == null || !((pipe.pipe instanceof PipeItemsSystemEntranceLogistics) || (pipe.pipe instanceof PipeItemsSystemDestinationLogistics))) {
                    return null;
                }
                IInventory inv = null;
                if (pipe.pipe instanceof PipeItemsSystemEntranceLogistics) {
                    inv = ((PipeItemsSystemEntranceLogistics) pipe.pipe).inv;
                } else if (pipe.pipe instanceof PipeItemsSystemDestinationLogistics) {
                    inv = ((PipeItemsSystemDestinationLogistics) pipe.pipe).inv;
                }
                return new GuiFreqCardContent(player, inv);
            case GuiIDs.GUI_HUD_Settings:
                return new GuiHUDSettings(player, x);
            case GuiIDs.GUI_Fluid_Basic_ID:
                if (pipe == null || pipe.pipe == null || !((pipe.pipe instanceof PipeFluidBasic))) {
                    return null;
                }
                return new GuiFluidBasic(player, ((PipeFluidBasic) pipe.pipe).filterInv);
            case GuiIDs.GUI_FIREWALL:
                if (pipe == null || pipe.pipe == null || !((pipe.pipe instanceof PipeItemsFirewall))) {
                    return null;
                }
                return new GuiFirewall((PipeItemsFirewall) pipe.pipe, player);
            case GuiIDs.GUI_Request_Table_ID:
                if (pipe == null || pipe.pipe == null || !(pipe.pipe instanceof PipeBlockRequestTable)) {
                    return null;
                }
                return new GuiRequestTable(player, ((PipeBlockRequestTable) pipe.pipe));
            default:
                break;
        }
    }
    return null;
}
Also used : GuiFreqCardContent(logisticspipes.gui.GuiFreqCardContent) GuiFluidSupplierPipe(logisticspipes.gui.GuiFluidSupplierPipe) PipeFluidBasic(logisticspipes.pipes.PipeFluidBasic) TileEntity(net.minecraft.tileentity.TileEntity) PipeFluidSupplierMk2(logisticspipes.pipes.PipeFluidSupplierMk2) PipeItemsInvSysConnector(logisticspipes.pipes.PipeItemsInvSysConnector) PipeItemsFluidSupplier(logisticspipes.pipes.PipeItemsFluidSupplier) PipeFluidRequestLogistics(logisticspipes.pipes.PipeFluidRequestLogistics) PipeItemsSystemDestinationLogistics(logisticspipes.pipes.PipeItemsSystemDestinationLogistics) NormalGuiOrderer(logisticspipes.gui.orderer.NormalGuiOrderer) NormalMk2GuiOrderer(logisticspipes.gui.orderer.NormalMk2GuiOrderer) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) PipeItemsRequestLogisticsMk2(logisticspipes.pipes.PipeItemsRequestLogisticsMk2) GuiHUDSettings(logisticspipes.gui.hud.GuiHUDSettings) FluidGuiOrderer(logisticspipes.gui.orderer.FluidGuiOrderer) IInventory(net.minecraft.inventory.IInventory) GuiSatellitePipe(logisticspipes.gui.GuiSatellitePipe) PipeItemsFirewall(logisticspipes.pipes.PipeItemsFirewall) PipeBlockRequestTable(logisticspipes.pipes.PipeBlockRequestTable) PipeItemsSatelliteLogistics(logisticspipes.pipes.PipeItemsSatelliteLogistics) GuiFirewall(logisticspipes.gui.GuiFirewall) PipeItemsSystemEntranceLogistics(logisticspipes.pipes.PipeItemsSystemEntranceLogistics) GuiFluidBasic(logisticspipes.gui.GuiFluidBasic) PipeFluidSatellite(logisticspipes.pipes.PipeFluidSatellite) PipeItemsProviderLogistics(logisticspipes.pipes.PipeItemsProviderLogistics) GuiRequestTable(logisticspipes.gui.orderer.GuiRequestTable) GuiInvSysConnector(logisticspipes.gui.GuiInvSysConnector) GuiFluidSupplierMk2Pipe(logisticspipes.gui.GuiFluidSupplierMk2Pipe) GuiProviderPipe(logisticspipes.gui.GuiProviderPipe)

Example 2 with PipeItemsSystemDestinationLogistics

use of logisticspipes.pipes.PipeItemsSystemDestinationLogistics in project LogisticsPipes by RS485.

the class GuiHandler method getServerGuiElement.

@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, final int x, final int y, final int z) {
    TileEntity tile = null;
    if (y != -1) {
        tile = world.getTileEntity(x, y, z);
    }
    LogisticsTileGenericPipe pipe = null;
    if (tile instanceof LogisticsTileGenericPipe) {
        pipe = (LogisticsTileGenericPipe) tile;
    }
    final LogisticsTileGenericPipe fpipe = pipe;
    DummyContainer dummy;
    int xOffset;
    int yOffset;
    if (ID > 10000) {
        ID -= 10000;
    }
    //Handle Module Configuration
    if (ID == -1) {
        return getServerGuiElement(100 * -20 + x, player, world, 0, -1, z);
    }
    if (ID < 110 && ID > 0) {
        switch(ID) {
            case GuiIDs.GUI_FluidSupplier_ID:
                if (pipe == null || pipe.pipe == null || !(pipe.pipe instanceof PipeItemsFluidSupplier)) {
                    return null;
                }
                dummy = new DummyContainer(player.inventory, ((PipeItemsFluidSupplier) pipe.pipe).getDummyInventory());
                dummy.addNormalSlotsForPlayerInventory(18, 97);
                xOffset = 72;
                yOffset = 18;
                for (int row = 0; row < 3; row++) {
                    for (int column = 0; column < 3; column++) {
                        dummy.addDummySlot(column + row * 3, xOffset + column * 18, yOffset + row * 18);
                    }
                }
                MainProxy.sendPacketToPlayer(PacketHandler.getPacket(FluidSupplierMode.class).setInteger((((PipeItemsFluidSupplier) pipe.pipe).isRequestingPartials() ? 1 : 0)).setPosX(pipe.xCoord).setPosY(pipe.yCoord).setPosZ(pipe.zCoord), player);
                return dummy;
            case GuiIDs.GUI_FluidSupplier_MK2_ID:
                if (pipe == null || pipe.pipe == null || !(pipe.pipe instanceof PipeFluidSupplierMk2)) {
                    return null;
                }
                dummy = new DummyContainer(player.inventory, ((PipeFluidSupplierMk2) pipe.pipe).getDummyInventory());
                dummy.addNormalSlotsForPlayerInventory(18, 97);
                dummy.addFluidSlot(0, ((PipeFluidSupplierMk2) pipe.pipe).getDummyInventory(), 0, 0);
                MainProxy.sendPacketToPlayer(PacketHandler.getPacket(FluidSupplierMode.class).setInteger((((PipeFluidSupplierMk2) pipe.pipe).isRequestingPartials() ? 1 : 0)).setPosX(pipe.xCoord).setPosY(pipe.yCoord).setPosZ(pipe.zCoord), player);
                MainProxy.sendPacketToPlayer(PacketHandler.getPacket(FluidSupplierMinMode.class).setInteger(((PipeFluidSupplierMk2) pipe.pipe).getMinMode().ordinal()).setPosX(pipe.xCoord).setPosY(pipe.yCoord).setPosZ(pipe.zCoord), player);
                return dummy;
            case GuiIDs.GUI_ProviderPipe_ID:
                if (pipe == null || pipe.pipe == null || !(pipe.pipe instanceof PipeItemsProviderLogistics)) {
                    return null;
                }
                dummy = new DummyContainer(player.inventory, ((PipeItemsProviderLogistics) pipe.pipe).getprovidingInventory());
                dummy.addNormalSlotsForPlayerInventory(18, 97);
                xOffset = 72;
                yOffset = 18;
                for (int row = 0; row < 3; row++) {
                    for (int column = 0; column < 3; column++) {
                        dummy.addDummySlot(column + row * 3, xOffset + column * 18, yOffset + row * 18);
                    }
                }
                return dummy;
            case GuiIDs.GUI_SatellitePipe_ID:
                if (pipe != null && pipe.pipe != null && pipe.pipe instanceof PipeItemsSatelliteLogistics) {
                    return new DummyContainer(player.inventory, null);
                }
                if (pipe != null && pipe.pipe != null && pipe.pipe instanceof PipeFluidSatellite) {
                    return new DummyContainer(player.inventory, null);
                }
            case GuiIDs.GUI_Normal_Orderer_ID:
                if (pipe == null || pipe.pipe == null || !(pipe.pipe instanceof CoreRoutedPipe)) {
                    return null;
                }
                return new DummyContainer(player.inventory, null);
            case GuiIDs.GUI_Normal_Mk2_Orderer_ID:
                if (pipe == null || pipe.pipe == null || !(pipe.pipe instanceof PipeItemsRequestLogisticsMk2)) {
                    return null;
                }
                return new DummyContainer(player.inventory, null);
            case GuiIDs.GUI_Fluid_Orderer_ID:
                if (pipe == null || pipe.pipe == null || !(pipe.pipe instanceof PipeFluidRequestLogistics)) {
                    return null;
                }
                return new DummyContainer(player.inventory, null);
            case GuiIDs.GUI_Inv_Sys_Connector_ID:
                if (pipe == null || pipe.pipe == null || !(pipe.pipe instanceof PipeItemsInvSysConnector)) {
                    return null;
                }
                dummy = new DummyContainer(player.inventory, ((PipeItemsInvSysConnector) pipe.pipe).inv);
                dummy.addRestrictedSlot(0, ((PipeItemsInvSysConnector) pipe.pipe).inv, 50, 10, itemStack -> {
                    if (itemStack == null) {
                        return false;
                    }
                    if (itemStack.getItem() != LogisticsPipes.LogisticsItemCard) {
                        return false;
                    }
                    if (itemStack.getItemDamage() != LogisticsItemCard.FREQ_CARD) {
                        return false;
                    }
                    return true;
                });
                dummy.addNormalSlotsForPlayerInventory(0, 50);
                MainProxy.sendPacketToPlayer(PacketHandler.getPacket(InvSysConResistance.class).setInteger(((PipeItemsInvSysConnector) pipe.pipe).resistance).setPosX(pipe.xCoord).setPosY(pipe.yCoord).setPosZ(pipe.zCoord), player);
                return dummy;
            case GuiIDs.GUI_Freq_Card_ID:
                if (pipe == null || pipe.pipe == null || !((pipe.pipe instanceof PipeItemsSystemEntranceLogistics) || (pipe.pipe instanceof PipeItemsSystemDestinationLogistics))) {
                    return null;
                }
                IInventory inv = null;
                if (pipe.pipe instanceof PipeItemsSystemEntranceLogistics) {
                    inv = ((PipeItemsSystemEntranceLogistics) pipe.pipe).inv;
                } else if (pipe.pipe instanceof PipeItemsSystemDestinationLogistics) {
                    inv = ((PipeItemsSystemDestinationLogistics) pipe.pipe).inv;
                }
                dummy = new DummyContainer(player.inventory, inv);
                dummy.addRestrictedSlot(0, inv, 40, 40, itemStack -> {
                    if (itemStack == null) {
                        return false;
                    }
                    if (itemStack.getItem() != LogisticsPipes.LogisticsItemCard) {
                        return false;
                    }
                    if (itemStack.getItemDamage() != LogisticsItemCard.FREQ_CARD) {
                        return false;
                    }
                    return true;
                });
                dummy.addNormalSlotsForPlayerInventory(0, 0);
                return dummy;
            case GuiIDs.GUI_HUD_Settings:
                dummy = new DummyContainer(player.inventory, null);
                dummy.addRestrictedHotbarForPlayerInventory(10, 160);
                dummy.addRestrictedArmorForPlayerInventory(10, 60);
                return dummy;
            case GuiIDs.GUI_Fluid_Basic_ID:
                if (pipe == null || pipe.pipe == null || !((pipe.pipe instanceof PipeFluidBasic))) {
                    return null;
                }
                dummy = new DummyContainer(player, ((PipeFluidBasic) pipe.pipe).filterInv, new IGuiOpenControler() {

                    @Override
                    public void guiOpenedByPlayer(EntityPlayer player) {
                        ((PipeFluidBasic) fpipe.pipe).guiOpenedByPlayer(player);
                    }

                    @Override
                    public void guiClosedByPlayer(EntityPlayer player) {
                        ((PipeFluidBasic) fpipe.pipe).guiClosedByPlayer(player);
                    }
                });
                dummy.addFluidSlot(0, ((PipeFluidBasic) pipe.pipe).filterInv, 28, 15);
                dummy.addNormalSlotsForPlayerInventory(10, 45);
                return dummy;
            case GuiIDs.GUI_FIREWALL:
                if (pipe == null || pipe.pipe == null || !((pipe.pipe instanceof PipeItemsFirewall))) {
                    return null;
                }
                dummy = new DummyContainer(player.inventory, ((PipeItemsFirewall) pipe.pipe).inv);
                dummy.addNormalSlotsForPlayerInventory(33, 147);
                for (int i = 0; i < 6; i++) {
                    for (int j = 0; j < 6; j++) {
                        dummy.addDummySlot(i * 6 + j, 0, 0);
                    }
                }
                return dummy;
            case GuiIDs.GUI_Request_Table_ID:
                if (pipe == null || !(pipe.pipe instanceof PipeBlockRequestTable)) {
                    return null;
                }
                dummy = new DummyContainer(player, ((PipeBlockRequestTable) pipe.pipe).matrix, (PipeBlockRequestTable) pipe.pipe);
                int i = 0;
                for (int Y = 0; Y < 3; Y++) {
                    for (int X = 0; X < 9; X++) {
                        dummy.addNormalSlot(i++, ((PipeBlockRequestTable) pipe.pipe).inv, 0, 0);
                    }
                }
                i = 0;
                for (int Y = 0; Y < 3; Y++) {
                    for (int X = 0; X < 3; X++) {
                        dummy.addDummySlot(i++, 0, 0);
                    }
                }
                dummy.addCallableSlotHandler(0, ((PipeBlockRequestTable) pipe.pipe).resultInv, 0, 0, () -> ((PipeBlockRequestTable) fpipe.pipe).getResultForClick());
                dummy.addNormalSlot(0, ((PipeBlockRequestTable) pipe.pipe).toSortInv, 0, 0);
                dummy.addNormalSlot(0, ((PipeBlockRequestTable) pipe.pipe).diskInv, 0, 0);
                dummy.addNormalSlotsForPlayerInventory(0, 0);
                return dummy;
            default:
                break;
        }
    }
    return null;
}
Also used : IInventory(net.minecraft.inventory.IInventory) DummyContainer(logisticspipes.utils.gui.DummyContainer) PipeItemsFirewall(logisticspipes.pipes.PipeItemsFirewall) PipeBlockRequestTable(logisticspipes.pipes.PipeBlockRequestTable) PipeItemsSatelliteLogistics(logisticspipes.pipes.PipeItemsSatelliteLogistics) PipeItemsSystemEntranceLogistics(logisticspipes.pipes.PipeItemsSystemEntranceLogistics) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) InvSysConResistance(logisticspipes.network.packets.pipe.InvSysConResistance) PipeFluidBasic(logisticspipes.pipes.PipeFluidBasic) PipeFluidSatellite(logisticspipes.pipes.PipeFluidSatellite) PipeItemsProviderLogistics(logisticspipes.pipes.PipeItemsProviderLogistics) TileEntity(net.minecraft.tileentity.TileEntity) PipeFluidSupplierMk2(logisticspipes.pipes.PipeFluidSupplierMk2) PipeItemsInvSysConnector(logisticspipes.pipes.PipeItemsInvSysConnector) PipeItemsFluidSupplier(logisticspipes.pipes.PipeItemsFluidSupplier) PipeFluidRequestLogistics(logisticspipes.pipes.PipeFluidRequestLogistics) PipeItemsSystemDestinationLogistics(logisticspipes.pipes.PipeItemsSystemDestinationLogistics) IGuiOpenControler(logisticspipes.interfaces.IGuiOpenControler) FluidSupplierMode(logisticspipes.network.packets.pipe.FluidSupplierMode) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) EntityPlayer(net.minecraft.entity.player.EntityPlayer) PipeItemsRequestLogisticsMk2(logisticspipes.pipes.PipeItemsRequestLogisticsMk2) FluidSupplierMinMode(logisticspipes.network.packets.pipe.FluidSupplierMinMode)

Example 3 with PipeItemsSystemDestinationLogistics

use of logisticspipes.pipes.PipeItemsSystemDestinationLogistics in project LogisticsPipes by RS485.

the class EntrencsTransport method resolveDestination.

@Override
public ForgeDirection resolveDestination(LPTravelingItemServer data) {
    if (data.getDestination() < 0 || data.getArrived()) {
        if (pipe.getLocalFreqUUID() != null) {
            if (pipe.useEnergy(5)) {
                for (ExitRoute router : pipe.getRouter().getIRoutersByCost()) {
                    if (!router.containsFlag(PipeRoutingConnectionType.canRouteTo)) {
                        continue;
                    }
                    CoreRoutedPipe lPipe = router.destination.getPipe();
                    if (lPipe instanceof PipeItemsSystemDestinationLogistics) {
                        PipeItemsSystemDestinationLogistics dPipe = (PipeItemsSystemDestinationLogistics) lPipe;
                        if (dPipe.getTargetUUID() != null) {
                            if (dPipe.getTargetUUID().equals(pipe.getLocalFreqUUID())) {
                                data.setDestination(dPipe.getRouter().getSimpleID());
                                data.setArrived(false);
                            }
                        }
                    }
                }
            }
        }
    }
    return super.resolveDestination(data);
}
Also used : PipeItemsSystemDestinationLogistics(logisticspipes.pipes.PipeItemsSystemDestinationLogistics) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) ExitRoute(logisticspipes.routing.ExitRoute)

Aggregations

PipeItemsSystemDestinationLogistics (logisticspipes.pipes.PipeItemsSystemDestinationLogistics)3 PipeBlockRequestTable (logisticspipes.pipes.PipeBlockRequestTable)2 PipeFluidBasic (logisticspipes.pipes.PipeFluidBasic)2 PipeFluidRequestLogistics (logisticspipes.pipes.PipeFluidRequestLogistics)2 PipeFluidSatellite (logisticspipes.pipes.PipeFluidSatellite)2 PipeFluidSupplierMk2 (logisticspipes.pipes.PipeFluidSupplierMk2)2 PipeItemsFirewall (logisticspipes.pipes.PipeItemsFirewall)2 PipeItemsFluidSupplier (logisticspipes.pipes.PipeItemsFluidSupplier)2 PipeItemsInvSysConnector (logisticspipes.pipes.PipeItemsInvSysConnector)2 PipeItemsProviderLogistics (logisticspipes.pipes.PipeItemsProviderLogistics)2 PipeItemsRequestLogisticsMk2 (logisticspipes.pipes.PipeItemsRequestLogisticsMk2)2 PipeItemsSatelliteLogistics (logisticspipes.pipes.PipeItemsSatelliteLogistics)2 PipeItemsSystemEntranceLogistics (logisticspipes.pipes.PipeItemsSystemEntranceLogistics)2 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)2 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)2 IInventory (net.minecraft.inventory.IInventory)2 TileEntity (net.minecraft.tileentity.TileEntity)2 GuiFirewall (logisticspipes.gui.GuiFirewall)1 GuiFluidBasic (logisticspipes.gui.GuiFluidBasic)1 GuiFluidSupplierMk2Pipe (logisticspipes.gui.GuiFluidSupplierMk2Pipe)1