From ccbcaf9e3ff20a0a236d085ad89a60023fb564e2 Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Sun, 25 Sep 2022 17:17:57 -0700 Subject: [PATCH] Fixinum - Fix missing chunks when backend is off and sodium installed. - Fix crashes when used with iris. --- .../SodiumChunkRenderDataMixin.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/jozufozu/flywheel/mixin/instancemanage/SodiumChunkRenderDataMixin.java b/src/main/java/com/jozufozu/flywheel/mixin/instancemanage/SodiumChunkRenderDataMixin.java index 55e7340f2..d2ec94a62 100644 --- a/src/main/java/com/jozufozu/flywheel/mixin/instancemanage/SodiumChunkRenderDataMixin.java +++ b/src/main/java/com/jozufozu/flywheel/mixin/instancemanage/SodiumChunkRenderDataMixin.java @@ -10,6 +10,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher; import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry; @@ -30,15 +31,19 @@ public class SodiumChunkRenderDataMixin { @Inject(method = "addBlockEntity", at = @At("HEAD"), cancellable = true, require = 0) private void flywheel$onAddBlockEntity(BlockEntity be, boolean cull, CallbackInfo ci) { + if (flywheel$level == null) { + flywheel$level = be.getLevel(); + } + + if (!Backend.canUseInstancing(flywheel$level)) { + return; + } + if (InstancedRenderRegistry.canInstance(be.getType())) { if (flywheel$blockEntities == null) { flywheel$blockEntities = new ArrayList<>(); } - if (flywheel$level == null) { - flywheel$level = be.getLevel(); - } - // Collect BEs in a temporary list to avoid excessive synchronization in InstancedRenderDispatcher. flywheel$blockEntities.add(be); } @@ -50,7 +55,7 @@ public class SodiumChunkRenderDataMixin { @Inject(method = "build", at = @At("HEAD")) private void flywheel$onBuild(CallbackInfoReturnable cir) { - if (flywheel$level == null || flywheel$blockEntities == null) { + if (flywheel$level == null || flywheel$blockEntities == null || !Backend.canUseInstancing(flywheel$level)) { return; }