Skip to content

Rework BlockEntityRenderFabricExtension to support alternative implementations - #342

Merged
tr7zw merged 2 commits into
tr7zw:mainfrom
BluSpring:pr/rework_be_culling
Oct 11, 2026
Merged

tr7zw merged 2 commits into
tr7zw:mainfrom
BluSpring:pr/rework_be_culling

Conversation

@BluSpring

@BluSpring BluSpring commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Supersedes #339, fixes KiltMC/Kilt#1020.
Also closes #335.

Allows properly supporting Kilt's interface injection of the same method, and also allows alternative implementations (e.g. Porting Lib) to be handled too. Still retains support for the interface, just in case there is a performance impact (edit: reading back, that sounds kinda stupid since it doesn't bypass on Vanilla BEs lmao), and also for the sake of mods that are already dependent on this interface.

Utilizes Java's ClassValue for caching the method reflections, Kilt uses a similar system and the performance impact seems to be pretty much next to none and thread-safe.

@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Walkthrough

Block entity render bounds now use a helper that supports extension implementations and compatible reflected methods. The caller uses this helper, and the BlockEntityRenderer mixin is removed from the mixin configuration.

Changes

Block entity render bounds

Layer / File(s) Summary
Resolve and use renderer bounds
src/main/java/dev/tr7zw/entityculling/BlockEntityRenderFabricExtension.java, src/main/java/dev/tr7zw/entityculling/EntityCullingMod.java, src/main/java/dev/tr7zw/entityculling/mixin/BlockEntityRendererMixin.java, src/main/resources/entityculling.mixins.json
The helper calls the extension method when available. Otherwise, it invokes a cached public method only when it is non-static and returns exactly AABB; missing or incompatible methods use the block-position box. Invocation access or target exceptions are wrapped in RuntimeException. setupAABB now calls the helper, and the renderer mixin is removed.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant EntityCullingMod
  participant BlockEntityRenderFabricExtension
  participant RENDER_BOUNDING_BOX_GETTER
  participant BlockEntityRenderer
  EntityCullingMod->>BlockEntityRenderFabricExtension: tryGetRenderBoundingBox(renderer, blockEntity)
  alt renderer implements the extension
    BlockEntityRenderFabricExtension->>BlockEntityRenderer: getRenderBoundingBox(blockEntity)
  else renderer requires reflection
    BlockEntityRenderFabricExtension->>RENDER_BOUNDING_BOX_GETTER: look up method for renderer class
    RENDER_BOUNDING_BOX_GETTER-->>BlockEntityRenderFabricExtension: compatible method or no method
    alt compatible method found
      BlockEntityRenderFabricExtension->>BlockEntityRenderer: invoke getRenderBoundingBox(blockEntity)
    else no compatible method
      BlockEntityRenderFabricExtension-->>EntityCullingMod: return block-position box
    end
  end
Loading

Suggested reviewers: tr7zw

Merge Risk: ⚪ Minimal · up to cea9b

The reviewed change preserves the existing bounds fallback, and no demonstrated regression currently blocks merging. Compatibility with Kilt remains unverified at runtime.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Issue #1020 requires EntityCulling to avoid the Kilt default-method conflict and to load into a world with block-entity culling active. The reviewed code removes the injected `BlockEntityRendererMixin…
Out of Scope Changes check Passed The reviewed changes are limited to block-entity render-bounding-box dispatch. The reflection cache, fallback behavior, caller update, and removal of the interface-injection mixin directly support iss…
Title check Passed The title clearly summarizes the main change: updating BlockEntityRenderFabricExtension to support alternative implementations.
Description check Passed The description directly explains support for Kilt interface injection, alternative implementations, compatibility, and ClassValue-based method caching.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (1 skipped: 1 unsupported.)


  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR





  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔇 Additional comments (4)
src/main/java/dev/tr7zw/entityculling/EntityCullingMod.java (1)

58-59: LGTM!

src/main/resources/entityculling.mixins.json (1)

17-17: LGTM!

src/main/java/dev/tr7zw/entityculling/BlockEntityRenderFabricExtension.java-51-54 (1)

51-54: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Do not wrap reflection failures in an uncaught RuntimeException.

setupAABB calls this helper on the render and culling path. If the reflected getRenderBoundingBox throws, InvocationTargetException becomes a RuntimeException. The exception propagates to the caller and can crash the client. A block entity renderer that fails in getRenderBoundingBox then causes a crash instead of a fallback.

Fall back to the block-position box on failure. Unwrap the cause only if you want to log it.

Proposed fix
             try {
                 return (AABB) method.orElseThrow().invoke(renderer, blockEntity);
-            } catch (IllegalAccessException | InvocationTargetException e) {
-                throw new RuntimeException(e);
+            } catch (IllegalAccessException | InvocationTargetException e) {
+                // Fall through to the default box.
             }
src/main/java/dev/tr7zw/entityculling/BlockEntityRenderFabricExtension.java (1)

34-35: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Add a comment inside the empty catch block.

SonarCloud flags the empty block. State that a missing method is expected and falls back to the default box.

Proposed fix
-            } catch (NoSuchMethodException ignored) {
-            }
+            } catch (NoSuchMethodException ignored) {
+                // Expected: the renderer has no such method. Use the default box.
+            }

Source: Linters/SAST tools


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b2a813a8-e5a5-4d57-808d-6646e7f5ed32
📥 Commits

Reviewing files that changed from the base of the PR and between 7e62c6e and cea9b25.

📒 Files selected for processing (4)
  • src/main/java/dev/tr7zw/entityculling/BlockEntityRenderFabricExtension.java
  • src/main/java/dev/tr7zw/entityculling/EntityCullingMod.java
  • src/main/java/dev/tr7zw/entityculling/mixin/BlockEntityRendererMixin.java
  • src/main/resources/entityculling.mixins.json
💤 Files with no reviewable changes (1)
  • src/main/java/dev/tr7zw/entityculling/mixin/BlockEntityRendererMixin.java

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@tr7zw

tr7zw commented Oct 10, 2026

Copy link
Copy Markdown
Owner

Ok that's an interesting approach. Will check out out tomorrow and merge it if the implementation is sound. Using reflections usually is "not great ™️" but this might be a good usecase for such a flimsy method.

@tr7zw
tr7zw merged commit 5269dd5 into tr7zw:main Oct 11, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants