Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

  • Author

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

  • Author

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

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.