From cda66c0ad8f922f9817602b4765d0c7a7d18efd1 Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Wed, 4 Aug 2021 20:20:24 -0700 Subject: [PATCH] Fix #23 - Clamp update divisor --- .../jozufozu/flywheel/backend/instancing/InstanceManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceManager.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceManager.java index 6b9dbc8f6..9c88d2ff1 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceManager.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceManager.java @@ -16,11 +16,13 @@ import javax.annotation.Nullable; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.material.MaterialManager; +import com.jozufozu.flywheel.util.RenderMath; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import it.unimi.dsi.fastutil.objects.ObjectArraySet; import net.minecraft.client.renderer.ActiveRenderInfo; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.vector.Vector3f; public abstract class InstanceManager implements MaterialManager.OriginShiftListener { @@ -281,7 +283,7 @@ public abstract class InstanceManager implements MaterialManager.OriginShiftL int i = (dSq / 2048); - return divisorSequence[Math.min(i, divisorSequence.length - 1)]; + return divisorSequence[MathHelper.clamp(i, 0, divisorSequence.length - 1)]; } protected void addInternal(T tile) {