Search in sources :

Example 11 with Pos

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;
}
Also used : Pos(com.builtbroken.mc.lib.transform.vector.Pos)

Example 12 with Pos

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;
}
Also used : Pos(com.builtbroken.mc.lib.transform.vector.Pos) HashMap(java.util.HashMap) Pair(com.builtbroken.jlib.type.Pair)

Example 13 with Pos

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;
}
Also used : Pos(com.builtbroken.mc.lib.transform.vector.Pos)

Example 14 with Pos

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;
}
Also used : Pos(com.builtbroken.mc.lib.transform.vector.Pos)

Example 15 with Pos

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();
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileConductor(com.builtbroken.mc.prefab.tile.TileConductor) Pos(com.builtbroken.mc.lib.transform.vector.Pos) FakeWorld(com.builtbroken.mc.testing.junit.world.FakeWorld)

Aggregations

Pos (com.builtbroken.mc.lib.transform.vector.Pos)68 Block (net.minecraft.block.Block)11 TileEntity (net.minecraft.tileentity.TileEntity)8 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)8 FakeWorld (com.builtbroken.mc.testing.junit.world.FakeWorld)7 Cube (com.builtbroken.mc.lib.transform.region.Cube)6 Test (org.junit.Test)6 IPos3D (com.builtbroken.jlib.data.vector.IPos3D)5 BlockEdit (com.builtbroken.mc.lib.world.edit.BlockEdit)5 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 Vector3DistanceComparator (com.builtbroken.mc.lib.transform.sorting.Vector3DistanceComparator)4 BlockTile (com.builtbroken.mc.prefab.tile.BlockTile)4 Tile (com.builtbroken.mc.prefab.tile.Tile)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 World (net.minecraft.world.World)4 Pair (com.builtbroken.jlib.type.Pair)3 PacketTile (com.builtbroken.mc.core.network.packet.PacketTile)3 Quaternion (com.builtbroken.mc.lib.transform.rotation.Quaternion)3 AbstractTest (com.builtbroken.mc.testing.junit.AbstractTest)3