use of com.builtbroken.mc.imp.transform.region.Cube in project ICBM-Classic by BuiltBrokenModding.
the class BlastRepulsive method pushEntities.
public void pushEntities(float radius, float force, int type) {
// Step 2: Damage all entities
Pos minCoord = position.toPos();
minCoord = minCoord.add(-radius - 1);
Pos maxCoord = position.toPos();
maxCoord = maxCoord.add(radius + 1);
Cube region = new Cube(minCoord, maxCoord);
List<Entity> entities = region.getEntities(this.world(), Entity.class);
for (Entity entity : entities) {
double var13 = entity.getDistance(position.x(), position.y(), position.z()) / radius;
if (var13 <= 1.0D) {
double xDifference = entity.posX - position.x();
double yDifference = entity.posY - position.y();
double zDifference = entity.posZ - position.z();
double distance = MathHelper.sqrt_double(xDifference * xDifference + yDifference * yDifference + zDifference * zDifference);
xDifference /= distance;
yDifference /= distance;
zDifference /= distance;
if (type == 1) {
double modifier = var13 * force * (entity instanceof EntityPlayer ? 0.5 : 1);
entity.addVelocity(-xDifference * modifier, -yDifference * modifier, -zDifference * modifier);
} else if (type == 2) {
double modifier = (1.0D - var13) * force * (entity instanceof EntityPlayer ? 0.5 : 1);
entity.addVelocity(xDifference * modifier, yDifference * modifier, zDifference * modifier);
}
}
}
}
use of com.builtbroken.mc.imp.transform.region.Cube in project Engine by VoltzEngine-Project.
the class PacketSelectionData method encodeInto.
@Override
public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
//Write player's selection
selection.writeBytes(buffer);
//Write cubes
buffer.writeInt(cubes.size());
for (Cube cube : cubes) {
cube.writeBytes(buffer);
}
//Write regions
buffer.writeInt(regions.size());
for (Cube cube : regions) {
cube.writeBytes(buffer);
}
}
use of com.builtbroken.mc.imp.transform.region.Cube in project Engine by VoltzEngine-Project.
the class AbstractTileTest method testGetCollisionBoxes.
@Test
public void testGetCollisionBoxes() {
FakeWorld world = FakeWorld.newWorld("TestGetCollisionBoxes");
world.setBlock(0, 0, 0, block);
Tile tile = ((Tile) world.getTileEntity(0, 0, 0));
Iterable<Cube> cubes = tile.getCollisionBoxes(new Cube(-2, -2, -2, 2, 2, 2), player);
assertTrue(cubes != null);
for (Cube cube : cubes) {
assertTrue(cube != null);
//TODO check if the cube is valid
}
}
use of com.builtbroken.mc.imp.transform.region.Cube 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.imp.transform.region.Cube 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