use of com.builtbroken.mc.lib.transform.vector.Pos in project Engine by VoltzEngine-Project.
the class InventoryUtility method dropBlockAsItem.
/**
* Attempts to drop the block at the location as an item. Does not check what the block is
* and can fail if the block doesn't contain items.
*
* @param world
* @param x
* @param y
* @param z
* @param destroy - will break the block
*/
public static void dropBlockAsItem(World world, int x, int y, int z, boolean destroy) {
if (!world.isRemote) {
Block block = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
if (block != null) {
ArrayList<ItemStack> items = block.getDrops(world, x, y, z, meta, 0);
for (ItemStack itemStack : items) {
dropItemStack(world, new Pos(x, y, z), itemStack, 10);
}
}
if (destroy) {
world.setBlockToAir(x, y, z);
}
}
}
use of com.builtbroken.mc.lib.transform.vector.Pos in project Engine by VoltzEngine-Project.
the class TestAbstractLocation method testToPos.
/**
* Tests {@link AbstractLocation#toPos()
*/
public void testToPos() {
TLocation location = new TLocation(world, 20, 10, 10);
Pos pos = location.toPos();
assertTrue(pos.equals(new Pos(20, 10, 10)));
}
use of com.builtbroken.mc.lib.transform.vector.Pos in project Engine by VoltzEngine-Project.
the class AbstractTileEntityTest method testGetDistanceFrom.
@Test
public void testGetDistanceFrom() {
T tile = newTile();
FakeWorld world = FakeWorld.newWorld("testGetDistanceFrom");
tile.setWorldObj(world);
double distance = tile.getDistanceFrom(10, 14, 15);
double distance2 = new Pos(0.5).sub(10, 14, 15).magnitudeSquared();
assertTrue("Distance = " + distance + " Distance2 = " + distance2, Math.abs(distance - distance2) < .01);
}
use of com.builtbroken.mc.lib.transform.vector.Pos in project Engine by VoltzEngine-Project.
the class CuboidTest method testCollisionOverlap.
public void testCollisionOverlap() {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
Pos vec = new Pos(dir).multiply(0.3);
Cube c = cube.add(vec);
if (!cube.doesOverlap(c)) {
System.out.println("Cube: " + cube);
System.out.println("Above: " + c.toString());
assertEquals("x check failed", cube.isOutSideX(c.min().x(), c.max().x()), dir == ForgeDirection.EAST || dir == ForgeDirection.WEST);
assertEquals("y check failed", cube.isOutSideY(c.min().y(), c.max().y()), dir == ForgeDirection.DOWN || dir == ForgeDirection.UP);
assertEquals("z check failed", cube.isOutSideZ(c.min().z(), c.max().z()), dir == ForgeDirection.NORTH || dir == ForgeDirection.SOUTH);
fail("Didn't collide for side " + dir);
}
}
}
use of com.builtbroken.mc.lib.transform.vector.Pos in project Engine by VoltzEngine-Project.
the class CuboidTest method testInsideBounds.
public void testInsideBounds() {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
Cube above = cube.clone();
assertEquals("Failed center collision check for side " + dir, true, cube.isInsideBounds(above));
above = above.add(new Pos(dir));
assertEquals("Failed collision check one for side " + dir, false, cube.isInsideBounds(above));
above = above.add(new Pos(dir));
assertEquals("Failed collision check two for side " + dir, false, cube.isInsideBounds(above));
}
}
Aggregations