Search in sources :

Example 16 with Box

use of buildcraft.lib.misc.data.Box in project BuildCraft by BuildCraft.

the class BoxTester method testCenterExact.

@Test
public void testCenterExact() {
    Box box = new Box(MIN, MAX);
    TestHelper.assertVec3dEquals(CENTER_EXACT, box.centerExact());
}
Also used : Box(buildcraft.lib.misc.data.Box) Test(org.junit.Test)

Example 17 with Box

use of buildcraft.lib.misc.data.Box in project BuildCraft by BuildCraft.

the class TileBuilder method getRenderBoundingBox.

@Override
public AxisAlignedBB getRenderBoundingBox() {
    Box renderBox = new Box(this).extendToEncompass(box);
    for (LaserData l : pathLasers) {
        renderBox = renderBox.extendToEncompass(l.head);
        renderBox = renderBox.extendToEncompass(l.tail);
    }
    return renderBox.expand(50).getBoundingBox();
}
Also used : Box(buildcraft.lib.misc.data.Box) LaserData(buildcraft.core.LaserData)

Example 18 with Box

use of buildcraft.lib.misc.data.Box in project BuildCraft by BuildCraft.

the class TileQuarry method onPlacedBy.

@Override
public void onPlacedBy(EntityLivingBase placer, ItemStack stack) {
    super.onPlacedBy(placer, stack);
    if (placer.world.isRemote) {
        return;
    }
    EnumFacing facing = world.getBlockState(pos).getValue(BlockBCBase_Neptune.PROP_FACING);
    BlockPos areaPos = pos.offset(facing.getOpposite());
    TileEntity tile = world.getTileEntity(areaPos);
    BlockPos min = null, max = null;
    if (tile instanceof IAreaProvider) {
        IAreaProvider provider = (IAreaProvider) tile;
        min = provider.min();
        max = provider.max();
        int dx = max.getX() - min.getX();
        int dz = max.getZ() - min.getZ();
        if (dx < 3 || dz < 3) {
            min = null;
            max = null;
        } else {
            provider.removeFromWorld();
        }
    }
    // noinspection ConstantConditions
    if (min == null || max == null) {
        min = null;
        max = null;
        VolumeSubCache cache = VolumeCache.INSTANCE.getSubCache(getWorld());
        for (BlockPos markerPos : cache.getAllMarkers()) {
            TileMarkerVolume marker = (TileMarkerVolume) cache.getMarker(markerPos);
            if (marker == null) {
                continue;
            }
            VolumeConnection connection = marker.getCurrentConnection();
            if (connection == null) {
                continue;
            }
            Box volBox = connection.getBox();
            Box box2 = new Box();
            box2.initialize(volBox);
            if (!box2.isInitialized()) {
                continue;
            }
            if (pos.getY() != box2.min().getY()) {
                continue;
            }
            if (box2.contains(pos)) {
                continue;
            }
            if (!box2.contains(areaPos)) {
                continue;
            }
            if (box2.size().getX() < 3 || box2.size().getZ() < 3) {
                continue;
            }
            box2.expand(1);
            box2.setMin(box2.min().up());
            if (box2.isOnEdge(pos)) {
                min = volBox.min();
                max = volBox.max();
                marker.removeFromWorld();
                break;
            }
        }
    }
    if (min == null || max == null) {
        miningBox.reset();
        frameBox.reset();
        switch(facing.getOpposite()) {
            case DOWN:
            case UP:
            default:
            case // +X
            EAST:
                min = pos.add(1, 0, -5);
                max = pos.add(11, 4, 5);
                break;
            case // -X
            WEST:
                min = pos.add(-11, 0, -5);
                max = pos.add(-1, 4, 5);
                break;
            case // +Z
            SOUTH:
                min = pos.add(-5, 0, 1);
                max = pos.add(5, 4, 11);
                break;
            case // -Z
            NORTH:
                min = pos.add(-5, 0, -11);
                max = pos.add(5, 4, -1);
                break;
        }
    }
    if (max.getY() - min.getY() < 4) {
        max = new BlockPos(max.getX(), min.getY() + 4, max.getZ());
    }
    frameBox.reset();
    frameBox.setMin(min);
    frameBox.setMax(max);
    miningBox.reset();
    miningBox.setMin(new BlockPos(min.getX() + 1, 0, min.getZ() + 1));
    miningBox.setMax(new BlockPos(max.getX() - 1, max.getY() - 1, max.getZ() - 1));
    updatePoses();
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IAreaProvider(buildcraft.api.core.IAreaProvider) TileMarkerVolume(buildcraft.core.tile.TileMarkerVolume) VolumeConnection(buildcraft.core.marker.VolumeConnection) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) Box(buildcraft.lib.misc.data.Box) VolumeSubCache(buildcraft.core.marker.VolumeSubCache)

Example 19 with Box

use of buildcraft.lib.misc.data.Box in project BuildCraft by BuildCraft.

the class ItemMapLocation method getPointBox.

public static IBox getPointBox(@Nonnull ItemStack item) {
    NBTTagCompound cpt = NBTUtilBC.getItemData(item);
    MapLocationType type = MapLocationType.getFromStack(item);
    switch(type) {
        case SPOT:
            {
                int x = cpt.getInteger("x");
                int y = cpt.getInteger("y");
                int z = cpt.getInteger("z");
                BlockPos pos = new BlockPos(x, y, z);
                return new Box(pos, pos);
            }
        default:
            {
                return null;
            }
    }
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) BlockPos(net.minecraft.util.math.BlockPos) Box(buildcraft.lib.misc.data.Box) IBox(buildcraft.api.core.IBox)

Aggregations

Box (buildcraft.lib.misc.data.Box)19 BlockPos (net.minecraft.util.math.BlockPos)10 Test (org.junit.Test)9 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 IBox (buildcraft.api.core.IBox)2 VolumeConnection (buildcraft.core.marker.VolumeConnection)2 NBTUtilBC (buildcraft.lib.misc.NBTUtilBC)2 PacketBufferBC (buildcraft.lib.net.PacketBufferBC)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 NBTUtil (net.minecraft.nbt.NBTUtil)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 Vec3d (net.minecraft.util.math.Vec3d)2 World (net.minecraft.world.World)2 EnumPipePart (buildcraft.api.core.EnumPipePart)1 IAreaProvider (buildcraft.api.core.IAreaProvider)1 IPathProvider (buildcraft.api.core.IPathProvider)1 EnumOptionalSnapshotType (buildcraft.api.enums.EnumOptionalSnapshotType)1 EnumSnapshotType (buildcraft.api.enums.EnumSnapshotType)1