Fix sunk grate side rendering, and prevent sunk placements over air blocks

This commit is contained in:
George Paton 2024-06-07 13:24:10 +10:00
parent b9e87b0d30
commit 0c26d45a71
2 changed files with 13 additions and 4 deletions

View File

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

View File

@ -23,6 +23,13 @@ public class RenderGrate implements ISimpleBlockRenderingHandler {
tessellator.setColorOpaque_F(1, 1, 1);
float fy = ((BlockGrate)block).getY(meta);
if(fy < 0) {
fy++;
y--;
} else if(fy >= 1) {
fy--;
y++;
}
renderer.setRenderBounds(0.0D, fy, 0D, 1D, fy + 0.125D, 1D);
renderer.renderStandardBlock(block, x, y, z);