Search in sources :

Example 51 with CoreRoutedPipe

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

the class PipeManagerWatchingPacket method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    LogisticsTileGenericPipe pipe = this.getPipe(player.getEntityWorld());
    if (pipe == null || !(pipe.pipe instanceof CoreRoutedPipe)) {
        return;
    }
    CoreRoutedPipe cPipe = (CoreRoutedPipe) pipe.pipe;
    if (start) {
        cPipe.getOrderManager().startWatching(player);
    } else {
        cPipe.getOrderManager().stopWatching(player);
    }
}
Also used : LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe)

Example 52 with CoreRoutedPipe

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

the class PipeSignTypes method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    LogisticsTileGenericPipe pipe = this.getPipe(player.getEntityWorld(), LTGPCompletionCheck.PIPE);
    if (pipe == null || !pipe.isInitialized()) {
        return;
    }
    ((CoreRoutedPipe) pipe.pipe).handleSignPacket(types);
}
Also used : LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe)

Example 53 with CoreRoutedPipe

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

the class FluidRoutedPipe method enabledUpdateEntity.

@Override
public void enabledUpdateEntity() {
    super.enabledUpdateEntity();
    if (canInsertFromSideToTanks()) {
        int validDirections = 0;
        List<Pair<TileEntity, ForgeDirection>> list = getAdjacentTanks(true);
        for (Pair<TileEntity, ForgeDirection> pair : list) {
            if (pair.getValue1() instanceof LogisticsTileGenericPipe) {
                if (((LogisticsTileGenericPipe) pair.getValue1()).pipe instanceof CoreRoutedPipe) {
                    continue;
                }
            }
            FluidTank tank = ((PipeFluidTransportLogistics) transport).sideTanks[pair.getValue2().ordinal()];
            validDirections++;
            if (tank.getFluid() == null) {
                continue;
            }
            int filled = ((IFluidHandler) pair.getValue1()).fill(pair.getValue2().getOpposite(), tank.getFluid().copy(), true);
            if (filled == 0) {
                continue;
            }
            FluidStack drain = tank.drain(filled, true);
            if (drain == null || filled != drain.amount) {
                if (LPConstants.DEBUG) {
                    throw new UnsupportedOperationException("Fluid Multiplication");
                }
            }
        }
        if (validDirections == 0) {
            return;
        }
        FluidTank tank = ((PipeFluidTransportLogistics) transport).internalTank;
        FluidStack stack = tank.getFluid();
        if (stack == null) {
            return;
        }
        for (Pair<TileEntity, ForgeDirection> pair : list) {
            if (pair.getValue1() instanceof LogisticsTileGenericPipe) {
                if (((LogisticsTileGenericPipe) pair.getValue1()).pipe instanceof CoreRoutedPipe) {
                    continue;
                }
            }
            FluidTank tankSide = ((PipeFluidTransportLogistics) transport).sideTanks[pair.getValue2().ordinal()];
            stack = tank.getFluid();
            if (stack == null) {
                continue;
            }
            stack = stack.copy();
            int filled = tankSide.fill(stack, true);
            if (filled == 0) {
                continue;
            }
            FluidStack drain = tank.drain(filled, true);
            if (drain == null || filled != drain.amount) {
                if (LPConstants.DEBUG) {
                    throw new UnsupportedOperationException("Fluid Multiplication");
                }
            }
        }
    }
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) PipeFluidTransportLogistics(logisticspipes.transport.PipeFluidTransportLogistics) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) IFluidHandler(net.minecraftforge.fluids.IFluidHandler) TileEntity(net.minecraft.tileentity.TileEntity) FluidTank(net.minecraftforge.fluids.FluidTank) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) Pair(logisticspipes.utils.tuples.Pair)

Example 54 with CoreRoutedPipe

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

the class BaseWrapperClass method load.

@Override
public void load(NBTTagCompound nbt) {
    if (object != null) {
        return;
    }
    String type = nbt.getString("Type");
    if (type.equals("")) {
        return;
    }
    if (type.equals("LPGlobalCCAccess")) {
        object = LogisticsPipes.getComputerLP();
        checkType();
    } else if (type.equals("CoreRoutedPipe")) {
        int x = nbt.getInteger("X");
        int y = nbt.getInteger("Y");
        int z = nbt.getInteger("Z");
        final DoubleCoordinates pos = new DoubleCoordinates(x, y, z);
        final int dim = nbt.getInteger("Dim");
        QueuedTasks.queueTask(() -> {
            World world = DimensionManager.getWorld(dim);
            if (world != null) {
                TileEntity tile = pos.getTileEntity(world);
                if (tile instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) tile).pipe instanceof CoreRoutedPipe) {
                    object = ((LogisticsTileGenericPipe) tile).pipe;
                    checkType();
                }
            }
            return null;
        });
    } else if (type.equals("CCItemIdentifierImplementation")) {
        ItemStack stack = ItemStack.loadItemStackFromNBT(nbt);
        if (stack != null) {
            object = new CCItemIdentifierImplementation(ItemIdentifier.get(stack));
            checkType();
        }
    } else if (type.equals("CCItemIdentifierStackImplementation")) {
        ItemStack stack = ItemStack.loadItemStackFromNBT(nbt);
        if (stack != null) {
            object = new CCItemIdentifierStackImplementation(ItemIdentifierStack.getFromStack(stack));
            checkType();
        }
    } else if (type.equals("CCItemIdentifierBuilder")) {
        ItemStack stack = ItemStack.loadItemStackFromNBT(nbt);
        if (stack != null) {
            CCItemIdentifierBuilder builder = new CCItemIdentifierBuilder();
            builder.setItemID(Double.valueOf(Item.getIdFromItem(stack.getItem())));
            builder.setItemData(Double.valueOf(stack.getItemDamage()));
            object = builder;
            checkType();
        }
    } else if (type.equals("LogisticsSolidTileEntity")) {
        int x = nbt.getInteger("X");
        int y = nbt.getInteger("Y");
        int z = nbt.getInteger("Z");
        final DoubleCoordinates pos = new DoubleCoordinates(x, y, z);
        final int dim = nbt.getInteger("Dim");
        QueuedTasks.queueTask(() -> {
            World world = DimensionManager.getWorld(dim);
            if (world != null) {
                TileEntity tile = pos.getTileEntity(world);
                if (tile instanceof LogisticsSolidTileEntity) {
                    object = tile;
                    checkType();
                }
            }
            return null;
        });
    } else {
        System.out.println("Unknown type to load");
    }
}
Also used : LogisticsSolidTileEntity(logisticspipes.blocks.LogisticsSolidTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) CCItemIdentifierImplementation(logisticspipes.proxy.computers.objects.CCItemIdentifier.CCItemIdentifierImplementation) CCItemIdentifierBuilder(logisticspipes.proxy.computers.objects.CCItemIdentifierBuilder) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) LogisticsSolidTileEntity(logisticspipes.blocks.LogisticsSolidTileEntity) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack) CCItemIdentifierStackImplementation(logisticspipes.proxy.computers.objects.CCItemIdentifierStack.CCItemIdentifierStackImplementation)

Example 55 with CoreRoutedPipe

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

the class LogisticsRoutingBoardRobot method refreshRoutingTable.

private void refreshRoutingTable() {
    TileEntity tile = getLinkedStationPosition().getTileEntity(robot.worldObj);
    if (tile instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) tile).isRoutingPipe()) {
        CoreRoutedPipe pipe = ((LogisticsTileGenericPipe) tile).getRoutingPipe();
        pipe.getRouter().update(true, pipe);
    }
}
Also used : LogisticsPowerJunctionTileEntity(logisticspipes.blocks.powertile.LogisticsPowerJunctionTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe)

Aggregations

CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)68 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)43 TileEntity (net.minecraft.tileentity.TileEntity)22 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)16 ExitRoute (logisticspipes.routing.ExitRoute)15 ArrayList (java.util.ArrayList)14 LinkedList (java.util.LinkedList)13 IRouter (logisticspipes.routing.IRouter)11 Pair (logisticspipes.utils.tuples.Pair)10 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)10 List (java.util.List)9 HashMap (java.util.HashMap)8 IFilter (logisticspipes.interfaces.routing.IFilter)8 SimpleServiceLocator (logisticspipes.proxy.SimpleServiceLocator)7 Map (java.util.Map)6 PipeRoutingConnectionType (logisticspipes.routing.PipeRoutingConnectionType)6 World (net.minecraft.world.World)6 BitSet (java.util.BitSet)5 Collections (java.util.Collections)5 EnumSet (java.util.EnumSet)5