Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,4 @@ private void wrapChat(Gui instance, GuiGraphics context, DeltaTracker tickCounte
private void wrapPlayerList(Gui instance, GuiGraphics context, DeltaTracker tickCounter, Operation<Void> 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<Void> renderVanilla, @Local(argsOnly = true) DeltaTracker tickCounter) {
HudElementRegistryImpl.getRoot(VanillaHudElements.SUBTITLES).render(context, tickCounter, (ctx, tc) -> renderVanilla.call(instance, ctx, bl));
}
}
Original file line number Diff line number Diff line change
@@ -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<Void> original) {
HudElementRegistryImpl.getRoot(VanillaHudElements.SUBTITLES).render(
context,
Minecraft.getInstance().getDeltaTracker(),
(ctx, tc) -> original.call(ctx)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"GuiRendererMixin",
"GuiAccessor",
"GuiMixin",
"SubtitleOverlayMixin",
"LivingEntityRendererAccessor",
"LivingEntityRendererMixin",
"ModelMixin",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading