Search in sources :

Example 11 with Coordinate

use of mcjty.lib.varia.Coordinate in project RFTools by McJty.

the class BuilderTileEntity method nextLocationQuarry.

private void nextLocationQuarry(int x, int y, int z) {
    if (x >= maxBox.getX() || ((x + 1) % 16 == 0)) {
        if (z >= maxBox.getZ() || ((z + 1) % 16 == 0)) {
            if (y <= minBox.getY()) {
                if (x < maxBox.getX()) {
                    x++;
                    z = (z >> 4) << 4;
                    y = maxBox.getY();
                    scan = new Coordinate(x, y, z);
                } else if (z < maxBox.getZ()) {
                    x = minBox.getX();
                    z++;
                    y = maxBox.getY();
                    scan = new Coordinate(x, y, z);
                } else {
                    restartScan();
                }
            } else {
                scan = new Coordinate((x >> 4) << 4, y - 1, (z >> 4) << 4);
            }
        } else {
            scan = new Coordinate((x >> 4) << 4, y, z + 1);
        }
    } else {
        scan = new Coordinate(x + 1, y, z);
    }
}
Also used : Coordinate(mcjty.lib.varia.Coordinate)

Example 12 with Coordinate

use of mcjty.lib.varia.Coordinate in project RFTools by McJty.

the class BuilderTileEntity method createProjection.

private void createProjection(SpaceChamberRepository.SpaceChamberChannel chamberChannel) {
    Coordinate minC = rotate(chamberChannel.getMinCorner());
    Coordinate maxC = rotate(chamberChannel.getMaxCorner());
    Coordinate minCorner = new Coordinate(Math.min(minC.getX(), maxC.getX()), Math.min(minC.getY(), maxC.getY()), Math.min(minC.getZ(), maxC.getZ()));
    Coordinate maxCorner = new Coordinate(Math.max(minC.getX(), maxC.getX()), Math.max(minC.getY(), maxC.getY()), Math.max(minC.getZ(), maxC.getZ()));
    int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
    ForgeDirection direction = BlockTools.getOrientationHoriz(meta);
    int spanX = maxCorner.getX() - minCorner.getX();
    int spanY = maxCorner.getY() - minCorner.getY();
    int spanZ = maxCorner.getZ() - minCorner.getZ();
    switch(direction) {
        case SOUTH:
            projDx = xCoord + ForgeDirection.NORTH.offsetX - minCorner.getX() - ((anchor == ANCHOR_NE || anchor == ANCHOR_SE) ? spanX : 0);
            projDz = zCoord + ForgeDirection.NORTH.offsetZ - minCorner.getZ() - spanZ;
            break;
        case NORTH:
            projDx = xCoord + ForgeDirection.SOUTH.offsetX - minCorner.getX() - spanX + ((anchor == ANCHOR_NE || anchor == ANCHOR_SE) ? spanX : 0);
            projDz = zCoord + ForgeDirection.SOUTH.offsetZ - minCorner.getZ();
            break;
        case WEST:
            projDx = xCoord + ForgeDirection.EAST.offsetX - minCorner.getX();
            projDz = zCoord + ForgeDirection.EAST.offsetZ - minCorner.getZ() - ((anchor == ANCHOR_NE || anchor == ANCHOR_SE) ? spanZ : 0);
            break;
        case EAST:
            projDx = xCoord + ForgeDirection.WEST.offsetX - minCorner.getX() - spanX;
            projDz = zCoord + ForgeDirection.WEST.offsetZ - minCorner.getZ() - spanZ + ((anchor == ANCHOR_NE || anchor == ANCHOR_SE) ? spanZ : 0);
            break;
        case DOWN:
        case UP:
        case UNKNOWN:
            break;
    }
    projDy = yCoord - minCorner.getY() - ((anchor == ANCHOR_NE || anchor == ANCHOR_NW) ? spanY : 0);
}
Also used : Coordinate(mcjty.lib.varia.Coordinate) ForgeDirection(net.minecraftforge.common.util.ForgeDirection)

Example 13 with Coordinate

use of mcjty.lib.varia.Coordinate in project RFTools by McJty.

the class BuilderTileEntity method clearSupportBlocksShaped.

private void clearSupportBlocksShaped() {
    ItemStack shapeCard = inventoryHelper.getStackInSlot(BuilderContainer.SLOT_TAB);
    Coordinate dimension = ShapeCardItem.getClampedDimension(shapeCard, SpaceProjectorConfiguration.maxBuilderDimension);
    Coordinate offset = ShapeCardItem.getClampedOffset(shapeCard, SpaceProjectorConfiguration.maxBuilderOffset);
    ShapeCardItem.Shape shape = ShapeCardItem.getShape(shapeCard);
    List<Coordinate> blocks = new ArrayList<Coordinate>();
    ShapeCardItem.composeShape(shape.makeHollow(), worldObj, getCoordinate(), dimension, offset, blocks, SpaceProjectorConfiguration.maxSpaceChamberDimension * SpaceProjectorConfiguration.maxSpaceChamberDimension * SpaceProjectorConfiguration.maxSpaceChamberDimension, false, null);
    for (Coordinate block : blocks) {
        if (worldObj.getBlock(block.getX(), block.getY(), block.getZ()) == SpaceProjectorSetup.supportBlock) {
            worldObj.setBlockToAir(block.getX(), block.getY(), block.getZ());
        }
    }
}
Also used : ShapeCardItem(mcjty.rftools.items.shapecard.ShapeCardItem) Coordinate(mcjty.lib.varia.Coordinate) ItemStack(net.minecraft.item.ItemStack)

Example 14 with Coordinate

use of mcjty.lib.varia.Coordinate in project RFTools by McJty.

the class BuilderTileEntity method clearSupportBlocks.

public void clearSupportBlocks() {
    if (worldObj.isRemote) {
        // Don't do anything on the client.
        return;
    }
    if (isShapeCard()) {
        clearSupportBlocksShaped();
        return;
    }
    SpaceChamberRepository.SpaceChamberChannel chamberChannel = calculateBox();
    if (chamberChannel != null) {
        int dimension = chamberChannel.getDimension();
        World world = DimensionManager.getWorld(dimension);
        for (int x = minBox.getX(); x <= maxBox.getX(); x++) {
            for (int y = minBox.getY(); y <= maxBox.getY(); y++) {
                for (int z = minBox.getZ(); z <= maxBox.getZ(); z++) {
                    Coordinate src = new Coordinate(x, y, z);
                    if (world != null) {
                        Block srcBlock = world.getBlock(src.getX(), src.getY(), src.getZ());
                        if (srcBlock == SpaceProjectorSetup.supportBlock) {
                            world.setBlockToAir(src.getX(), src.getY(), src.getZ());
                        }
                    }
                    Coordinate dest = sourceToDest(src);
                    Block dstBlock = worldObj.getBlock(dest.getX(), dest.getY(), dest.getZ());
                    if (dstBlock == SpaceProjectorSetup.supportBlock) {
                        worldObj.setBlockToAir(dest.getX(), dest.getY(), dest.getZ());
                    }
                }
            }
        }
    }
}
Also used : Coordinate(mcjty.lib.varia.Coordinate) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) World(net.minecraft.world.World)

Example 15 with Coordinate

use of mcjty.lib.varia.Coordinate in project RFTools by McJty.

the class BuilderTileEntity method calculateBoxShaped.

private void calculateBoxShaped() {
    ItemStack shapeCard = inventoryHelper.getStackInSlot(BuilderContainer.SLOT_TAB);
    if (shapeCard == null) {
        return;
    }
    Coordinate dimension = ShapeCardItem.getClampedDimension(shapeCard, SpaceProjectorConfiguration.maxBuilderDimension);
    Coordinate offset = ShapeCardItem.getClampedOffset(shapeCard, SpaceProjectorConfiguration.maxBuilderOffset);
    Coordinate minCorner = ShapeCardItem.getMinCorner(getCoordinate(), dimension, offset);
    Coordinate maxCorner = ShapeCardItem.getMaxCorner(getCoordinate(), dimension, offset);
    if (minCorner.getY() < 0) {
        minCorner = new Coordinate(minCorner.getX(), 0, minCorner.getZ());
    } else if (minCorner.getY() > 255) {
        minCorner = new Coordinate(minCorner.getX(), 255, minCorner.getZ());
    }
    if (maxCorner.getY() < 0) {
        maxCorner = new Coordinate(maxCorner.getX(), 0, maxCorner.getZ());
    } else if (maxCorner.getY() > 255) {
        maxCorner = new Coordinate(maxCorner.getX(), 255, maxCorner.getZ());
    }
    if (boxValid) {
        // Double check if the box is indeed still valid.
        if (minCorner.equals(minBox) && maxCorner.equals(maxBox)) {
            return;
        }
    }
    boxValid = true;
    cardType = shapeCard.getItemDamage();
    cachedBlocks = null;
    cachedChunk = null;
    cachedVoidableBlocks = null;
    minBox = minCorner;
    maxBox = maxCorner;
    restartScan();
}
Also used : Coordinate(mcjty.lib.varia.Coordinate) ItemStack(net.minecraft.item.ItemStack)

Aggregations

Coordinate (mcjty.lib.varia.Coordinate)181 GlobalCoordinate (mcjty.lib.varia.GlobalCoordinate)63 TileEntity (net.minecraft.tileentity.TileEntity)30 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)19 Block (net.minecraft.block.Block)14 HashMap (java.util.HashMap)13 Map (java.util.Map)13 GenericEnergyReceiverTileEntity (mcjty.lib.entity.GenericEnergyReceiverTileEntity)13 World (net.minecraft.world.World)12 NBTTagList (net.minecraft.nbt.NBTTagList)11 Callback (li.cil.oc.api.machine.Callback)10 HorizontalLayout (mcjty.lib.gui.layout.HorizontalLayout)10 Panel (mcjty.lib.gui.widgets.Panel)10 ItemStack (net.minecraft.item.ItemStack)10 ArrayList (java.util.ArrayList)9 Label (mcjty.lib.gui.widgets.Label)8 BlockInfo (mcjty.rftools.BlockInfo)7 SyncedCoordinate (mcjty.lib.entity.SyncedCoordinate)5 ChoiceEvent (mcjty.lib.gui.events.ChoiceEvent)4 TeleportDestinationClientInfo (mcjty.rftools.blocks.teleporter.TeleportDestinationClientInfo)4