use of com.builtbroken.mc.lib.transform.vector.Pos in project Engine by VoltzEngine-Project.
the class Vector3DistanceComparator method compare.
@Override
public int compare(IPos3D o1, IPos3D o2) {
double d = new Pos(o1).distance(center);
double d2 = new Pos(o2).distance(center);
return d > d2 ? 1 : d == d2 ? 0 : -1;
}
use of com.builtbroken.mc.lib.transform.vector.Pos in project Engine by VoltzEngine-Project.
the class Schematic method getBox.
/**
* Creates a map of vectors in the shape of a square
*
* @param center - center to create the box around, controls offset for later if needed
* @param block - block to make the box out of
* @param meta - meta value of the block for placement
* @param sizeX - size from the center to the edge, half of the side
* @param sizeZ - size from the center to the edge, half of the side
* @return hash map of vectors to placement data
*/
public HashMap<Pos, Pair<Block, Integer>> getBox(final Pos center, Block block, int meta, int sizeX, int sizeZ) {
HashMap<Pos, Pair<Block, Integer>> returnMap = new HashMap();
// zero zero corner of the square
Pos start = new Pos(-sizeX, 0, -sizeZ).add(center);
if (sizeX != sizeZ) {
// X sides
for (int x = 0; x <= sizeX * 2; x++) {
returnMap.put(new Pos(x, 0, 0).add(start), new Pair<>(block, meta));
returnMap.put(new Pos(x, 0, sizeZ * 2).add(start), new Pair<>(block, meta));
}
// Z sides
for (int z = 0; z <= sizeZ * 2; z++) {
returnMap.put(new Pos(0, 0, z).add(start), new Pair<>(block, meta));
returnMap.put(new Pos(sizeX * 2, 0, z).add(start), new Pair<>(block, meta));
}
} else {
// All sides, used verses the other way as it cuts the time in half
for (int s = 0; s <= sizeX * 2; s++) {
returnMap.put(new Pos(s, 0, 0).add(start), new Pair<>(block, meta));
returnMap.put(new Pos(s, 0, sizeZ * 2).add(start), new Pair<>(block, meta));
returnMap.put(new Pos(0, 0, s).add(start), new Pair<>(block, meta));
returnMap.put(new Pos(sizeZ * 2, 0, s).add(start), new Pair<>(block, meta));
}
}
return returnMap;
}
use of com.builtbroken.mc.lib.transform.vector.Pos in project Engine by VoltzEngine-Project.
the class Cube method subtract.
public Cube subtract(double x, double y, double z) {
if (isValid()) {
pointOne = new Pos(pointOne.x() - x, pointOne.y() - y, pointOne.z() - z);
pointTwo = new Pos(pointTwo.x() - x, pointTwo.y() - y, pointTwo.z() - z);
recalc();
}
return this;
}
use of com.builtbroken.mc.lib.transform.vector.Pos in project Engine by VoltzEngine-Project.
the class Cube method cropToWorld.
/**
* Limits the cube to the world bounds
*
* @return this
*/
public Cube cropToWorld() {
Pos one = min();
Pos two = max();
if (min().y() < 0) {
one = new Pos(min().x(), 0, min().y());
}
if (max().y() > 255) {
two = new Pos(min().x(), 255, min().y());
}
set(one, two);
return this;
}
use of com.builtbroken.mc.lib.transform.vector.Pos in project Engine by VoltzEngine-Project.
the class BranchGridTest method setUpForTest.
@Override
public void setUpForTest(String name) {
// Create fake world to do actions in
world = new FakeWorld();
world.genFlatData();
// Set up wire grid
WireMap.WireTests.JUNCTION_FIVE.build(world, 0, 12, 0);
if (world.tiles.size() == 0) {
world.printLevel(12);
fail("No tiles were placed into the world");
}
world.updateEntities();
TileEntity tile = world.tiles.get(0);
if (tile instanceof TileConductor) {
grid = ((TileConductor) tile).getNode().getGrid();
} else {
System.out.println("Something went wrong building " + name + ".\n No tile was found to get grid from.");
for (TileEntity t : world.tiles) {
System.out.println("Tile: " + t + " Vec: " + new Pos(t));
}
fail();
}
// Trigger grid to update since we do not have a tick handler
grid.update();
}
Aggregations