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; }