diff --git a/common/src/main/java/dev/engine_room/flywheel/impl/mixin/ClientLevelMixin.java b/common/src/main/java/dev/engine_room/flywheel/impl/mixin/ClientLevelMixin.java deleted file mode 100644 index 10270b497..000000000 --- a/common/src/main/java/dev/engine_room/flywheel/impl/mixin/ClientLevelMixin.java +++ /dev/null @@ -1,32 +0,0 @@ -package dev.engine_room.flywheel.impl.mixin; - -import java.util.ArrayList; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import com.google.common.collect.Lists; - -import dev.engine_room.flywheel.api.visualization.VisualizationManager; -import dev.engine_room.flywheel.lib.visualization.VisualizationHelper; -import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.world.entity.Entity; - -@Mixin(ClientLevel.class) -abstract class ClientLevelMixin { - @Inject(method = "entitiesForRendering()Ljava/lang/Iterable;", at = @At("RETURN"), cancellable = true) - private void flywheel$filterEntities(CallbackInfoReturnable> cir) { - if (!VisualizationManager.supportsVisualization((ClientLevel) (Object) this)) { - return; - } - - Iterable entities = cir.getReturnValue(); - ArrayList filtered = Lists.newArrayList(entities); - - filtered.removeIf(VisualizationHelper::skipVanillaRender); - - cir.setReturnValue(filtered); - } -} diff --git a/common/src/main/java/dev/engine_room/flywheel/impl/mixin/LevelRendererMixin.java b/common/src/main/java/dev/engine_room/flywheel/impl/mixin/LevelRendererMixin.java index 2e259c04f..6fa747581 100644 --- a/common/src/main/java/dev/engine_room/flywheel/impl/mixin/LevelRendererMixin.java +++ b/common/src/main/java/dev/engine_room/flywheel/impl/mixin/LevelRendererMixin.java @@ -19,14 +19,17 @@ import com.mojang.blaze3d.vertex.PoseStack; import dev.engine_room.flywheel.api.visualization.VisualizationManager; import dev.engine_room.flywheel.impl.FlwImplXplat; import dev.engine_room.flywheel.impl.event.RenderContextImpl; +import dev.engine_room.flywheel.lib.visualization.VisualizationHelper; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import net.minecraft.client.Camera; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.LightTexture; +import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderBuffers; import net.minecraft.server.level.BlockDestructionProgress; +import net.minecraft.world.entity.Entity; @Mixin(value = LevelRenderer.class, priority = 1001) // Higher priority to go after Sodium abstract class LevelRendererMixin { @@ -120,4 +123,11 @@ abstract class LevelRendererMixin { } } } + + @Inject(method = "renderEntity", at = @At("HEAD"), cancellable = true) + private void flywheel$decideNotToRenderEntity(Entity pEntity, double pCamX, double pCamY, double pCamZ, float pPartialTick, PoseStack pPoseStack, MultiBufferSource pBufferSource, CallbackInfo ci) { + if (VisualizationManager.supportsVisualization(pEntity.level()) && VisualizationHelper.skipVanillaRender(pEntity)) { + ci.cancel(); + } + } } diff --git a/common/src/main/resources/flywheel.impl.mixins.json b/common/src/main/resources/flywheel.impl.mixins.json index 11b38d8db..a1953a127 100644 --- a/common/src/main/resources/flywheel.impl.mixins.json +++ b/common/src/main/resources/flywheel.impl.mixins.json @@ -7,7 +7,6 @@ "client": [ "BlockEntityTypeMixin", "ClientChunkCacheMixin", - "ClientLevelMixin", "EntityTypeMixin", "LevelMixin", "LevelRendererMixin",