Jump to content

[1.15.1] [Solved] Adding custom information to the HUD


badner

Recommended Posts

Hey,

 

I am migrating from 1.12.2 to 1.15.1. In 1.12.2 you can use FontRenderer.drawString(String text, int x, int y, int color) and you get a simple Text on HUD. I tried similar stuff in 1.15.1 with TextRenderer.draw(String text, float x, float y, int color), but that doesnt work. I also took a look inside "InGameHud", but this didnt help me neither. There is some stuff going on with e.g. client.getProfiler().push("bossHealth"); and client.getProfiler().pop(); which I dont understand.

 

How can I simply draw a text on HUD?

 

Thanks in advance.

Edited by badner
Link to comment
Share on other sites

Okay, thats strange. I guess the reason for that difference is that Forge and Fabric (I am using Fabric) are using different deobfuscation tools? 

 

Anyway you said that FontRenderer is pretty much unchanged, then I have to try it again.

Edited by badner
typo
Link to comment
Share on other sites

It seems that rendering the HUD has changed. With a hook inside the InGameHud, we can render a text on the hud:

 

package de.d4n1el89.chunkinfo.mixins;

import org.spongepowered.asm.mixin.Mixin;
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.MinecraftClient;
import net.minecraft.client.gui.hud.InGameHud;

@Mixin({ InGameHud.class })
public class MixinInGameHud {

	@Inject(method = { "renderStatusEffectOverlay" }, at = { @At("RETURN") })
	private void onRenderStatusEffectOverlay(CallbackInfo ci) {
		MinecraftClient.getInstance().textRenderer.draw("THIS IS SPARTA", 50, 50, 16777215);
	}
}

 

Edited by badner
Link to comment
Share on other sites

  • Guest locked this topic
Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.