Skip to content

Commit c4f0e88

Browse files
authored
Fix #1026: Don't render hatch/block previews further than 32 blocks away (#1048)
1 parent fe9b68c commit c4f0e88

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/client/java/aztech/modern_industrialization/machines/multiblocks/MultiblockMachineBER.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
import org.jetbrains.annotations.Nullable;
4343

4444
public class MultiblockMachineBER extends MachineBlockEntityRenderer<MultiblockMachineBlockEntity> {
45+
private static final double MAX_HIGHLIGHT_DISTANCE = 32.0;
46+
4547
public MultiblockMachineBER(BlockEntityRendererProvider.Context ctx) {
4648
super(ctx);
4749
}
@@ -55,8 +57,14 @@ public void render(MultiblockMachineBlockEntity be, float tickDelta, PoseStack m
5557
HatchType hatchType = getHeldHatchType();
5658
if (drawHighlights || hatchType != null) {
5759
ShapeMatcher matcher = be.createShapeMatcher();
60+
var player = Minecraft.getInstance().player;
5861

5962
for (BlockPos pos : matcher.getPositions()) {
63+
if (player != null && player.distanceToSqr(pos.getX(), pos.getY(), pos.getZ()) > MAX_HIGHLIGHT_DISTANCE * MAX_HIGHLIGHT_DISTANCE) {
64+
// Skip blocks that are far from the player to mitigate FPS drops.
65+
continue;
66+
}
67+
6068
matrices.pushPose();
6169
matrices.translate(pos.getX() - be.getBlockPos().getX(), pos.getY() - be.getBlockPos().getY(), pos.getZ() - be.getBlockPos().getZ());
6270

0 commit comments

Comments
 (0)