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

I'd like to create some floating text like this(see attachment) minimap mod JourneyMap, though I have no idea where to start.

Would be appreciated if someone could guide me to some steps I'd need to do

 

I know how to make floating text the armorstand client side way but that doesn't increase size

 

 

image.png.2385e06cf8dcad3b15b10920643dfc9d.png

You could try to use the same logic EntityRenderer.drawNameplate has(or maybe even straight up use that method) but scale the drawn textbox with distance to the player.

  • Author
6 hours ago, V0idWa1k3r said:

You could try to use the same logic EntityRenderer.drawNameplate has(or maybe even straight up use that method) but scale the drawn textbox with distance to the player.

How does EntityRenderer.drawNameplate work? Do I just input coordinates and text displays there? Can't get it working.

Like, do I put it in a Tick Event? or

Edited by San3001

5 hours ago, San3001 said:

How does EntityRenderer.drawNameplate work? Do I just input coordinates and text displays there? Can't get it working.

Like, do I put it in a Tick Event? or

Well you obviously need to call it from some kind of event that gets called every frame. RenderWorldLast or RenderTickEvent for example.

 

As for the arguments passed see what Render#renderLivingLabel does.

  • Author
11 hours ago, V0idWa1k3r said:

Well you obviously need to call it from some kind of event that gets called every frame. RenderWorldLast or RenderTickEvent for example.

 

As for the arguments passed see what Render#renderLivingLabel does.

 

This doesn't seem to work

 

public RenderManager renderManager = mc.getRenderManager();
	
	@SubscribeEvent
	public void renderTick(TickEvent.RenderTickEvent event) {
		EntityPlayerSP player = mc.player;
		
		EntityRenderer.drawNameplate(renderManager.getFontRenderer(), "text", 0f, 64f, 0f, 0, player.cameraYaw, player.cameraPitch, renderManager.options.thirdPersonView == 2, player.isSneaking());
	
	}

 

Did I mess something up?

Thanks for your help

How are you registering your event subscriber?

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

8 minutes ago, San3001 said:

public RenderManager renderManager = mc.getRenderManager();

when is this initialized? It could be null.

 

10 minutes ago, San3001 said:

TickEvent.RenderTickEvent

This has two phases - you need to check the phase first before doing anything.

 

11 minutes ago, San3001 said:

EntityPlayerSP player = mc.player;

This could be null when RenderTickEvent fires.

 

12 minutes ago, San3001 said:

0f, 64f, 0f

These are your x,y,z coordinates. Are you sure you want it to be drawn at 0, 64, 0?

 

If you are not crashing then your event handler isn't registered. Otherwise fix what I told you to fix.

  • Author
1 hour ago, Cadiboo said:

How are you registering your event subscriber?

Doing it in postInit

 

1 hour ago, V0idWa1k3r said:

when is this initialized? It could be null.

 

This has two phases - you need to check the phase first before doing anything.

 

This could be null when RenderTickEvent fires.

 

These are your x,y,z coordinates. Are you sure you want it to be drawn at 0, 64, 0?

 

If you are not crashing then your event handler isn't registered. Otherwise fix what I told you to fix.

Yeah, it was crashing before but I just made a command to change a run boolean I had.

I just wanted it to work to start somewhere.

Right now I just want it to spawn in a static position(0, 64, 0) . I'll change it later

 

I don't know where else to get player or render manager so.. would this work?

renderManager never returns null for some reason, but renderManager.getFontRenderer() does

 

public RenderManager renderManager = mc.getRenderManager();
	
	@SubscribeEvent
	public void renderTick(TickEvent.RenderTickEvent event) {
		if (event.phase == TickEvent.Phase.START || renderManager.getFontRenderer() == null || mc.player == null) {
			return;
		}
		EntityPlayerSP player = mc.player;
		EntityRenderer.drawNameplate(renderManager.getFontRenderer(), "text", 0f, 64f, 0f, 0, player.cameraYaw, player.cameraPitch, renderManager.options.thirdPersonView == 2, player.isSneaking());
	
	}

It doesn't crash anymore but it also still doesn't work.

I feel this is a really lazy way to do this.

Don’t get the player, get the current view entity

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

  • Author
1 hour ago, Cadiboo said:

Don’t get the player, get the current view entity

private Minecraft mc = Minecraft.getMinecraft();
	public  RenderManager renderManager = mc.getRenderManager();
	
	@SubscribeEvent
	public void renderTick(TickEvent.RenderTickEvent event) {
		if (event.phase == TickEvent.Phase.START || renderManager.getFontRenderer() == null) {
			return;
		}
		Entity viewEntity = mc.getRenderViewEntity();
		EntityRenderer.drawNameplate(renderManager.getFontRenderer(), "text", 0f, 64f, 0f, 0, viewEntity.rotationYaw, viewEntity.rotationPitch, renderManager.options.thirdPersonView == 2, viewEntity.isSneaking());
	
	}

Like this? Still can't see but it looks like better code

I did some debugging with your code and here are the results:

11 hours ago, San3001 said:

TickEvent.RenderTickEvent

Turns out this is not the right event to render things in the world because the GL matrices aren't correct. RenderWorldLast works just fine though.

 

11 hours ago, San3001 said:

0f, 64f, 0f

These 3 parameters are the x,y,z relative to the camera's position, not relative to 0,0,0 in the world. So kept like this they will make the text render 64 blocks directly above the camera. So to render at 0, 64, 0 you would need to translate against the camera first by subtracting the camera's position from these coordinates.

 

11 hours ago, San3001 said:

viewEntity.rotationYaw, viewEntity.rotationPitch

These parameters don't want the yaw and pitch, they want the RenderManager.playerViewY and RenderManager.playerViewX instead.

 

11 hours ago, San3001 said:

renderManager.getFontRenderer()

Use Minecraft.fontRenderer instead.

 

After I've applied all these fixes the nameplate did indeed render in the world.

  • Author
10 hours ago, V0idWa1k3r said:

I did some debugging with your code and here are the results:

Turns out this is not the right event to render things in the world because the GL matrices aren't correct. RenderWorldLast works just fine though.

 

These 3 parameters are the x,y,z relative to the camera's position, not relative to 0,0,0 in the world. So kept like this they will make the text render 64 blocks directly above the camera. So to render at 0, 64, 0 you would need to translate against the camera first by subtracting the camera's position from these coordinates.

 

These parameters don't want the yaw and pitch, they want the RenderManager.playerViewY and RenderManager.playerViewX instead.

 

Use Minecraft.fontRenderer instead.

 

After I've applied all these fixes the nameplate did indeed render in the world.

private Minecraft mc = Minecraft.getMinecraft();
private  RenderManager renderManager = mc.getRenderManager();
private FontRenderer fontRenderer = mc.fontRenderer;
	
@SubscribeEvent
public void renderTick(RenderWorldLastEvent event) {
	if (fontRenderer == null || mc.player == null || renderManager == null || renderManager.options == null) {
		return;
	}

		
	EntityPlayerSP player = mc.player;
	EntityRenderer.drawNameplate(fontRenderer, "text", 2f, 0f, 0f, 0, renderManager.playerViewY, renderManager.playerViewX, renderManager.options.thirdPersonView == 2, player.isSneaking());
	
}

This works perfectly, thank you so much! Subtracting player position should be easy enough.

Edited by San3001
Adding some text

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

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.