You now have to click the actual cable part head in order to get the GUI open

This commit is contained in:
Raoul Van den Berge
2016-08-07 01:10:46 +02:00
parent f0b6844d5c
commit 7aa4e1a225
7 changed files with 54 additions and 13 deletions

View File

@@ -10,6 +10,7 @@
- Fixed not being able to move inventory items in Grid GUI's to hotbar via the number keys - 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 - Fixed Relays when being in "Ignore Redstone" mode using up energy
- Improved collisions of Cable parts - Improved collisions of Cable parts
- You now have to click the actual cable part head in order to get the GUI open
**Features** **Features**
- Added German translation by ChillUpX - Added German translation by ChillUpX

View File

@@ -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); 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); protected static AxisAlignedBB CORE_AABB = createAABB(6, 6, 6, 10, 10, 10);
private static AxisAlignedBB NORTH_AABB = createAABB(6, 6, 0, 10, 10, 6); protected static AxisAlignedBB NORTH_AABB = createAABB(6, 6, 0, 10, 10, 6);
private static AxisAlignedBB EAST_AABB = createAABB(10, 6, 6, 16, 10, 10); protected static AxisAlignedBB EAST_AABB = createAABB(10, 6, 6, 16, 10, 10);
private static AxisAlignedBB SOUTH_AABB = createAABB(6, 6, 10, 10, 10, 16); protected static AxisAlignedBB SOUTH_AABB = createAABB(6, 6, 10, 10, 10, 16);
private static AxisAlignedBB WEST_AABB = createAABB(0, 6, 6, 6, 10, 10); protected static AxisAlignedBB WEST_AABB = createAABB(0, 6, 6, 6, 10, 10);
private static AxisAlignedBB UP_AABB = createAABB(6, 10, 6, 10, 16, 10); protected 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 DOWN_AABB = createAABB(6, 0, 6, 10, 6, 10);
private static final PropertyBool NORTH = PropertyBool.create("north"); protected static final PropertyBool NORTH = PropertyBool.create("north");
private static final PropertyBool EAST = PropertyBool.create("east"); protected static final PropertyBool EAST = PropertyBool.create("east");
private static final PropertyBool SOUTH = PropertyBool.create("south"); protected static final PropertyBool SOUTH = PropertyBool.create("south");
private static final PropertyBool WEST = PropertyBool.create("west"); protected static final PropertyBool WEST = PropertyBool.create("west");
private static final PropertyBool UP = PropertyBool.create("up"); protected static final PropertyBool UP = PropertyBool.create("up");
private static final PropertyBool DOWN = PropertyBool.create("down"); protected static final PropertyBool DOWN = PropertyBool.create("down");
private String name; private String name;
@@ -143,6 +143,22 @@ public class BlockCable extends BlockCoverable {
return false; 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<AxisAlignedBB> getUnionizedCollisionBoxes(IBlockState state) { public List<AxisAlignedBB> getUnionizedCollisionBoxes(IBlockState state) {
List<AxisAlignedBB> boxes = new ArrayList<>(); List<AxisAlignedBB> boxes = new ArrayList<>();

View File

@@ -74,8 +74,16 @@ public class BlockConstructor extends BlockCable {
return new TileConstructor(); 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 @Override
public boolean onBlockActivatedDefault(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { 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) { if (!world.isRemote) {
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.CONSTRUCTOR, world, pos.getX(), pos.getY(), pos.getZ()); player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.CONSTRUCTOR, world, pos.getX(), pos.getY(), pos.getZ());
} }

View File

@@ -33,6 +33,10 @@ public class BlockDestructor extends BlockCable {
@Override @Override
public boolean onBlockActivatedDefault(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { 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) { if (!world.isRemote) {
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.DESTRUCTOR, world, pos.getX(), pos.getY(), pos.getZ()); player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.DESTRUCTOR, world, pos.getX(), pos.getY(), pos.getZ());
} }

View File

@@ -87,6 +87,10 @@ public class BlockExporter extends BlockCable {
@Override @Override
public boolean onBlockActivatedDefault(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { 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) { if (!world.isRemote) {
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.EXPORTER, world, pos.getX(), pos.getY(), pos.getZ()); player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.EXPORTER, world, pos.getX(), pos.getY(), pos.getZ());
} }

View File

@@ -70,6 +70,10 @@ public class BlockExternalStorage extends BlockCable {
@Override @Override
public boolean onBlockActivatedDefault(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { 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) { if (!world.isRemote) {
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.STORAGE, world, pos.getX(), pos.getY(), pos.getZ()); player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.STORAGE, world, pos.getX(), pos.getY(), pos.getZ());
} }

View File

@@ -87,6 +87,10 @@ public class BlockImporter extends BlockCable {
@Override @Override
public boolean onBlockActivatedDefault(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { 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) { if (!world.isRemote) {
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.IMPORTER, world, pos.getX(), pos.getY(), pos.getZ()); player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.IMPORTER, world, pos.getX(), pos.getY(), pos.getZ());
} }