Skip to content

Commit

Permalink
Quick thinking
Browse files Browse the repository at this point in the history
- Decide not to render entities directly in the renderEntity method
- Prevents allocating large lists every frame to filter entities from
  the client level
  • Loading branch information
Jozufozu committed Sep 29, 2024
1 parent 0a01b82 commit 22b5676
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 33 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@
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 {
Expand Down Expand Up @@ -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();
}
}
}
1 change: 0 additions & 1 deletion common/src/main/resources/flywheel.impl.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"client": [
"BlockEntityTypeMixin",
"ClientChunkCacheMixin",
"ClientLevelMixin",
"EntityTypeMixin",
"LevelMixin",
"LevelRendererMixin",
Expand Down

0 comments on commit 22b5676

Please sign in to comment.