Search in sources :

Example 11 with DoubleCoordinates

use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.

the class LogisticsTileGenericSubMultiBlock method getMainPipe.

public List<LogisticsTileGenericPipe> getMainPipe() {
    if (mainPipe == null) {
        mainPipe = new ArrayList<>();
        for (DoubleCoordinates pos : mainPipePos) {
            TileEntity tile = pos.getTileEntity(getWorldObj());
            if (tile instanceof LogisticsTileGenericPipe) {
                mainPipe.add((LogisticsTileGenericPipe) tile);
            }
        }
        mainPipe = Collections.unmodifiableList(mainPipe);
    }
    boolean allInvalid = true;
    for (LogisticsTileGenericPipe pipe : mainPipe) {
        if (!pipe.isInvalid()) {
            allInvalid = false;
            break;
        }
    }
    if (mainPipe.isEmpty() || allInvalid) {
        getWorldObj().setBlockToAir(xCoord, yCoord, zCoord);
    }
    if (mainPipe != null) {
        return mainPipe;
    }
    return Collections.emptyList();
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 12 with DoubleCoordinates

use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.

the class LogisticsTileGenericSubMultiBlock method writeToNBT.

@Override
public void writeToNBT(NBTTagCompound nbt) {
    super.writeToNBT(nbt);
    NBTTagList nbtList = new NBTTagList();
    for (DoubleCoordinates pos : mainPipePos) {
        NBTTagCompound compound = new NBTTagCompound();
        pos.writeToNBT("MainPipePos_", compound);
        nbtList.appendTag(compound);
    }
    nbt.setTag("MainPipePosList", nbtList);
    NBTTagList nbtTypeList = new NBTTagList();
    for (CoreMultiBlockPipe.SubBlockTypeForShare type : subTypes) {
        if (type == null)
            continue;
        nbtTypeList.appendTag(new NBTTagString(type.name()));
    }
    nbt.setTag("SubTypeList", nbtTypeList);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NBTTagString(net.minecraft.nbt.NBTTagString) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 13 with DoubleCoordinates

use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.

the class PipeItemsInvSysConnector method inventoryConnected.

private boolean inventoryConnected() {
    for (int i = 0; i < 6; i++) {
        ForgeDirection dir = ForgeDirection.values()[i];
        DoubleCoordinates p = CoordinateUtils.add(new DoubleCoordinates(this), dir);
        TileEntity tile = p.getTileEntity(getWorld());
        if (tile instanceof IInventory && this.container.canPipeConnect(tile, dir)) {
            return true;
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IInventory(net.minecraft.inventory.IInventory) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 14 with DoubleCoordinates

use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.

the class RoutingUpdateDebugFilters method readData.

@Override
public void readData(LPDataInput input) {
    pos = new DoubleCoordinates(input);
    filterPositions = new EnumMap<>(PipeRoutingConnectionType.class);
    short id;
    while ((id = input.readShort()) != -1) {
        PipeRoutingConnectionType type = PipeRoutingConnectionType.values[id];
        List<List<DoubleCoordinates>> typeFilters = new ArrayList<>();
        int length;
        while ((length = input.readShort()) != -1) {
            List<DoubleCoordinates> linkedFilter = new ArrayList<>();
            for (int i = 0; i < length; i++) {
                linkedFilter.add(new DoubleCoordinates(input));
            }
            typeFilters.add(linkedFilter);
        }
        filterPositions.put(type, typeFilters);
    }
}
Also used : PipeRoutingConnectionType(logisticspipes.routing.PipeRoutingConnectionType) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 15 with DoubleCoordinates

use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.

the class EnderIOHyperCubeConnection method getConnections.

@Override
public List<TileEntity> getConnections(TileEntity tile) {
    boolean onlyOnePipe = false;
    for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
        DoubleCoordinates p = CoordinateUtils.add(new DoubleCoordinates(tile), direction);
        TileEntity canidate = p.getTileEntity(tile.getWorldObj());
        if (canidate instanceof LogisticsTileGenericPipe && MainProxy.checkPipesConnections(tile, canidate, direction)) {
            if (onlyOnePipe) {
                onlyOnePipe = false;
                break;
            } else {
                onlyOnePipe = true;
            }
        }
    }
    if (!onlyOnePipe || !SimpleServiceLocator.enderIOProxy.isSendAndReceive(tile)) {
        return new ArrayList<>(0);
    }
    List<? extends TileEntity> connections = SimpleServiceLocator.enderIOProxy.getConnectedHyperCubes(tile);
    List<TileEntity> list = new ArrayList<>();
    for (TileEntity connected : connections) {
        if (!SimpleServiceLocator.enderIOProxy.isSendAndReceive(connected)) {
            continue;
        }
        LogisticsTileGenericPipe pipe = null;
        for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
            DoubleCoordinates p = CoordinateUtils.add(new DoubleCoordinates(connected), direction);
            TileEntity canidate = p.getTileEntity(tile.getWorldObj());
            if (canidate instanceof LogisticsTileGenericPipe && MainProxy.checkPipesConnections(connected, canidate, direction)) {
                if (pipe != null) {
                    pipe = null;
                    break;
                } else {
                    pipe = (LogisticsTileGenericPipe) canidate;
                }
            }
        }
        if (pipe != null && pipe.pipe instanceof CoreRoutedPipe) {
            list.add(pipe);
        }
    }
    if (list.size() == 1) {
        return list;
    } else {
        return new ArrayList<>(0);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) ArrayList(java.util.ArrayList) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Aggregations

DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)70 TileEntity (net.minecraft.tileentity.TileEntity)44 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)21 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)15 ArrayList (java.util.ArrayList)14 LPPositionSet (logisticspipes.utils.LPPositionSet)10 Block (net.minecraft.block.Block)10 SideOnly (cpw.mods.fml.relauncher.SideOnly)8 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)8 ItemStack (net.minecraft.item.ItemStack)8 World (net.minecraft.world.World)8 LogisticsTileGenericSubMultiBlock (logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock)6 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)6 IIcon (net.minecraft.util.IIcon)6 DockingStation (buildcraft.api.robots.DockingStation)5 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)5 DoubleCoordinatesType (network.rs485.logisticspipes.world.DoubleCoordinatesType)5 EntityRobotBase (buildcraft.api.robots.EntityRobotBase)4 PipePluggable (buildcraft.api.transport.pluggable.PipePluggable)4 RobotStationPluggable (buildcraft.robotics.RobotStationPluggable)4