Search in sources :

Example 1 with TileConductor

use of com.builtbroken.mc.prefab.tile.TileConductor in project Engine by VoltzEngine-Project.

the class NodeConnectionTest method testAllSides.

//Full all side connection test
public void testAllSides() {
    buildFullWireSet();
    //Trigger connection building in the wire
    TileEntity tile = center.getTileEntity();
    if (tile instanceof TileConductor) {
        ((TileConductor) tile).getNode().buildConnections();
    }
    //Test connections
    assertNotNull("There should be a tile at Vec(8,8,8)", tile);
    if (tile instanceof TileConductor) {
        NodeBranchPart node = ((TileConductor) tile).getNode();
        assertNotNull("There should be a node at Vec(8,8,8)", node);
        if (node.getConnections().size() == 0)
            fail("Should be at least one connection");
        for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
            boolean found = false;
            for (Map.Entry<NodeBranchPart, ForgeDirection> entry : node.getConnections().entrySet()) {
                if (entry.getValue() == dir.getOpposite()) {
                    found = true;
                }
            }
            if (!found)
                fail("No " + dir + " connection found");
        }
    }
    //Clean up
    world.clear();
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileConductor(com.builtbroken.mc.prefab.tile.TileConductor) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) Map(java.util.Map) NodeBranchPart(com.builtbroken.mc.lib.grid.branch.NodeBranchPart)

Example 2 with TileConductor

use of com.builtbroken.mc.prefab.tile.TileConductor 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

TileConductor (com.builtbroken.mc.prefab.tile.TileConductor)2 TileEntity (net.minecraft.tileentity.TileEntity)2 NodeBranchPart (com.builtbroken.mc.lib.grid.branch.NodeBranchPart)1 Pos (com.builtbroken.mc.lib.transform.vector.Pos)1 FakeWorld (com.builtbroken.mc.testing.junit.world.FakeWorld)1 Map (java.util.Map)1 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)1