diff --git a/src/dark/core/prefab/helpers/ConnectionHelper.java b/src/dark/core/prefab/helpers/ConnectionHelper.java index b7cb7d5a..1cbc2dcb 100644 --- a/src/dark/core/prefab/helpers/ConnectionHelper.java +++ b/src/dark/core/prefab/helpers/ConnectionHelper.java @@ -9,7 +9,7 @@ public class ConnectionHelper { /** Used to find all tileEntities sounding the location you will have to filter for selective * tileEntities - * + * * @param world - the world being searched threw * @param x * @param y @@ -18,7 +18,11 @@ public class ConnectionHelper public static TileEntity[] getSurroundingTileEntities(TileEntity ent) { return getSurroundingTileEntities(ent.worldObj, ent.xCoord, ent.yCoord, ent.zCoord); + } + public static TileEntity[] getSurroundingTileEntities(World world, Vector3 vec) + { + return getSurroundingTileEntities(world, vec.intX(), vec.intY(), vec.intZ()); } public static TileEntity[] getSurroundingTileEntities(World world, int x, int y, int z) @@ -31,50 +35,33 @@ public class ConnectionHelper return list; } - public static int[] getSurroundingBlocks(TileEntity ent) - { - return getSurroundingBlocks(ent.worldObj, ent.xCoord, ent.yCoord, ent.zCoord); - } - - public static int[] getSurroundingBlocks(World world, Vector3 v) - { - return ConnectionHelper.getSurroundingBlocks(world, v.intX(), v.intY(), v.intZ()); - } - - public static int[] getSurroundingBlocks(World world, int x, int y, int z) - { - int[] list = new int[6]; - for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) - { - int id = world.getBlockId(x + direction.offsetX, y + direction.offsetY, z + direction.offsetZ); - list[direction.ordinal()] = id; - } - return list; - } - /** Used to find which of 4 Corners this block is in a group of blocks 0 = not a corner 1-4 = a * corner of some direction */ public static int corner(TileEntity entity) { TileEntity[] en = getSurroundingTileEntities(entity.worldObj, entity.xCoord, entity.yCoord, entity.zCoord); - if (en[4] != null && en[2] != null && en[5] == null && en[3] == null) + TileEntity north = en[ForgeDirection.NORTH.ordinal()]; + TileEntity south = en[ForgeDirection.SOUTH.ordinal()]; + TileEntity east = en[ForgeDirection.EAST.ordinal()]; + TileEntity west = en[ForgeDirection.WEST.ordinal()]; + + if (west != null && north != null && east == null && south == null) { return 3; } - if (en[2] != null && en[5] != null && en[3] == null && en[4] == null) + if (north != null && east != null && south == null && west == null) { return 4; } - if (en[5] != null && en[3] != null && en[4] == null && en[2] == null) + if (east != null && south != null && west == null && north == null) { return 1; } - if (en[3] != null && en[4] != null && en[2] == null && en[5] == null) + if (south != null && west != null && north == null && east == null) { return 2; } return 0; - } }