Merge pull request #1530 from MellowArpeggiation/master

Fix grate placement and rendering issues
This commit is contained in:
HbmMods 2024-06-07 07:52:54 +02:00 committed by GitHub
commit 6a4552a858
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 12 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 otherBB = block.getSelectedBoundingBoxFromPool(world, x, y - 1, z);
if(!block.isAir(world, x, y + 1, z) && (otherBB == null || otherBB.maxY - (double)y < -0.05)) {
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 otherBB = block.getSelectedBoundingBoxFromPool(world, x, y + 1, z);
if(!block.isAir(world, x, y + 1, z) && (otherBB == null || otherBB.minY - (double)(y + 1) > 0.05)) {
world.setBlockMetadataWithNotify(x, y, z, 8, 3);
}
}
@ -131,15 +133,11 @@ public class BlockGrate extends Block implements ITooltipProvider {
boolean breakIt = false;
if(meta == 9) {
AxisAlignedBB bb = world.getBlock(x, y - 1, z).getCollisionBoundingBoxFromPool(world, x, y - 1, z);
if(bb != null && (int) ((bb.maxY - (y - 1)) * 100) >= 90) {
breakIt = true;
}
AxisAlignedBB otherBB = world.getBlock(x, y - 1, z).getSelectedBoundingBoxFromPool(world, x, y - 1, z);
breakIt = !(otherBB == null || otherBB.maxY - (double)y < -0.05);
} else if(meta == 8) {
AxisAlignedBB bb = world.getBlock(x, y + 1, z).getCollisionBoundingBoxFromPool(world, x, y + 1, z);
if(bb != null && (int) ((bb.minY - (y + 1)) * 100) <= 10) {
breakIt = true;
}
AxisAlignedBB otherBB = world.getBlock(x, y + 1, z).getSelectedBoundingBoxFromPool(world, x, y + 1, z);
breakIt = !(otherBB == null || otherBB.minY - (double)(y + 1) > 0.05);
}
if(breakIt) {

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);