Fix translucent items vanishing behind water and glass (v1.2.0)#2
Draft
ReimaginedPixel wants to merge 4 commits into
Draft
Fix translucent items vanishing behind water and glass (v1.2.0)#2ReimaginedPixel wants to merge 4 commits into
ReimaginedPixel wants to merge 4 commits into
Conversation
Translucent entities (armor stands and the items they hold or wear) render in a separate pass from translucent blocks such as water and glass. Vanilla only depth-sorts render layers within each pass, never across them, so a translucent item near a translucent block has no defined blend order and its alpha pixels composite incorrectly — most visibly, the item disappears or is clipped behind water/glass. Add ItemTranslucencyMixin, which mixes into RenderLayer#getItemEntityTranslucentCull (the layer used to draw items in the world) and returns the equivalent getEntityCutout layer instead. Cutout is alpha-tested and writes depth like an opaque surface, so items resolve against translucent blocks correctly. The trade-off is loss of soft alpha edges, which is imperceptible for the vast majority of item textures. The behaviour is gated behind a new "Fix Item Translucency" toggle (default on) in the config and Mod Menu screen, alongside the existing force-render options. Bump mod version to 1.2.0 and refresh the README and mod metadata. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VaWtp4Tu17FEE4AtHU9hRo
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
The fabric-loom 1.16-SNAPSHOT plugin now resolves to a build that requires Gradle 9.4 (org.gradle.plugin.api-version=9.4.0), but the Build workflow pinned Gradle 8.8, so dependency resolution failed before any compilation. gradle-wrapper.properties already targets 9.4.0; align the CI workflow (and the README build note) with it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VaWtp4Tu17FEE4AtHU9hRo
RenderLayer#getEntityCutout(Identifier) does not exist in the 1.21.11 mappings; the compile failed on it. Swap to getEntityCutoutNoCull(Identifier), a long-stable entity cutout layer. NoCull also keeps back faces of 3D display models visible, which suits the custom furniture models this targets. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VaWtp4Tu17FEE4AtHU9hRo
In 1.21.11 the render-layer factory methods moved out of RenderLayer and were renamed. Intercept the two layers that actually draw items in the world: - TexturedRenderLayers#getItemTranslucentCull (block-atlas items) -> getEntityCutout - RenderLayers#itemEntityTranslucentCull(Identifier) (per-texture items) -> entityCutout Both swaps keep the same texture and backface culling, changing only the pass from translucent to depth-writing cutout so items composite correctly against water and glass. Method/class names verified against the yarn 1.21.11 mappings. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VaWtp4Tu17FEE4AtHU9hRo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Translucent entities (armor stands and the items they hold or wear) render in a separate pass from translucent blocks such as water and glass. Vanilla only depth-sorts render layers within each pass, never across them — so a translucent item near a translucent block has no defined blend order and its alpha pixels composite incorrectly. Most visibly, the item disappears or gets clipped when it sits behind water or glass.
This is the same class of vanilla rendering bug ForceRender already tackles for frustum culling, and it shows up on custom display models (e.g. ItemsAdder furniture).
The fix
New
ItemTranslucencyMixinmixes intoRenderLayer#getItemEntityTranslucentCull— the render layer Minecraft uses to draw items in the world — and returns the equivalentgetEntityCutoutlayer instead.Cutout is alpha-tested and writes depth like an opaque surface, so items now resolve against translucent blocks correctly via the depth buffer. This is the least-invasive of the two possible approaches (the alternative being a much heavier mixin that reorders the translucent entity/block passes).
Trade-off: cutout loses soft alpha edges — each pixel is either fully drawn or discarded. This is imperceptible for the vast majority of item textures, and the behaviour can be turned off if soft transparency is specifically needed.
Config
Gated behind a new Fix Item Translucency toggle (default on), added to both
forcerender.propertiesand the Mod Menu settings screen alongside the existing options.Changes
mixin/ItemTranslucencyMixin.java— new client mixin (registered inforcerender.mixins.json)ForceRenderConfig.java— newfixTranslucencyoption (load/save)ForceRenderConfigScreen.java— new toggle button + labelForceRenderMod.java— startup log includes the new optionfabric.mod.json— updated descriptiongradle.properties— version bump1.1.0 → 1.2.0README.md— documents the new fix, refreshed settings/compatibility tablesVersion bumped to 1.2.0 (new user-facing feature, not just a patch).
Verification
The sandbox network policy blocks
maven.fabricmc.net, so the mod can't be compiled locally here. Compilation — including Mixin annotation-processor validation of the injection target against the real 1.21.11RenderLayerclass — runs in the existing Build GitHub Actions workflow on this PR. Runtime/visual verification (item behind water/glass with the toggle on vs off) still needs a manual in-game check.🤖 Generated with Claude Code
https://claude.ai/code/session_01VaWtp4Tu17FEE4AtHU9hRo
Generated by Claude Code