-
Notifications
You must be signed in to change notification settings - Fork 487
[Issue] - Fix HudElementRegistry.replaceElement() for subtitles during gameplay. #5012
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 1.21.11
Are you sure you want to change the base?
Conversation
|
The test |
yes, MC-304369 |
|
Wait don't merge yet |
| HudElementRegistryImpl.getRoot(VanillaHudElements.PLAYER_LIST).render(context, tickCounter, (ctx, tc) -> renderVanilla.call(instance, ctx, tc)); | ||
| } | ||
|
|
||
| @WrapOperation(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Gui;renderSubtitleOverlay(Lnet/minecraft/client/gui/GuiGraphics;Z)V")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree with this mixin, see https://discord.com/channels/507304429255393322/807617700734042122/1440940666829013103.
I think it would better to instead mixin into the renderSubtitleOverlay method (and the lambda) to wrap the subtitleOverlay#render (as shown in the image).
As stated by @cassiancc, we can obtain the DeltaTracker/RenderTickCounter from the client so my suggested change may actually be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ekulxam - I have made some changes, thanks for the feedback 😄
| @Inject(method = "render", at = @At("HEAD"), cancellable = true) | ||
| private void wrapSubtitleRender(GuiGraphics context, CallbackInfo ci) { | ||
| if (!fabric_renderingThroughHud) { | ||
| DeltaTracker deltaTracker = Minecraft.getInstance().getDeltaTracker(); | ||
|
|
||
| ci.cancel(); | ||
|
|
||
| HudElementRegistryImpl.getRoot(VanillaHudElements.SUBTITLES) | ||
| .render(context, deltaTracker, (ctx, tc) -> { | ||
| fabric_renderingThroughHud = true; | ||
|
|
||
| try { | ||
| fabric_callOriginalRender(ctx); | ||
| } finally { | ||
| fabric_renderingThroughHud = false; | ||
| } | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| @Unique | ||
| private void fabric_callOriginalRender(GuiGraphics context) { | ||
| ((SubtitleOverlay) (Object) this).render(context); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does this need to be recursive? I would think that this should be a WrapMethod.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I said to wrap it and not inject. It should actually be a WrapOperation into both the lambda and the renderSubtitleOverlay method with the render call as the target.
Fixes issue #4933 where
HudElementRegistry.replaceElement(VanillaHudElements.SUBTITLES, ...)did not work correctly during normal gameplay, only when the game was paused. This prevented mods from properly scaling, positioning, or otherwise modifying subtitle rendering during active play.Screen.Recording.2025-11-19.at.16.17.20.mov