fix: some tile entities have no bounds?

This commit is contained in:
əlemi 2023-03-13 03:19:39 +01:00
parent 49c4b2fd47
commit 924601fc90
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -32,6 +32,7 @@ import net.minecraft.tileentity.ShulkerBoxTileEntity;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TrappedChestTileEntity; import net.minecraft.tileentity.TrappedChestTileEntity;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.util.math.vector.Vector3f; import net.minecraft.util.math.vector.Vector3f;
import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.client.event.RenderWorldLastEvent;
@ -112,8 +113,11 @@ public class StorageESP extends QuickModule {
for (TileEntity ent : MC.level.tickableBlockEntities) { for (TileEntity ent : MC.level.tickableBlockEntities) {
Vector3f color = this.tileHighlight(ent); Vector3f color = this.tileHighlight(ent);
if (color != null) { if (color != null) {
AxisAlignedBB bounds = ent.getBlockState().getCollisionShape(MC.level, ent.getBlockPos()).bounds().move(ent.getBlockPos()); VoxelShape shape = ent.getBlockState().getCollisionShape(MC.level, ent.getBlockPos());
WorldRenderer.renderLineBox(stack, builder, bounds, color.x(), color.y(), color.z(), this.alpha.get().floatValue()); if (!shape.isEmpty()) { // this might be null in some rare occurrences, just skip rendering this block for this frame
AxisAlignedBB bounds = shape.bounds().move(ent.getBlockPos());
WorldRenderer.renderLineBox(stack, builder, bounds, color.x(), color.y(), color.z(), this.alpha.get().floatValue());
}
} }
} }