From 456ed364a41545e3e1cd41ba62f584641e7e0690 Mon Sep 17 00:00:00 2001 From: JozsefA Date: Thu, 4 Feb 2021 00:03:37 -0800 Subject: [PATCH] Fix another issue with ghost instances. Hopefully fix belt lighting issues. --- .../contraptions/relays/belt/BeltTileEntity.java | 14 +++++++++++--- .../render/instancing/InstancedModel.java | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltTileEntity.java index acb2d0865..84a60d265 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltTileEntity.java @@ -125,6 +125,9 @@ public class BeltTileEntity extends KineticTileEntity { BeltMovementHandler.transportEntity(this, entity, info); }); toRemove.forEach(passengers::remove); + + if (blockLight == -1) + updateLight(); } @Override @@ -216,7 +219,7 @@ public class BeltTileEntity extends KineticTileEntity { if (!clientPacket) return; - updateLight(); + if (casingBefore == casing) return; requestModelDataUpdate(); @@ -484,7 +487,12 @@ public class BeltTileEntity extends KineticTileEntity { } private void updateLight() { - skyLight = (byte) world.getLightLevel(LightType.SKY, pos); - blockLight = (byte) world.getLightLevel(LightType.BLOCK, pos); + if (world != null) { + skyLight = (byte) world.getLightLevel(LightType.SKY, pos); + blockLight = (byte) world.getLightLevel(LightType.BLOCK, pos); + } else { + skyLight = -1; + blockLight = -1; + } } } diff --git a/src/main/java/com/simibubi/create/foundation/render/instancing/InstancedModel.java b/src/main/java/com/simibubi/create/foundation/render/instancing/InstancedModel.java index b6b70e6e2..7253675dd 100644 --- a/src/main/java/com/simibubi/create/foundation/render/instancing/InstancedModel.java +++ b/src/main/java/com/simibubi/create/foundation/render/instancing/InstancedModel.java @@ -92,8 +92,8 @@ public abstract class InstancedModel extends BufferedMod keys.get(i).index--; } - markIndexChanged(index - 1); maxIndexChanged = keys.size() - 1; + markIndexChanged(Math.min(maxIndexChanged, index)); key.invalidate(); }