Search in sources :

Example 51 with DoubleCoordinates

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

the class HSTubeGain method getConnectedEndTile.

@Override
public TileEntity getConnectedEndTile(ForgeDirection output) {
    if (orientation.dir.getOpposite() == output) {
        return container.getTile(output);
    } else {
        DoubleCoordinates pos = new DoubleCoordinates(0, 1, -3);
        LPPositionSet<DoubleCoordinates> set = new LPPositionSet<>(DoubleCoordinates.class);
        set.add(pos);
        orientation.rotatePositions(set);
        TileEntity subTile = pos.add(getLPPosition()).getTileEntity(getWorld());
        if (subTile instanceof LogisticsTileGenericSubMultiBlock) {
            return ((LogisticsTileGenericSubMultiBlock) subTile).getTile(output);
        }
    }
    return null;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) LPPositionSet(logisticspipes.utils.LPPositionSet) LogisticsTileGenericSubMultiBlock(logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 52 with DoubleCoordinates

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

the class HSTubeGain method addCollisionBoxesToList.

@Override
public void addCollisionBoxesToList(List arraylist, AxisAlignedBB axisalignedbb) {
    if (boxes == null || boxes.isEmpty()) {
        boxes = new ArrayList<>();
        double x = getX();
        double y = getY();
        double z = getZ();
        for (int i = -1; i < 54; i++) {
            double xOne = x;
            double yOne = y;
            double zOne = z;
            double xTwo = x;
            double yTwo = y + 2;
            double zTwo = z;
            if (orientation.getRenderOrientation() == TubeGainRenderOrientation.SOUTH) {
                zOne += 4.0F * (i - 4) / 50;
                zTwo += 4.0F * (i + 4) / 50;
                xOne += 1;
                xTwo -= 2;
            } else if (orientation.getRenderOrientation() == TubeGainRenderOrientation.WEST) {
                xOne -= 3;
                xTwo -= 3;
                xOne += 4.0F * (i - 4) / 50;
                xTwo += 4.0F * (i + 4) / 50;
                zOne -= 1;
                zTwo += 2;
            } else if (orientation.getRenderOrientation() == TubeGainRenderOrientation.NORTH) {
                zOne += 1;
                zTwo += 1;
                zOne -= 4.0F * (i - 4) / 50;
                zTwo -= 4.0F * (i + 4) / 50;
                xOne -= 1;
                xTwo += 2;
            } else if (orientation.getRenderOrientation() == TubeGainRenderOrientation.EAST) {
                xOne += 4;
                xTwo += 4;
                xOne -= 4.0F * (i - 4) / 50;
                xTwo -= 4.0F * (i + 4) / 50;
                zOne -= 1;
                zTwo += 2;
            }
            AxisAlignedBB box = GainTubeRenderer.getObjectBoundsAt(AxisAlignedBB.getBoundingBox(Math.min(xOne, xTwo), Math.min(yOne, yTwo), Math.min(zOne, zTwo), Math.max(xOne, xTwo), Math.max(yOne, yTwo), Math.max(zOne, zTwo)).getOffsetBoundingBox(-x, -y, -z), orientation);
            if (box != null) {
                LPPositionSet<DoubleCoordinates> lpBox = new LPPositionSet<>(DoubleCoordinates.class);
                lpBox.addFrom(box);
                DoubleCoordinates center = lpBox.getCenter();
                box = AxisAlignedBB.getBoundingBox(center.getXCoord() - 0.3D, center.getYCoord() - 0.3D, center.getZCoord() - 0.3D, center.getXCoord() + 0.3D, center.getYCoord() + 0.3D, center.getZCoord() + 0.3D);
                if (box != null) {
                    AxisAlignedBB cBox = getCompleteBox();
                    if (box.minX < cBox.minX) {
                        box.minX = cBox.minX;
                    }
                    if (box.minY < cBox.minY) {
                        box.minY = cBox.minY;
                    }
                    if (box.minZ < cBox.minZ) {
                        box.minZ = cBox.minZ;
                    }
                    if (box.maxX > cBox.maxX) {
                        box.maxX = cBox.maxX;
                    }
                    if (box.maxY > cBox.maxY) {
                        box.maxY = cBox.maxY;
                    }
                    if (box.maxZ > cBox.maxZ) {
                        box.maxZ = cBox.maxZ;
                    }
                    box = box.getOffsetBoundingBox(x, y, z);
                    boxes.add(box);
                }
            }
        }
    }
    arraylist.addAll(boxes.stream().filter(box -> box != null && (axisalignedbb == null || axisalignedbb.intersectsWith(box))).collect(Collectors.toList()));
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) LPPositionSet(logisticspipes.utils.LPPositionSet) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 53 with DoubleCoordinates

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

the class HSTubeSCurve method addCollisionBoxesToList.

@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings({ "unchecked", "rawtypes" })
public void addCollisionBoxesToList(List arraylist, AxisAlignedBB axisalignedbb) {
    if (boxes == null || boxes.isEmpty()) {
        boxes = new ArrayList<>();
        double x = getX();
        double y = getY();
        double z = getZ();
        for (int i = -1; i < 54; i++) {
            double xOne = x;
            double yOne = y;
            double zOne = z;
            double xTwo = x;
            double yTwo = y + 1;
            double zTwo = z;
            if (orientation.getRenderOrientation() == TurnSDirection.NORTH_INV || orientation.getRenderOrientation() == TurnSDirection.NORTH) {
                zOne += 1;
                zTwo += 1;
                zOne -= 4.0F * (i - 4) / 50;
                zTwo -= 4.0F * (i + 4) / 50;
                xOne -= 1;
                xTwo += 2;
            } else if (orientation.getRenderOrientation() == TurnSDirection.EAST_INV || orientation.getRenderOrientation() == TurnSDirection.EAST) {
                xOne += 4;
                xTwo += 4;
                xOne -= 4.0F * (i - 4) / 50;
                xTwo -= 4.0F * (i + 4) / 50;
                zOne -= 1;
                zTwo += 2;
            }
            AxisAlignedBB box = SCurveTubeRenderer.getObjectBoundsAt(AxisAlignedBB.getBoundingBox(Math.min(xOne, xTwo), Math.min(yOne, yTwo), Math.min(zOne, zTwo), Math.max(xOne, xTwo), Math.max(yOne, yTwo), Math.max(zOne, zTwo)).getOffsetBoundingBox(-x, -y, -z), orientation);
            if (box != null) {
                LPPositionSet<DoubleCoordinates> lpBox = new LPPositionSet<>(DoubleCoordinates.class);
                lpBox.addFrom(box);
                DoubleCoordinates center = lpBox.getCenter();
                box = AxisAlignedBB.getBoundingBox(center.getXCoord() - 0.3D, center.getYCoord() - 0.3D, center.getZCoord() - 0.3D, center.getXCoord() + 0.3D, center.getYCoord() + 0.3D, center.getZCoord() + 0.3D);
                if (box != null) {
                    AxisAlignedBB cBox = getCompleteBox();
                    if (box.minX < cBox.minX) {
                        box.minX = cBox.minX;
                    }
                    if (box.minY < cBox.minY) {
                        box.minY = cBox.minY;
                    }
                    if (box.minZ < cBox.minZ) {
                        box.minZ = cBox.minZ;
                    }
                    if (box.maxX > cBox.maxX) {
                        box.maxX = cBox.maxX;
                    }
                    if (box.maxY > cBox.maxY) {
                        box.maxY = cBox.maxY;
                    }
                    if (box.maxZ > cBox.maxZ) {
                        box.maxZ = cBox.maxZ;
                    }
                    box = box.getOffsetBoundingBox(x, y, z);
                    boxes.add(box);
                }
            }
        }
    }
    arraylist.addAll(boxes.stream().filter(box -> box != null && (axisalignedbb == null || axisalignedbb.intersectsWith(box))).collect(Collectors.toList()));
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) LPPositionSet(logisticspipes.utils.LPPositionSet) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 54 with DoubleCoordinates

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

the class PipeItemsSatelliteLogistics method getRawInventory.

private IInventory getRawInventory(ForgeDirection dir) {
    DoubleCoordinates pos = CoordinateUtils.add(new DoubleCoordinates(this), dir);
    TileEntity tile = pos.getTileEntity(getWorld());
    if (SimpleServiceLocator.pipeInformationManager.isItemPipe(tile)) {
        return null;
    }
    if (!(tile instanceof IInventory)) {
        return null;
    }
    return InventoryHelper.getInventory((IInventory) tile);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IInventory(net.minecraft.inventory.IInventory) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 55 with DoubleCoordinates

use of network.rs485.logisticspipes.world.DoubleCoordinates 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)

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