Posted October 31, 20186 yr 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
October 31, 20186 yr 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.
October 31, 20186 yr 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 October 31, 20186 yr by San3001
October 31, 20186 yr 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.
November 1, 20186 yr 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
November 1, 20186 yr How are you registering your event subscriber? About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.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)
November 1, 20186 yr 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.
November 1, 20186 yr 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.
November 1, 20186 yr Don’t get the player, get the current view entity About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.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)
November 1, 20186 yr 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
November 1, 20186 yr 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.
November 2, 20186 yr 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 November 2, 20186 yr 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.