Search in sources :

Example 1 with Box

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

the class TileQuarry method createUtilsIfNeeded.

public void createUtilsIfNeeded() {
    if (!worldObj.isRemote) {
        if (builder == null) {
            if (!box.isInitialized()) {
                setBoundaries(loadDefaultBoundaries);
            }
            initializeBlueprintBuilder();
        }
    }
    if (getStage() != Stage.BUILDING) {
        box.isVisible = false;
        if (arm == null) {
            createArm();
        }
        if (miningBox == null || !miningBox.isInitialized()) {
            miningBox = new Box(box.min(), box.max());
            miningBox.contract(1);
            miningBox.setMin(VecUtil.replaceValue(miningBox.min(), Axis.Y, 0));
            miningBox.setMax(miningBox.max().add(0, 1, 0));
        }
        if (findTarget(false)) {
            AxisAlignedBB union = miningBox.getBoundingBox().union(box.getBoundingBox());
            if (!union.isVecInside(headPos)) {
                headPos = VecUtil.replaceValue(headPos, Axis.Y, (double) (miningBox.max().getY() - 2));
                BlockPos nearestPos = miningBox.closestInsideTo(Utils.convertFloor(headPos));
                headPos = Utils.convert(nearestPos);
            }
        }
    } else {
        box.isVisible = true;
    }
}
Also used : Box(buildcraft.lib.misc.data.Box)

Example 2 with Box

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

the class BoxTester method testMax.

@Test
public void testMax() {
    Box box = new Box(MIN, MAX);
    Assert.assertEquals(MAX, box.max());
}
Also used : Box(buildcraft.lib.misc.data.Box) Test(org.junit.Test)

Example 3 with Box

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

the class BoxTester method testIntersection1.

@Test
public void testIntersection1() {
    Box box1 = new Box(new BlockPos(0, 0, 0), new BlockPos(2, 2, 2));
    Box box2 = new Box(new BlockPos(1, 1, 1), new BlockPos(3, 3, 3));
    Box inter = new Box(new BlockPos(1, 1, 1), new BlockPos(2, 2, 2));
    Assert.assertEquals(inter, box1.getIntersect(box2));
    Assert.assertEquals(inter, box2.getIntersect(box1));
}
Also used : Box(buildcraft.lib.misc.data.Box) BlockPos(net.minecraft.util.math.BlockPos) Test(org.junit.Test)

Example 4 with Box

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

the class BoxTester method testContainsVec3d.

@Test
@Theory
public void testContainsVec3d(@FromDataPoints("testContainsVec3d") Entry<Vec3d, Boolean> entry) {
    Box box = new Box(MIN, MAX);
    Vec3d in = entry.getKey();
    boolean expected = entry.getValue();
    Assert.assertEquals(expected, box.contains(in));
}
Also used : Box(buildcraft.lib.misc.data.Box) Vec3d(net.minecraft.util.math.Vec3d) Test(org.junit.Test) Theory(org.junit.experimental.theories.Theory)

Example 5 with Box

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

the class RenderBoxProvider method renderTileEntityAt.

@Override
public void renderTileEntityAt(T tileentity, double x, double y, double z, float f, int anArgument) {
    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GlStateManager.enableCull();
    GlStateManager.disableLighting();
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glPushMatrix();
    GL11.glTranslated(-tileentity.getPos().getX(), -tileentity.getPos().getY(), -tileentity.getPos().getZ());
    GL11.glTranslated(x, y, z);
    if (tileentity instanceof IBoxesProvider) {
        for (Box b : ((IBoxesProvider) tileentity).getBoxes()) {
            if (b.isVisible) {
                RenderBox.doRender(TileEntityRendererDispatcher.instance.worldObj, Minecraft.getMinecraft().renderEngine, getTexture(b.kind), b);
            }
        }
    } else if (tileentity instanceof IBoxProvider) {
        Box b = ((IBoxProvider) tileentity).getBox();
        if (b.isVisible && b.isInitialized()) {
            RenderBox.doRender(TileEntityRendererDispatcher.instance.worldObj, Minecraft.getMinecraft().renderEngine, getTexture(b.kind), b);
        }
    }
    GL11.glPopMatrix();
    GL11.glPopAttrib();
    GL11.glPopMatrix();
}
Also used : IBoxesProvider(buildcraft.core.internal.IBoxesProvider) Box(buildcraft.lib.misc.data.Box) IBoxProvider(buildcraft.core.internal.IBoxProvider)

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