Fix funky placement issues

This commit is contained in:
George Paton 2024-06-07 14:25:46 +10:00
parent 0c26d45a71
commit 7d26a51c6b

View File

@ -110,14 +110,14 @@ public class BlockGrate extends Block implements ITooltipProvider {
if(meta == 0) { if(meta == 0) {
// Check that the block below can fit a grate above it // Check that the block below can fit a grate above it
Block block = world.getBlock(x, y - 1, z); Block block = world.getBlock(x, y - 1, z);
AxisAlignedBB bb = block.getCollisionBoundingBoxFromPool(world, x, y - 1, z); AxisAlignedBB otherBB = block.getSelectedBoundingBoxFromPool(world, x, y - 1, z);
if(!block.isAir(world, x, y + 1, z) && (bb == null || (int) ((bb.maxY - (y - 1)) * 100) < 90)) { if(!block.isAir(world, x, y + 1, z) && (otherBB == null || otherBB.maxY - (double)y < -0.05)) {
world.setBlockMetadataWithNotify(x, y, z, 9, 3); world.setBlockMetadataWithNotify(x, y, z, 9, 3);
} }
} else if(meta == 7) { } else if(meta == 7) {
Block block = world.getBlock(x, y + 1, z); Block block = world.getBlock(x, y + 1, z);
AxisAlignedBB bb = block.getCollisionBoundingBoxFromPool(world, x, y + 1, z); AxisAlignedBB otherBB = block.getSelectedBoundingBoxFromPool(world, x, y + 1, z);
if(!block.isAir(world, x, y + 1, z) && (bb == null || (int) ((bb.minY - (y + 1)) * 100) > 10)) { if(!block.isAir(world, x, y + 1, z) && (otherBB == null || otherBB.minY - (double)(y + 1) > 0.05)) {
world.setBlockMetadataWithNotify(x, y, z, 8, 3); world.setBlockMetadataWithNotify(x, y, z, 8, 3);
} }
} }
@ -133,15 +133,11 @@ public class BlockGrate extends Block implements ITooltipProvider {
boolean breakIt = false; boolean breakIt = false;
if(meta == 9) { if(meta == 9) {
AxisAlignedBB bb = world.getBlock(x, y - 1, z).getCollisionBoundingBoxFromPool(world, x, y - 1, z); AxisAlignedBB otherBB = world.getBlock(x, y - 1, z).getSelectedBoundingBoxFromPool(world, x, y - 1, z);
if(bb != null && (int) ((bb.maxY - (y - 1)) * 100) >= 90) { breakIt = !(otherBB == null || otherBB.maxY - (double)y < -0.05);
breakIt = true;
}
} else if(meta == 8) { } else if(meta == 8) {
AxisAlignedBB bb = world.getBlock(x, y + 1, z).getCollisionBoundingBoxFromPool(world, x, y + 1, z); AxisAlignedBB otherBB = world.getBlock(x, y + 1, z).getSelectedBoundingBoxFromPool(world, x, y + 1, z);
if(bb != null && (int) ((bb.minY - (y + 1)) * 100) <= 10) { breakIt = !(otherBB == null || otherBB.minY - (double)(y + 1) > 0.05);
breakIt = true;
}
} }
if(breakIt) { if(breakIt) {