diff --git a/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/mixin/client/rendering/GuiMixin.java b/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/mixin/client/rendering/GuiMixin.java index 7e1905e6ab6..d361a6724b7 100644 --- a/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/mixin/client/rendering/GuiMixin.java +++ b/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/mixin/client/rendering/GuiMixin.java @@ -159,9 +159,4 @@ private void wrapChat(Gui instance, GuiGraphics context, DeltaTracker tickCounte private void wrapPlayerList(Gui instance, GuiGraphics context, DeltaTracker tickCounter, Operation renderVanilla) { 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")) - private void wrapSubtitlesHud(Gui instance, GuiGraphics context, boolean bl, Operation renderVanilla, @Local(argsOnly = true) DeltaTracker tickCounter) { - HudElementRegistryImpl.getRoot(VanillaHudElements.SUBTITLES).render(context, tickCounter, (ctx, tc) -> renderVanilla.call(instance, ctx, bl)); - } } diff --git a/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/mixin/client/rendering/SubtitleOverlayMixin.java b/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/mixin/client/rendering/SubtitleOverlayMixin.java new file mode 100644 index 00000000000..9cb08fab780 --- /dev/null +++ b/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/mixin/client/rendering/SubtitleOverlayMixin.java @@ -0,0 +1,40 @@ +/* + * 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 com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import org.spongepowered.asm.mixin.Mixin; + +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 { + @WrapMethod(method = "render") + private void wrapSubtitleRender(GuiGraphics context, Operation original) { + HudElementRegistryImpl.getRoot(VanillaHudElements.SUBTITLES).render( + context, + Minecraft.getInstance().getDeltaTracker(), + (ctx, tc) -> original.call(ctx) + ); + } +} diff --git a/fabric-rendering-v1/src/client/resources/fabric-rendering-v1.mixins.json b/fabric-rendering-v1/src/client/resources/fabric-rendering-v1.mixins.json index 85931a91672..29672da39dd 100644 --- a/fabric-rendering-v1/src/client/resources/fabric-rendering-v1.mixins.json +++ b/fabric-rendering-v1/src/client/resources/fabric-rendering-v1.mixins.json @@ -23,6 +23,7 @@ "GuiRendererMixin", "GuiAccessor", "GuiMixin", + "SubtitleOverlayMixin", "LivingEntityRendererAccessor", "LivingEntityRendererMixin", "ModelMixin", diff --git a/fabric-rendering-v1/src/testmodClient/java/net/fabricmc/fabric/test/rendering/client/HudTests.java b/fabric-rendering-v1/src/testmodClient/java/net/fabricmc/fabric/test/rendering/client/HudTests.java index 872b9181f0b..af39e2f59d9 100644 --- a/fabric-rendering-v1/src/testmodClient/java/net/fabricmc/fabric/test/rendering/client/HudTests.java +++ b/fabric-rendering-v1/src/testmodClient/java/net/fabricmc/fabric/test/rendering/client/HudTests.java @@ -53,6 +53,16 @@ public void onInitializeClient() { HudElementRegistry.attachElementBefore(VanillaHudElements.DEMO_TIMER, Identifier.fromNamespaceAndPath(MOD_ID, BEFORE_DEMO_TIMER), HudTests::renderBeforeDemoTimer); HudElementRegistry.attachElementBefore(VanillaHudElements.CHAT, Identifier.fromNamespaceAndPath(MOD_ID, BEFORE_CHAT), HudTests::renderBeforeChat); HudElementRegistry.attachElementAfter(VanillaHudElements.SUBTITLES, Identifier.fromNamespaceAndPath(MOD_ID, AFTER_SUBTITLES), HudTests::renderAfterSubtitles); + + // https://github.com/FabricMC/fabric/issues/4933#issuecomment-3552574307 + HudElementRegistry.replaceElement( + VanillaHudElements.SUBTITLES, original -> (graphics, tracker) -> { + graphics.pose().pushMatrix(); + graphics.pose().scale(0.25f); + original.render(graphics, tracker); + graphics.pose().popMatrix(); + } + ); } private static void renderBeforeMiscOverlay(GuiGraphics context, DeltaTracker tickCounter) {