-
Notifications
You must be signed in to change notification settings - Fork 508
[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
Merged
+51
−5
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
db55ab2
[Issue] - Enhance subtitle overlay rendering in GuiMixin.
Liam-Broome 029221f
Fix indentation in GuiMixin subtitle rendering
Liam-Broome 6e4935b
Merge branch '1.21.11' into issue/4933
modmuss50 d28ab22
Refactor subtitle overlay rendering to new mixin
Liam-Broome a44b07c
Clean up formatting in SubtitleOverlayMixin
Liam-Broome b276b6d
Cleanup SubtitleOverlayMixin
ekulxam a2097d0
Fix checkstyle
ekulxam 2aa4375
Merge pull request #1 from ekulxam/issue/4933
Liam-Broome 3e7556c
Merge branch '1.21.11' into issue/4933
Liam-Broome File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
62 changes: 62 additions & 0 deletions
62
...g-v1/src/client/java/net/fabricmc/fabric/mixin/client/rendering/SubtitleOverlayMixin.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| /* | ||
| * Copyright (c) 2016, 2017, 2018, 2019 FabricMC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package net.fabricmc.fabric.mixin.client.rendering; | ||
|
|
||
| import org.spongepowered.asm.mixin.Mixin; | ||
| import org.spongepowered.asm.mixin.Unique; | ||
| import org.spongepowered.asm.mixin.injection.At; | ||
| import org.spongepowered.asm.mixin.injection.Inject; | ||
| import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
|
||
| import net.minecraft.client.DeltaTracker; | ||
| import net.minecraft.client.Minecraft; | ||
| import net.minecraft.client.gui.GuiGraphics; | ||
| import net.minecraft.client.gui.components.SubtitleOverlay; | ||
|
|
||
| import net.fabricmc.fabric.api.client.rendering.v1.hud.VanillaHudElements; | ||
| import net.fabricmc.fabric.impl.client.rendering.hud.HudElementRegistryImpl; | ||
|
|
||
| @Mixin(SubtitleOverlay.class) | ||
| public class SubtitleOverlayMixin { | ||
| @Unique | ||
| private boolean fabric_renderingThroughHud = false; | ||
|
|
||
| @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); | ||
| } | ||
| } | ||
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
Oops, something went wrong.
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.
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.
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.
You're right actually; WrapMethod is cleaner here and does accomplish what we wanted.