Search in sources :

Example 36 with DoubleCoordinates

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

the class PipeItemsInvSysConnector method isConnectedInv.

public boolean isConnectedInv(TileEntity tile) {
    for (int i = 0; i < 6; i++) {
        ForgeDirection dir = ForgeDirection.values()[i];
        DoubleCoordinates p = CoordinateUtils.add(new DoubleCoordinates(this), dir);
        TileEntity lTile = p.getTileEntity(getWorld());
        if (lTile instanceof IInventory) {
            if (lTile == tile) {
                return this.container.canPipeConnect(lTile, dir);
            }
        }
    }
    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 37 with DoubleCoordinates

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

the class RoutingUpdateDebugClosedSet method readData.

@Override
public void readData(LPDataInput input) {
    set = input.readEnumSet(PipeRoutingConnectionType.class);
    pos = new DoubleCoordinates(input);
}
Also used : PipeRoutingConnectionType(logisticspipes.routing.PipeRoutingConnectionType) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 38 with DoubleCoordinates

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

the class LogisticsTileGenericSubMultiBlock method readFromNBT.

@Override
public void readFromNBT(NBTTagCompound nbt) {
    super.readFromNBT(nbt);
    if (nbt.hasKey("MainPipePos_xPos")) {
        mainPipePos.clear();
        DoubleCoordinates pos = DoubleCoordinates.readFromNBT("MainPipePos_", nbt);
        if (pos != null) {
            mainPipePos.add(pos);
        }
    }
    if (nbt.hasKey("MainPipePosList")) {
        NBTTagList list = nbt.getTagList("MainPipePosList", new NBTTagCompound().getId());
        for (int i = 0; i < list.tagCount(); i++) {
            DoubleCoordinates pos = DoubleCoordinates.readFromNBT("MainPipePos_", list.getCompoundTagAt(i));
            if (pos != null) {
                mainPipePos.add(pos);
            }
        }
    }
    if (nbt.hasKey("SubTypeList")) {
        NBTTagList list = nbt.getTagList("SubTypeList", new NBTTagString().getId());
        subTypes.clear();
        for (int i = 0; i < list.tagCount(); i++) {
            String name = list.getStringTagAt(i);
            CoreMultiBlockPipe.SubBlockTypeForShare type = CoreMultiBlockPipe.SubBlockTypeForShare.valueOf(name);
            if (type != null) {
                subTypes.add(type);
            }
        }
    }
    mainPipe = null;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NBTTagString(net.minecraft.nbt.NBTTagString) NBTTagString(net.minecraft.nbt.NBTTagString) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 39 with DoubleCoordinates

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

the class LPRobotConnectionControl method checkAll.

public void checkAll(World world) {
    if (!globalAvailableRobots.containsKey(world)) {
        return;
    }
    for (Pair<DoubleCoordinates, ForgeDirection> canidatePos : globalAvailableRobots.get(world)) {
        TileEntity connectedPipeTile = canidatePos.getValue1().getTileEntity(world);
        if (!(connectedPipeTile instanceof LogisticsTileGenericPipe)) {
            continue;
        }
        LogisticsTileGenericPipe connectedPipe = (LogisticsTileGenericPipe) connectedPipeTile;
        if (!connectedPipe.isRoutingPipe()) {
            continue;
        }
        PipePluggable connectedPluggable = ((TileGenericPipe) connectedPipe.tilePart.getOriginal()).getPipePluggable(canidatePos.getValue2());
        if (!(connectedPluggable instanceof RobotStationPluggable)) {
            continue;
        }
        DockingStation connectedStation = ((RobotStationPluggable) connectedPluggable).getStation();
        if (!connectedStation.isTaken()) {
            continue;
        }
        EntityRobotBase connectedRobot = connectedStation.robotTaking();
        if (connectedRobot == null) {
            continue;
        }
        if (!(connectedRobot.getBoard() instanceof LogisticsRoutingBoardRobot)) {
            continue;
        }
        LogisticsRoutingBoardRobot lpBoard = ((LogisticsRoutingBoardRobot) connectedRobot.getBoard());
        if (isModified(lpBoard)) {
            connectedPipe.getRoutingPipe().triggerConnectionCheck();
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) RobotStationPluggable(buildcraft.robotics.RobotStationPluggable) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) TileGenericPipe(buildcraft.transport.TileGenericPipe) DockingStation(buildcraft.api.robots.DockingStation) LogisticsRoutingBoardRobot(logisticspipes.proxy.buildcraft.robots.boards.LogisticsRoutingBoardRobot) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) PipePluggable(buildcraft.api.transport.pluggable.PipePluggable) EntityRobotBase(buildcraft.api.robots.EntityRobotBase) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 40 with DoubleCoordinates

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

the class LPRobotConnectionControl method isModified.

public boolean isModified(LogisticsRoutingBoardRobot board) {
    Set<Pair<DoubleCoordinates, ForgeDirection>> localConnectedRobots = new HashSet<>();
    DoubleCoordinates sourceRobotPosition = CoordinateUtils.add(board.getLinkedStationPosition().center(), board.robot.getLinkedStation().side(), 0.5);
    IZone zone = board.robot.getZoneToWork();
    for (Pair<DoubleCoordinates, ForgeDirection> canidatePos : globalAvailableRobots.get(board.robot.worldObj)) {
        DoubleCoordinates canidateRobotPosition = CoordinateUtils.add(new DoubleCoordinates(canidatePos.getValue1()).center(), canidatePos.getValue2(), 0.5);
        double distance = canidateRobotPosition.distanceTo(sourceRobotPosition);
        boolean isPartOfZone;
        if (zone != null) {
            isPartOfZone = zone.contains(canidateRobotPosition.getXCoord(), canidateRobotPosition.getYCoord(), canidateRobotPosition.getZCoord());
        } else {
            isPartOfZone = distance < Configs.MAX_ROBOT_DISTANCE;
        }
        if (isPartOfZone) {
            localConnectedRobots.add(canidatePos);
        }
    }
    if (board.getConnectionDetails().localConnectedRobots.equals(localConnectedRobots)) {
        return false;
    } else {
        board.getConnectionDetails().localConnectedRobots.clear();
        board.getConnectionDetails().localConnectedRobots.addAll(localConnectedRobots);
        return true;
    }
}
Also used : ForgeDirection(net.minecraftforge.common.util.ForgeDirection) IZone(buildcraft.api.core.IZone) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) HashSet(java.util.HashSet) Pair(logisticspipes.utils.tuples.Pair)

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