use of com.builtbroken.mc.lib.transform.vector.Pos in project Engine by VoltzEngine-Project.
the class TestBlockEdit method testHashCode.
@Test
public void testHashCode() {
World world = FakeWorld.newWorld("BlockEditTest");
World world2 = FakeWorld.newWorld("BlockEditTest2");
BlockEdit location = new BlockEdit(world, 0, 0, 0);
BlockEdit location2 = new BlockEdit(world, 0, 0, 0);
// Test would equals
Assert.assertEquals("BlockEdit one should equal itself", location.hashCode(), location.hashCode());
Assert.assertEquals("BlockEdit two should equal itself", location2.hashCode(), location2.hashCode());
Assert.assertEquals("BlockEdit one & two should equal each other", location.hashCode(), location2.hashCode());
location2 = new BlockEdit(world2, 0, 0, 0);
// Test world not equal
Assert.assertNotSame("BlockEdit one & two should not equal each other", location.hashCode(), location2.hashCode());
location = new BlockEdit(world, 0, 1, 0);
// Test pos not equal
Assert.assertNotSame("BlockEdit one & two should not equal each other", location.hashCode(), location2.hashCode());
// Test decimal point
for (Pos pos : new Pos[] { new Pos(1, 2.0, 3.0f), new Pos(1, 2.2, 3.1f), new Pos(1.5125412, 2.2223, 3.0f), new Pos(1.231, 2.45454, 3.23213f) }) {
location = new BlockEdit(world, pos.x(), pos.y(), pos.z());
location2 = new BlockEdit(world, pos.x(), pos.y(), pos.z());
// Test would equals
Assert.assertEquals("BlockEdit one should equal itself", location.hashCode(), location.hashCode());
Assert.assertEquals("BlockEdit two should equal itself", location2.hashCode(), location2.hashCode());
Assert.assertEquals("BlockEdit one & two should equal each other", location.hashCode(), location2.hashCode());
}
location = new BlockEdit(world, 1, 2, 3);
location2 = new BlockEdit(world, 1.3, 2.2, 3.4);
// Test would equals
Assert.assertEquals("BlockEdit one should equal itself", location.hashCode(), location.hashCode());
Assert.assertEquals("BlockEdit two should equal itself", location2.hashCode(), location2.hashCode());
Assert.assertEquals("BlockEdit one & two should equal each other", location.hashCode(), location2.hashCode());
}
use of com.builtbroken.mc.lib.transform.vector.Pos in project Engine by VoltzEngine-Project.
the class TestBlockEdit method testEquals.
@Test
public void testEquals() {
World world = FakeWorld.newWorld("BlockEditTest");
World world2 = FakeWorld.newWorld("BlockEditTest2");
BlockEdit location = new BlockEdit(world, 0, 0, 0);
BlockEdit location2 = new BlockEdit(world, 0, 0, 0);
// Test would equals
Assert.assertEquals("BlockEdit one should equal itself", location, location);
Assert.assertEquals("BlockEdit two should equal itself", location2, location2);
Assert.assertEquals("BlockEdit one & two should equal each other", location, location2);
location2 = new BlockEdit(world2, 0, 0, 0);
// Test world not equal
Assert.assertNotSame("BlockEdit one & two should not equal each other", location, location2);
location = new BlockEdit(world, 0, 1, 0);
// Test pos not equal
Assert.assertNotSame("BlockEdit one & two should not equal each other", location, location2);
// Test decimal point
for (Pos pos : new Pos[] { new Pos(1, 2.0, 3.0f), new Pos(1, 2.2, 3.1f), new Pos(1.5125412, 2.2223, 3.0f), new Pos(1.231, 2.45454, 3.23213f) }) {
location = new BlockEdit(world, pos.x(), pos.y(), pos.z());
location2 = new BlockEdit(world, pos.x(), pos.y(), pos.z());
// Test would equals
Assert.assertEquals("BlockEdit one should equal itself", location, location);
Assert.assertEquals("BlockEdit two should equal itself", location2, location2);
Assert.assertEquals("BlockEdit one & two should equal each other", location, location2);
}
location = new BlockEdit(world, 1, 2, 3);
location2 = new BlockEdit(world, 1.3, 2.2, 3.4);
// Test would equals
Assert.assertEquals("BlockEdit one should equal itself", location, location);
Assert.assertEquals("BlockEdit two should equal itself", location2, location2);
Assert.assertEquals("BlockEdit one & two should equal each other", location, location2);
}
use of com.builtbroken.mc.lib.transform.vector.Pos in project Engine by VoltzEngine-Project.
the class BlockTile method onNeighborChange.
@Override
public void onNeighborChange(IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ) {
if (!(world instanceof World) || !((World) world).isRemote) {
Tile tile = inject(world, x, y, z);
tile.onNeighborChanged(new Pos(tileX, tileY, tileZ));
eject();
}
}
use of com.builtbroken.mc.lib.transform.vector.Pos in project Engine by VoltzEngine-Project.
the class BlockTile method addCollisionBoxesToList.
@Override
@SuppressWarnings("unchecked")
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity entity) {
Tile tile = inject(world, x, y, z);
Iterable<Cube> bounds = tile.getCollisionBoxes(new Cube(aabb).subtract(new Pos(x, y, z)), entity);
eject();
if (bounds != null) {
for (Cube cuboid : bounds) {
AxisAlignedBB bb = cuboid.toAABB().offset(x, y, z);
if (aabb.intersectsWith(bb)) {
list.add(bb);
}
}
}
}
use of com.builtbroken.mc.lib.transform.vector.Pos in project Engine by VoltzEngine-Project.
the class CuboidTest method testCollisionCorners.
public void testCollisionCorners() {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
for (int side = 0; side < 4; side++) {
Pos vec = new Pos(dir).multiply(0.3);
switch(dir) {
case DOWN:
case UP:
switch(side) {
case 0:
vec.add(0.3, 0, 0.3);
break;
case 1:
vec.add(-0.3, 0, 0.3);
break;
case 2:
vec.add(0.3, 0, -0.3);
break;
case 3:
vec.add(-0.3, 0, -0.3);
break;
}
case NORTH:
case SOUTH:
switch(side) {
case 0:
vec.add(0.3, 0.3, 0);
break;
case 1:
vec.add(-0.3, 0.3, 0);
break;
case 2:
vec.add(0.3, -0.3, 0);
break;
case 3:
vec.add(-0.3, -0.3, 0);
break;
}
break;
case WEST:
case EAST:
switch(side) {
case 0:
vec.add(0, 0.3, 0.3);
break;
case 1:
vec.add(0, -0.3, 0.3);
break;
case 2:
vec.add(0, 0.3, -0.3);
break;
case 3:
vec.add(0, -0.3, -0.3);
break;
}
break;
}
Cube c = cube.clone().add(vec);
if (!cube.doesOverlap(c)) {
System.out.println("Cube: " + cube);
System.out.println("Above: " + c.toString());
System.out.println("Is outside X limits -> " + cube.isOutSideX(c.min().x(), c.max().x()));
System.out.println("Is outside Y limits -> " + cube.isOutSideY(c.min().y(), c.max().y()));
System.out.println("Is outside Z limits -> " + cube.isOutSideZ(c.min().z(), c.max().z()));
fail("Didn't collide for side " + dir + " and corner " + side);
}
}
}
}
Aggregations