Search in sources :

Example 1 with NodeBranchPart

use of com.builtbroken.mc.lib.grid.branch.NodeBranchPart 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 NodeBranchPart

use of com.builtbroken.mc.lib.grid.branch.NodeBranchPart in project Engine by VoltzEngine-Project.

the class Part method _join.

protected Part _join(Part part) {
    if (part != this) {
        for (NodeBranchPart node : part.getEcapsulatedNodes()) {
            add(node);
        }
        for (Part p : part.getEcapsulatedParts()) {
            add(p);
        }
        //Cleanup
        part.getEcapsulatedNodes().clear();
        part.getEcapsulatedParts().clear();
        return this;
    }
    return null;
}
Also used : NodeBranchPart(com.builtbroken.mc.lib.grid.branch.NodeBranchPart) NodeBranchPart(com.builtbroken.mc.lib.grid.branch.NodeBranchPart)

Example 3 with NodeBranchPart

use of com.builtbroken.mc.lib.grid.branch.NodeBranchPart in project Engine by VoltzEngine-Project.

the class NodeConnectionTest method testForNodes.

public void testForNodes() {
    for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
        //Build
        buildWireInDir(ForgeDirection.UNKNOWN);
        buildWireInDir(side);
        //Test
        Location vec = center.add(side);
        TileEntity tile = vec.getTileEntity();
        if (tile instanceof ITileModuleProvider) {
            NodeBranchPart part = ((ITileModuleProvider) tile).getModule(NodeBranchPart.class, side.getOpposite());
            if (part == null)
                fail("Failed to get NodeBranchPart from tile at " + vec + " from side " + side.getOpposite());
        } else {
            fail("Something failed good as the wire is not an instance of INodeProvider");
        }
        //Cleanup
        center.setBlockToAir();
        center.add(side).setBlockToAir();
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ITileModuleProvider(com.builtbroken.mc.api.tile.ITileModuleProvider) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) NodeBranchPart(com.builtbroken.mc.lib.grid.branch.NodeBranchPart) Location(com.builtbroken.mc.lib.transform.vector.Location)

Aggregations

NodeBranchPart (com.builtbroken.mc.lib.grid.branch.NodeBranchPart)3 TileEntity (net.minecraft.tileentity.TileEntity)2 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)2 ITileModuleProvider (com.builtbroken.mc.api.tile.ITileModuleProvider)1 Location (com.builtbroken.mc.lib.transform.vector.Location)1 TileConductor (com.builtbroken.mc.prefab.tile.TileConductor)1 Map (java.util.Map)1