diff --git a/CHANGELOG.md b/CHANGELOG.md index 65875a8ee..48868d7bc 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Fixed not being able to move inventory items in Grid GUI's to hotbar via the number keys - Fixed Relays when being in "Ignore Redstone" mode using up energy - Improved collisions of Cable parts +- You now have to click the actual cable part head in order to get the GUI open **Features** - Added German translation by ChillUpX diff --git a/src/main/java/refinedstorage/block/BlockCable.java b/src/main/java/refinedstorage/block/BlockCable.java index ef407b0fc..a91e494e3 100755 --- a/src/main/java/refinedstorage/block/BlockCable.java +++ b/src/main/java/refinedstorage/block/BlockCable.java @@ -42,20 +42,20 @@ public class BlockCable extends BlockCoverable { return new AxisAlignedBB((float) fromX / 16F, (float) fromY / 16F, (float) fromZ / 16F, (float) toX / 16F, (float) toY / 16F, (float) toZ / 16F); } - private static AxisAlignedBB CORE_AABB = createAABB(6, 6, 6, 10, 10, 10); - private static AxisAlignedBB NORTH_AABB = createAABB(6, 6, 0, 10, 10, 6); - private static AxisAlignedBB EAST_AABB = createAABB(10, 6, 6, 16, 10, 10); - private static AxisAlignedBB SOUTH_AABB = createAABB(6, 6, 10, 10, 10, 16); - private static AxisAlignedBB WEST_AABB = createAABB(0, 6, 6, 6, 10, 10); - private static AxisAlignedBB UP_AABB = createAABB(6, 10, 6, 10, 16, 10); - private static AxisAlignedBB DOWN_AABB = createAABB(6, 0, 6, 10, 6, 10); + protected static AxisAlignedBB CORE_AABB = createAABB(6, 6, 6, 10, 10, 10); + protected static AxisAlignedBB NORTH_AABB = createAABB(6, 6, 0, 10, 10, 6); + protected static AxisAlignedBB EAST_AABB = createAABB(10, 6, 6, 16, 10, 10); + protected static AxisAlignedBB SOUTH_AABB = createAABB(6, 6, 10, 10, 10, 16); + protected static AxisAlignedBB WEST_AABB = createAABB(0, 6, 6, 6, 10, 10); + protected static AxisAlignedBB UP_AABB = createAABB(6, 10, 6, 10, 16, 10); + protected static AxisAlignedBB DOWN_AABB = createAABB(6, 0, 6, 10, 6, 10); - private static final PropertyBool NORTH = PropertyBool.create("north"); - private static final PropertyBool EAST = PropertyBool.create("east"); - private static final PropertyBool SOUTH = PropertyBool.create("south"); - private static final PropertyBool WEST = PropertyBool.create("west"); - private static final PropertyBool UP = PropertyBool.create("up"); - private static final PropertyBool DOWN = PropertyBool.create("down"); + protected static final PropertyBool NORTH = PropertyBool.create("north"); + protected static final PropertyBool EAST = PropertyBool.create("east"); + protected static final PropertyBool SOUTH = PropertyBool.create("south"); + protected static final PropertyBool WEST = PropertyBool.create("west"); + protected static final PropertyBool UP = PropertyBool.create("up"); + protected static final PropertyBool DOWN = PropertyBool.create("down"); private String name; @@ -143,6 +143,22 @@ public class BlockCable extends BlockCoverable { return false; } + private boolean isInAABB(AxisAlignedBB aabb, float hitX, float hitY, float hitZ) { + return hitX >= aabb.minX && hitX <= aabb.maxX && hitY >= aabb.minY && hitY <= aabb.maxY && hitZ >= aabb.minZ && hitZ <= aabb.maxZ; + } + + protected boolean hitCablePart(IBlockState state, World world, BlockPos pos, float hitX, float hitY, float hitZ) { + state = getActualState(state, world, pos); + + return isInAABB(CORE_AABB, hitX, hitY, hitZ) || + (state.getValue(NORTH) && isInAABB(NORTH_AABB, hitX, hitY, hitZ)) || + (state.getValue(EAST) && isInAABB(EAST_AABB, hitX, hitY, hitZ)) || + (state.getValue(SOUTH) && isInAABB(SOUTH_AABB, hitX, hitY, hitZ)) || + (state.getValue(WEST) && isInAABB(WEST_AABB, hitX, hitY, hitZ)) || + (state.getValue(UP) && isInAABB(UP_AABB, hitX, hitY, hitZ)) || + (state.getValue(DOWN) && isInAABB(DOWN_AABB, hitX, hitY, hitZ)); + } + public List getUnionizedCollisionBoxes(IBlockState state) { List boxes = new ArrayList<>(); diff --git a/src/main/java/refinedstorage/block/BlockConstructor.java b/src/main/java/refinedstorage/block/BlockConstructor.java index 1a17fef82..1f40403f4 100755 --- a/src/main/java/refinedstorage/block/BlockConstructor.java +++ b/src/main/java/refinedstorage/block/BlockConstructor.java @@ -74,8 +74,16 @@ public class BlockConstructor extends BlockCable { return new TileConstructor(); } + private boolean isInAABB(AxisAlignedBB aabb, float hitX, float hitY, float hitZ) { + return hitX >= aabb.minX && hitX <= aabb.maxX && hitY >= aabb.minY && hitY <= aabb.maxY && hitZ >= aabb.minZ && hitZ <= aabb.maxZ; + } + @Override public boolean onBlockActivatedDefault(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { + if (hitCablePart(state, world, pos, hitX, hitY, hitZ)) { + return false; + } + if (!world.isRemote) { player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.CONSTRUCTOR, world, pos.getX(), pos.getY(), pos.getZ()); } diff --git a/src/main/java/refinedstorage/block/BlockDestructor.java b/src/main/java/refinedstorage/block/BlockDestructor.java index 24701b07f..a8978ff03 100755 --- a/src/main/java/refinedstorage/block/BlockDestructor.java +++ b/src/main/java/refinedstorage/block/BlockDestructor.java @@ -33,6 +33,10 @@ public class BlockDestructor extends BlockCable { @Override public boolean onBlockActivatedDefault(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { + if (hitCablePart(state, world, pos, hitX, hitY, hitZ)) { + return false; + } + if (!world.isRemote) { player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.DESTRUCTOR, world, pos.getX(), pos.getY(), pos.getZ()); } diff --git a/src/main/java/refinedstorage/block/BlockExporter.java b/src/main/java/refinedstorage/block/BlockExporter.java index 9e7dd9bcc..b78aaef9f 100755 --- a/src/main/java/refinedstorage/block/BlockExporter.java +++ b/src/main/java/refinedstorage/block/BlockExporter.java @@ -87,6 +87,10 @@ public class BlockExporter extends BlockCable { @Override public boolean onBlockActivatedDefault(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { + if (hitCablePart(state, world, pos, hitX, hitY, hitZ)) { + return false; + } + if (!world.isRemote) { player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.EXPORTER, world, pos.getX(), pos.getY(), pos.getZ()); } diff --git a/src/main/java/refinedstorage/block/BlockExternalStorage.java b/src/main/java/refinedstorage/block/BlockExternalStorage.java index 25764e4eb..37e0c6660 100755 --- a/src/main/java/refinedstorage/block/BlockExternalStorage.java +++ b/src/main/java/refinedstorage/block/BlockExternalStorage.java @@ -70,6 +70,10 @@ public class BlockExternalStorage extends BlockCable { @Override public boolean onBlockActivatedDefault(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { + if (hitCablePart(state, world, pos, hitX, hitY, hitZ)) { + return false; + } + if (!world.isRemote) { player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.STORAGE, world, pos.getX(), pos.getY(), pos.getZ()); } diff --git a/src/main/java/refinedstorage/block/BlockImporter.java b/src/main/java/refinedstorage/block/BlockImporter.java index d39e74d01..0db3bd463 100755 --- a/src/main/java/refinedstorage/block/BlockImporter.java +++ b/src/main/java/refinedstorage/block/BlockImporter.java @@ -87,6 +87,10 @@ public class BlockImporter extends BlockCable { @Override public boolean onBlockActivatedDefault(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { + if (hitCablePart(state, world, pos, hitX, hitY, hitZ)) { + return false; + } + if (!world.isRemote) { player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.IMPORTER, world, pos.getX(), pos.getY(), pos.getZ()); }