Search in sources :

Example 21 with LogisticsTileGenericPipe

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

the class PipeTransportLogistics method resolveUnroutedDestination.

public RoutingResult resolveUnroutedDestination(LPTravelingItemServer data) {
    List<EnumFacing> dirs = new ArrayList<>(Arrays.asList(EnumFacing.VALUES));
    dirs.remove(data.input.getOpposite());
    Iterator<EnumFacing> iter = dirs.iterator();
    while (iter.hasNext()) {
        EnumFacing dir = iter.next();
        DoubleCoordinates pos = CoordinateUtils.add(getPipe().getLPPosition(), dir);
        TileEntity tile = pos.getTileEntity(getWorld());
        if (!SimpleServiceLocator.pipeInformationManager.isItemPipe(tile)) {
            iter.remove();
        } else if (!canPipeConnect(tile, dir)) {
            iter.remove();
        } else if (tile instanceof LogisticsTileGenericPipe && !((LogisticsTileGenericPipe) tile).canConnect(container, dir.getOpposite(), false)) {
            iter.remove();
        }
    }
    if (dirs.isEmpty()) {
        return new RoutingResult(null, false);
    }
    int num = new Random().nextInt(dirs.size());
    return new RoutingResult(dirs.get(num), true);
}
Also used : LogisticsPowerJunctionTileEntity(logisticspipes.blocks.powertile.LogisticsPowerJunctionTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) Random(java.util.Random) EnumFacing(net.minecraft.util.EnumFacing) ArrayList(java.util.ArrayList) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 22 with LogisticsTileGenericPipe

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

the class PathFinder method messureDistanceToNextRoutedPipe.

public static int messureDistanceToNextRoutedPipe(DoubleCoordinates lpPosition, EnumFacing exitOrientation, World world) {
    int dis = 1;
    TileEntity tile = lpPosition.getTileEntity(world);
    if (tile instanceof LogisticsTileGenericPipe) {
        tile = ((LogisticsTileGenericPipe) tile).getNextConnectedTile(exitOrientation);
    }
    if (tile == null) {
        return 0;
    }
    IPipeInformationProvider info = SimpleServiceLocator.pipeInformationManager.getInformationProviderFor(tile);
    while (info != null && !info.isRoutingPipe()) {
        tile = info.getNextConnectedTile(exitOrientation);
        if (tile == null) {
            info = null;
            continue;
        }
        info = SimpleServiceLocator.pipeInformationManager.getInformationProviderFor(tile);
        dis++;
    }
    return dis;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe)

Example 23 with LogisticsTileGenericPipe

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

the class TEControl method invalidate.

public static void invalidate(final TileEntity tile) {
    final World world = tile.getWorld();
    if (!MainProxy.isServer(world)) {
        return;
    }
    if (tile instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) tile).isRoutingPipe()) {
        return;
    }
    if (((ILPTEInformation) tile).getObject() != null) {
        QueuedTasks.queueTask(() -> {
            DoubleCoordinates pos = new DoubleCoordinates(tile);
            for (EnumFacing dir : EnumFacing.VALUES) {
                DoubleCoordinates newPos = CoordinateUtils.sum(pos, dir);
                if (!newPos.blockExists(world)) {
                    continue;
                }
                TileEntity nextTile = newPos.getTileEntity(world);
                if (nextTile != null && ((ILPTEInformation) nextTile).getObject() != null) {
                    if (SimpleServiceLocator.pipeInformationManager.isItemPipe(nextTile)) {
                        SimpleServiceLocator.pipeInformationManager.getInformationProviderFor(nextTile).refreshTileCacheOnSide(dir.getOpposite());
                    }
                }
            }
            for (ITileEntityChangeListener listener : new ArrayList<>(((ILPTEInformation) tile).getObject().changeListeners)) {
                listener.pipeRemoved(pos);
            }
            return null;
        });
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ILPTEInformation(logisticspipes.asm.te.ILPTEInformation) ITileEntityChangeListener(logisticspipes.asm.te.ITileEntityChangeListener) EnumFacing(net.minecraft.util.EnumFacing) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) ArrayList(java.util.ArrayList) World(net.minecraft.world.World) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 24 with LogisticsTileGenericPipe

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

the class ClientRouter method getPipe.

@Override
public CoreRoutedPipe getPipe() {
    World world = MainProxy.proxy.getWorld();
    if (world == null) {
        return null;
    }
    TileEntity tile = world.getTileEntity(new BlockPos(_xCoord, _yCoord, _zCoord));
    if (!(tile instanceof LogisticsTileGenericPipe)) {
        return null;
    }
    LogisticsTileGenericPipe pipe = (LogisticsTileGenericPipe) tile;
    if (!(pipe.pipe instanceof CoreRoutedPipe)) {
        return null;
    }
    return (CoreRoutedPipe) pipe.pipe;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World)

Example 25 with LogisticsTileGenericPipe

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

the class PipeFluidSatellite method updateWatchers.

public void updateWatchers() {
    final LogisticsTileGenericPipe container = Objects.requireNonNull(getContainer());
    CoordinatesPacket packet = PacketHandler.getPacket(SyncSatelliteNamePacket.class).setString(satellitePipeName).setTilePos(container);
    MainProxy.sendToPlayerList(packet, localModeWatchers);
    MainProxy.sendPacketToAllWatchingChunk(container, packet);
}
Also used : LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) CoordinatesPacket(logisticspipes.network.abstractpackets.CoordinatesPacket)

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