Search in sources :

Example 86 with LogisticsTileGenericPipe

use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.

the class LogisticsPowerProviderTileEntity method update.

@Override
public void update() {
    super.update();
    pauseRequesting = false;
    if (!init) {
        if (MainProxy.isClient(getWorld())) {
            LogisticsHUDRenderer.instance().add(this);
        }
        init = true;
    }
    double globalRequest = orders.values().stream().reduce(Double::sum).orElse(0.0);
    if (globalRequest > 0) {
        final double fullfillRatio = Math.min(1, Math.min(internalStorage, getMaxProvidePerTick()) / globalRequest);
        if (fullfillRatio > 0) {
            final Function<NeighborTileEntity<LogisticsTileGenericPipe>, CoreRoutedPipe> getPipe = (NeighborTileEntity<LogisticsTileGenericPipe> neighbor) -> (CoreRoutedPipe) neighbor.getTileEntity().pipe;
            orders.entrySet().stream().map(routerIdToOrderCount -> new Pair<>(SimpleServiceLocator.routerManager.getRouter(routerIdToOrderCount.getKey()), Math.min(internalStorage, routerIdToOrderCount.getValue() * fullfillRatio))).filter(destinationToPower -> destinationToPower.getValue1() != null && destinationToPower.getValue1().getPipe() != null).forEach(destinationToPower -> new WorldCoordinatesWrapper(this).allNeighborTileEntities().stream().flatMap(neighbor -> LPNeighborTileEntityKt.optionalIs(neighbor, LogisticsTileGenericPipe.class).map(Stream::of).orElseGet(Stream::empty)).filter(neighbor -> neighbor.getTileEntity().pipe instanceof CoreRoutedPipe && !getPipe.apply(neighbor).stillNeedReplace()).flatMap(neighbor -> getPipe.apply(neighbor).getRouter().getDistanceTo(destinationToPower.getValue1()).stream().map(exitRoute -> new Pair<>(neighbor, exitRoute))).filter(neighborToExit -> neighborToExit.getValue2().containsFlag(PipeRoutingConnectionType.canPowerSubSystemFrom) && neighborToExit.getValue2().filters.stream().noneMatch(IFilter::blockPower)).findFirst().ifPresent(neighborToSource -> {
                CoreRoutedPipe sourcePipe = getPipe.apply(neighborToSource.getValue1());
                if (sourcePipe.isInitialized()) {
                    sourcePipe.container.addLaser(neighborToSource.getValue1().getOurDirection(), 1, getLaserColor(), true, true);
                }
                sendPowerLaserPackets(sourcePipe.getRouter(), destinationToPower.getValue1(), neighborToSource.getValue2().exitOrientation, neighborToSource.getValue2().exitOrientation != neighborToSource.getValue1().getDirection());
                internalStorage -= destinationToPower.getValue2();
                // because calculations with floats
                if (internalStorage <= 0)
                    internalStorage = 0;
                handlePower(destinationToPower.getValue1().getPipe(), destinationToPower.getValue2());
            }));
        }
    }
    orders.clear();
    if (MainProxy.isServer(world)) {
        if (internalStorage != lastUpdateStorage) {
            updateClients();
            lastUpdateStorage = internalStorage;
        }
    }
}
Also used : PowerProviderGui(logisticspipes.network.guis.block.PowerProviderGui) IRouter(logisticspipes.routing.IRouter) NeighborTileEntity(network.rs485.logisticspipes.connection.NeighborTileEntity) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) LogisticsPipes(logisticspipes.LogisticsPipes) LogisticsSolidTileEntity(logisticspipes.blocks.LogisticsSolidTileEntity) HashMap(java.util.HashMap) CCType(logisticspipes.proxy.computers.interfaces.CCType) MainProxy(logisticspipes.proxy.MainProxy) Function(java.util.function.Function) IHeadUpDisplayRenderer(logisticspipes.interfaces.IHeadUpDisplayRenderer) HUDStartBlockWatchingPacket(logisticspipes.network.packets.hud.HUDStartBlockWatchingPacket) PlayerCollectionList(logisticspipes.utils.PlayerCollectionList) NBTTagFloat(net.minecraft.nbt.NBTTagFloat) IHeadUpDisplayBlockRendererProvider(logisticspipes.interfaces.IHeadUpDisplayBlockRendererProvider) ISubSystemPowerProvider(logisticspipes.interfaces.ISubSystemPowerProvider) CrashReportCategory(net.minecraft.crash.CrashReportCategory) LogisticsHUDRenderer(logisticspipes.renderer.LogisticsHUDRenderer) Map(java.util.Map) IBlockWatchingHandler(logisticspipes.interfaces.IBlockWatchingHandler) LPNeighborTileEntityKt(network.rs485.logisticspipes.connection.LPNeighborTileEntityKt) LinkedList(java.util.LinkedList) CoordinatesGuiProvider(logisticspipes.network.abstractguis.CoordinatesGuiProvider) CCCommand(logisticspipes.proxy.computers.interfaces.CCCommand) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NewGuiHandler(logisticspipes.network.NewGuiHandler) PipeRoutingConnectionType(logisticspipes.routing.PipeRoutingConnectionType) HUDStopBlockWatchingPacket(logisticspipes.network.packets.hud.HUDStopBlockWatchingPacket) IGuiOpenControler(logisticspipes.interfaces.IGuiOpenControler) EnumFacing(net.minecraft.util.EnumFacing) Triplet(logisticspipes.utils.tuples.Triplet) PacketHandler(logisticspipes.network.PacketHandler) ExitRoute(logisticspipes.routing.ExitRoute) PowerProviderLevel(logisticspipes.network.packets.block.PowerProviderLevel) ServerRouter(logisticspipes.routing.ServerRouter) List(java.util.List) SimpleServiceLocator(logisticspipes.proxy.SimpleServiceLocator) Stream(java.util.stream.Stream) IFilter(logisticspipes.interfaces.routing.IFilter) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Pair(logisticspipes.utils.tuples.Pair) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) IGuiTileEntity(logisticspipes.interfaces.IGuiTileEntity) IPowerLevelDisplay(logisticspipes.interfaces.IPowerLevelDisplay) BitSet(java.util.BitSet) WorldCoordinatesWrapper(network.rs485.logisticspipes.world.WorldCoordinatesWrapper) HUDPowerLevel(logisticspipes.gui.hud.HUDPowerLevel) NeighborTileEntity(network.rs485.logisticspipes.connection.NeighborTileEntity) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) WorldCoordinatesWrapper(network.rs485.logisticspipes.world.WorldCoordinatesWrapper) Stream(java.util.stream.Stream) Pair(logisticspipes.utils.tuples.Pair)

Example 87 with LogisticsTileGenericPipe

use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.

the class LogisticsProgramCompilerTileEntity method update.

@Override
public void update() {
    super.update();
    if (MainProxy.isServer(world)) {
        if (currentTask != null) {
            wasAbleToConsumePower = false;
            for (EnumFacing dir : EnumFacing.VALUES) {
                if (dir == EnumFacing.UP)
                    continue;
                DoubleCoordinates pos = CoordinateUtils.add(new DoubleCoordinates(this), dir);
                TileEntity tile = pos.getTileEntity(getWorld());
                if (!(tile instanceof LogisticsTileGenericPipe)) {
                    continue;
                }
                LogisticsTileGenericPipe tPipe = (LogisticsTileGenericPipe) tile;
                if (!(tPipe.pipe.getClass() == PipeItemsBasicLogistics.class)) {
                    continue;
                }
                CoreRoutedPipe pipe = (CoreRoutedPipe) tPipe.pipe;
                if (pipe.useEnergy(10)) {
                    if (taskType.equals("category")) {
                        taskProgress += 0.0005;
                    } else if (taskType.equals("program")) {
                        taskProgress += 0.0025;
                    } else if (taskType.equals("flash")) {
                        taskProgress += 0.01;
                    } else {
                        taskProgress += 1;
                    }
                    wasAbleToConsumePower = true;
                }
            }
            if (taskProgress >= 1) {
                if (taskType.equals("category")) {
                    NBTTagList list = getNBTTagListForKey("compilerCategories");
                    list.appendTag(new NBTTagString(currentTask.toString()));
                } else if (taskType.equals("program")) {
                    NBTTagList list = getNBTTagListForKey("compilerPrograms");
                    list.appendTag(new NBTTagString(currentTask.toString()));
                } else if (taskType.equals("flash")) {
                    if (!getInventory().getStackInSlot(1).isEmpty()) {
                        ItemStack programmer = getInventory().getStackInSlot(1);
                        if (!programmer.hasTagCompound()) {
                            programmer.setTagCompound(new NBTTagCompound());
                        }
                        programmer.getTagCompound().setString(ItemLogisticsProgrammer.RECIPE_TARGET, currentTask.toString());
                    }
                } else {
                    throw new UnsupportedOperationException(taskType);
                }
                taskType = "";
                currentTask = null;
                taskProgress = 0;
                wasAbleToConsumePower = false;
            }
            updateClient();
        }
    }
}
Also used : IGuiTileEntity(logisticspipes.interfaces.IGuiTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) NBTTagList(net.minecraft.nbt.NBTTagList) EnumFacing(net.minecraft.util.EnumFacing) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) NBTTagString(net.minecraft.nbt.NBTTagString) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) ItemStack(net.minecraft.item.ItemStack)

Example 88 with LogisticsTileGenericPipe

use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.

the class ItemPipeSignCreator method onItemUse.

@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (MainProxy.isClient(world)) {
        return EnumActionResult.FAIL;
    }
    ItemStack itemStack = player.inventory.getCurrentItem();
    if (itemStack.isEmpty() || itemStack.getItemDamage() > this.getMaxDamage()) {
        return EnumActionResult.FAIL;
    }
    TileEntity tile = world.getTileEntity(pos);
    if (!(tile instanceof LogisticsTileGenericPipe)) {
        return EnumActionResult.FAIL;
    }
    if (!itemStack.hasTagCompound()) {
        itemStack.setTagCompound(new NBTTagCompound());
    }
    itemStack.getTagCompound().setInteger("PipeClicked", 0);
    int mode = itemStack.getTagCompound().getInteger("CreatorMode");
    if (facing == null) {
        return EnumActionResult.FAIL;
    }
    if (!(((LogisticsTileGenericPipe) tile).pipe instanceof CoreRoutedPipe)) {
        return EnumActionResult.FAIL;
    }
    CoreRoutedPipe pipe = (CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe;
    if (pipe == null) {
        return EnumActionResult.FAIL;
    }
    if (!player.isSneaking()) {
        if (pipe.hasPipeSign(facing)) {
            pipe.activatePipeSign(facing, player);
            return EnumActionResult.SUCCESS;
        } else if (mode >= 0 && mode < ItemPipeSignCreator.signTypes.size()) {
            Class<? extends IPipeSign> signClass = ItemPipeSignCreator.signTypes.get(mode);
            try {
                IPipeSign sign = signClass.newInstance();
                if (sign.isAllowedFor(pipe)) {
                    itemStack.damageItem(1, player);
                    sign.addSignTo(pipe, facing, player);
                    return EnumActionResult.SUCCESS;
                } else {
                    return EnumActionResult.FAIL;
                }
            } catch (InstantiationException | IllegalAccessException e) {
                throw new RuntimeException(e);
            }
        } else {
            return EnumActionResult.FAIL;
        }
    } else {
        if (pipe.hasPipeSign(facing)) {
            pipe.removePipeSign(facing, player);
            itemStack.damageItem(-1, player);
        }
        return EnumActionResult.SUCCESS;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IPipeSign(logisticspipes.pipes.signs.IPipeSign) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) ItemStack(net.minecraft.item.ItemStack) Nonnull(javax.annotation.Nonnull)

Example 89 with LogisticsTileGenericPipe

use of logisticspipes.pipes.basic.LogisticsTileGenericPipe 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(new BlockPos(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 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)).setBlockPos(pipe.getPos()), player);
                return dummy;
            case GuiIDs.GUI_FluidSupplier_MK2_ID:
                if (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)).setBlockPos(pipe.getPos()), player);
                MainProxy.sendPacketToPlayer(PacketHandler.getPacket(FluidSupplierMinMode.class).setInteger(((PipeFluidSupplierMk2) pipe.pipe).getMinMode().ordinal()).setBlockPos(pipe.getPos()), player);
                return dummy;
            case GuiIDs.GUI_SatellitePipe_ID:
                if (pipe != null && pipe.pipe instanceof PipeItemsSatelliteLogistics) {
                    return new DummyContainer(player.inventory, null);
                }
                if (pipe != null && pipe.pipe instanceof PipeFluidSatellite) {
                    return new DummyContainer(player.inventory, null);
                }
            case GuiIDs.GUI_Normal_Orderer_ID:
                if (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 instanceof PipeItemsRequestLogisticsMk2)) {
                    return null;
                }
                return new DummyContainer(player.inventory, null);
            case GuiIDs.GUI_Fluid_Orderer_ID:
                if (pipe == null || !(pipe.pipe instanceof PipeFluidRequestLogistics)) {
                    return null;
                }
                return new DummyContainer(player.inventory, null);
            case GuiIDs.GUI_Freq_Card_ID:
                if (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.isEmpty()) {
                        return false;
                    }
                    if (itemStack.getItem() != LPItems.itemCard) {
                        return false;
                    }
                    return itemStack.getItemDamage() == LogisticsItemCard.FREQ_CARD;
                });
                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 instanceof PipeFluidBasic))) {
                    return null;
                }
                dummy = new DummyContainer(player, ((PipeFluidBasic) pipe.pipe).getSinkInv(), 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).getSinkInv(), 28, 15);
                dummy.addNormalSlotsForPlayerInventory(10, 45);
                return dummy;
            case GuiIDs.GUI_Fluid_Terminus_ID:
                if (pipe == null || !((pipe.pipe instanceof PipeFluidTerminus))) {
                    return null;
                }
                dummy = new DummyContainer(player, ((PipeFluidTerminus) pipe.pipe).getSinkInv(), new IGuiOpenControler() {

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

                    @Override
                    public void guiClosedByPlayer(EntityPlayer player) {
                        ((PipeFluidTerminus) fpipe.pipe).guiClosedByPlayer(player);
                    }
                });
                for (int i = 0; i < 9; i++) {
                    dummy.addFluidSlot(i, ((PipeFluidTerminus) pipe.pipe).getSinkInv(), 8 + i * 18, 13);
                }
                dummy.addNormalSlotsForPlayerInventory(10, 45);
                return dummy;
            case GuiIDs.GUI_FIREWALL:
                if (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) PipeFluidTerminus(logisticspipes.pipes.PipeFluidTerminus) PipeFluidBasic(logisticspipes.pipes.PipeFluidBasic) PipeFluidSatellite(logisticspipes.pipes.PipeFluidSatellite) TileEntity(net.minecraft.tileentity.TileEntity) PipeFluidSupplierMk2(logisticspipes.pipes.PipeFluidSupplierMk2) 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) BlockPos(net.minecraft.util.math.BlockPos) PipeItemsRequestLogisticsMk2(logisticspipes.pipes.PipeItemsRequestLogisticsMk2) FluidSupplierMinMode(logisticspipes.network.packets.pipe.FluidSupplierMinMode)

Example 90 with LogisticsTileGenericPipe

use of logisticspipes.pipes.basic.LogisticsTileGenericPipe 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) {
    if (ID == -1) {
        return getClientGuiElement(-100 * 20 + x, player, world, 0, -1, z);
    }
    TileEntity tile = world.getTileEntity(new BlockPos(x, y, z));
    LogisticsTileGenericPipe pipe = null;
    if (tile instanceof LogisticsTileGenericPipe) {
        pipe = (LogisticsTileGenericPipe) tile;
    }
    if (ID < 110 && ID > 0) {
        switch(ID) {
            case GuiIDs.GUI_FluidSupplier_ID:
                if (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 instanceof PipeFluidSupplierMk2)) {
                    return null;
                }
                return new GuiFluidSupplierMk2Pipe(player.inventory, ((PipeFluidSupplierMk2) pipe.pipe).getDummyInventory(), (PipeFluidSupplierMk2) pipe.pipe);
            case GuiIDs.GUI_SatellitePipe_ID:
                if (pipe != null && pipe.pipe instanceof SatellitePipe) {
                    return new GuiSatellitePipe(((SatellitePipe) pipe.pipe));
                }
                return null;
            case GuiIDs.GUI_Normal_Orderer_ID:
                return new NormalGuiOrderer(x, y, z, world.provider.getDimension(), player);
            case GuiIDs.GUI_Normal_Mk2_Orderer_ID:
                if (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 instanceof PipeFluidRequestLogistics)) {
                    return null;
                }
                return new FluidGuiOrderer(((PipeFluidRequestLogistics) pipe.pipe), player);
            case GuiIDs.GUI_Freq_Card_ID:
                if (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 instanceof PipeFluidBasic))) {
                    return null;
                }
                return new GuiFluidBasic(player, ((PipeFluidBasic) pipe.pipe).getSinkInv());
            case GuiIDs.GUI_Fluid_Terminus_ID:
                if (pipe == null || !((pipe.pipe instanceof PipeFluidTerminus))) {
                    return null;
                }
                return new GuiFluidTerminus(player, ((PipeFluidTerminus) pipe.pipe));
            case GuiIDs.GUI_FIREWALL:
                if (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 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) 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) BlockPos(net.minecraft.util.math.BlockPos) 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) GuiFirewall(logisticspipes.gui.GuiFirewall) PipeItemsSystemEntranceLogistics(logisticspipes.pipes.PipeItemsSystemEntranceLogistics) GuiFluidBasic(logisticspipes.gui.GuiFluidBasic) PipeFluidTerminus(logisticspipes.pipes.PipeFluidTerminus) SatellitePipe(network.rs485.logisticspipes.SatellitePipe) GuiSatellitePipe(logisticspipes.gui.GuiSatellitePipe) GuiRequestTable(logisticspipes.gui.orderer.GuiRequestTable) GuiFluidTerminus(logisticspipes.gui.GuiFluidTerminus) GuiFluidSupplierMk2Pipe(logisticspipes.gui.GuiFluidSupplierMk2Pipe)

Aggregations

LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)115 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)47 TileEntity (net.minecraft.tileentity.TileEntity)45 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)21 EnumFacing (net.minecraft.util.EnumFacing)15 ArrayList (java.util.ArrayList)14 List (java.util.List)12 EntityPlayer (net.minecraft.entity.player.EntityPlayer)10 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)10 BlockPos (net.minecraft.util.math.BlockPos)10 World (net.minecraft.world.World)9 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)9 HashMap (java.util.HashMap)8 LinkedList (java.util.LinkedList)8 PipeBlockRequestTable (logisticspipes.pipes.PipeBlockRequestTable)8 LogisticsPowerJunctionTileEntity (logisticspipes.blocks.powertile.LogisticsPowerJunctionTileEntity)7 MainProxy (logisticspipes.proxy.MainProxy)7 ExitRoute (logisticspipes.routing.ExitRoute)7 PipeLogisticsChassi (logisticspipes.pipes.PipeLogisticsChassi)6 SimpleServiceLocator (logisticspipes.proxy.SimpleServiceLocator)6