Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.15.2] Display text in the upper right
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 1
Peyang

[1.15.2] Display text in the upper right

By Peyang, January 18 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Peyang    0

Peyang

Peyang    0

  • Tree Puncher
  • Peyang
  • Members
  • 0
  • 8 posts
Posted January 18

(Please forgive me for using a translator. :D

I wanted to show strings on the display and created a project in 1.15.2.
I ported from the code that worked in 1.8.9, but apparently it doesn't work in 1.15.2.
In the code of 1.8.9
I used Minecraft.getInstance().fontRenderer.drawStringWithShadow() from RenderGameOverlayEvent.Pre.
Since there was the same method in 1.15.2, I wrote it as it is, but it seems that it does not work.

I also tried, but it didn't work. I also tried RenderGameOverlayEvent.Post and so on.

Can anyone please teach me how to display the character string in the upper left corner of the screen?

 

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7699

diesieben07

diesieben07    7699

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7699
  • 56430 posts
Posted January 18

Show your code.

  • Quote

Share this post


Link to post
Share on other sites

Peyang    0

Peyang

Peyang    0

  • Tree Puncher
  • Peyang
  • Members
  • 0
  • 8 posts
Posted January 18 (edited)
@SubscribeEvent
public void onRender(final RenderGameOverlayEvent.Pre event)
{
    if (event.getType() != RenderGameOverlayEvent.ElementType.ALL/*HEALTH*/)
        return;
    DrawTest.draw();
}
public void draw()
{
    if (nowWanted == 0)
        return;
    IngameGui gui = Minecraft.getInstance().ingameGUI;
    int maxWidth = Minecraft.getInstance().getMainWindow().getWidth();
    int maxHeight = Minecraft.getInstance().getMainWindow().getHeight();
    int width = Regions.getStringWidth(StringUtils.repeat(/*'\u2606'*/"a", 5));
    String nowS= StringUtils.repeat(/*'\u2605'*/"a", 5);
    String maxS= StringUtils.repeat(/*'\u2606'*/"b", 5);
    String cS= nowS+ maxS;
    Matcher matcher = new Pattern("[\\s]{1,5}").matcher(cS);
    AtomicInteger ip = new AtomicInteger();
    FontRenderer fr = Minecraft.getInstance().fontRenderer;
    while (matcher.find())
    {
        //drawText(matcher.group(), 2, 2);
        gui.drawCenteredString(fr, "Test123", 20, 20, 0xffFFFFFF);
        ip.set(ip.get() + 11);
    }
}

 

 

public static final int FULL_COLOR = Regions.colorFromRGB(255, 255, 255, 255)
public static int colorFromRGB(Number red, Number green, Number blue, Number alpha)
{
    return red.intValue() << 16 | green.intValue() << 8 | blue.intValue() | alpha.intValue() << 24;
}
public static void drawText(String s, int w, int h)
{
    FontRenderer fr = Minecraft.getInstance().fontRenderer;
    fr.drawStringWithShadow(s, (float) w, (float) h, FULL_COLOR);}

 

 

 

Edited January 18 by Peyang
  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7699

diesieben07

diesieben07    7699

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7699
  • 56430 posts
Posted January 18

The drawText you posted is not even valid Java...

  • Quote

Share this post


Link to post
Share on other sites

Peyang    0

Peyang

Peyang    0

  • Tree Puncher
  • Peyang
  • Members
  • 0
  • 8 posts
Posted January 18

I'm sorry, when pasting from IDE, the variable name seems to disappear around the color...

It actually compiles and draw () seems to be running. <-Checked with standard output.

Also, my code is posted on GitHub, and if you have any questions, please take a look there. Also, I modified the code. https://github.com/TeamKun/GTA5WantedDisplayMod

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7699

diesieben07

diesieben07    7699

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7699
  • 56430 posts
Posted January 18

I cloned your repository, however it does not even let you get into a world, because your network version check is broken (it always rejects the server side version number).

Additionally, the only way the code ever draws something is if nowWanted is not 0. The only code path that sets nowWanted is WantedDisplay#set, which is called from PacketContainer (sidenote: what on earth is that packet sending code doing?!). PacketContainer is never sent by the server. In conclusion: nowWanted is always 0, so nothing ever draws - if you would even get into the world.

  • Quote

Share this post


Link to post
Share on other sites

Peyang    0

Peyang

Peyang    0

  • Tree Puncher
  • Peyang
  • Members
  • 0
  • 8 posts
Posted January 18

Originally it was created to connect Bukkit and Forge with a Plugin Message. nowWanted is a dedicated plug-in "https://github.com/TeamKun/GTAWantedDisplayTestPlugin" Changed from "/ wanted <max> <now>".

The server is Bukkit Server, not Forge Server.

Also, nowWanted if passed safely and I was able to get standard output.

I look forward to working with you.

Also, this mod does not need to send packets, it intercepts packets from the server.

I pushed the code for this log.

public void draw()
{

    if (nowWanted == 0)
        return;
    System.out.println("nowWanted: " + nowWanted);

image.png.cd88f8ed3c2ac12f449b52c7f32a6687.png

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7699

diesieben07

diesieben07    7699

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7699
  • 56430 posts
Posted January 18

Please provide a way for me to actually test this.

  • Quote

Share this post


Link to post
Share on other sites

Peyang    0

Peyang

Peyang    0

  • Tree Puncher
  • Peyang
  • Members
  • 0
  • 8 posts
Posted January 18

This is a mod that reproduces the GTA Wanted Star.
1. Build a PaperMC 1.15.2 server.
2. Copy https://github.com/TeamKun/GTAWantedDisplayTestPlugin/releases to plugins and do /reload or /restart.
3. Build https://github.com/TeamKun/GTA5WantedDisplayMod and enter the Bukkit server.
4. From the player, run /wanted <maxWanted> <nowWanted>.
Note: maxWanted is the maximum number of stars and nowWanted is the number of stars to change

Five stars will wrap to the next line.

Test case:


Input /wanted 10 4
Expected output: 
★★★★☆
☆☆☆☆☆

 

Input /wanted 5 3
Expected output: 
★★★☆☆

 

Input /wanted 20 13
Expected output:
★★★★★
★★★★★
★★★☆☆
☆☆☆☆☆

 

I look forward to working with you.
Thank you

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7699

diesieben07

diesieben07    7699

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7699
  • 56430 posts
Posted January 18

Yeah no, I am not doing that lol. Way too much effort.

Your repo should be runnable out of the box.

  • Quote

Share this post


Link to post
Share on other sites

Peyang    0

Peyang

Peyang    0

  • Tree Puncher
  • Peyang
  • Members
  • 0
  • 8 posts
Posted January 18

Ah, I'm sorry.

I will try to reproduce it in personal project.

  • Quote

Share this post


Link to post
Share on other sites

Peyang    0

Peyang

Peyang    0

  • Tree Puncher
  • Peyang
  • Members
  • 0
  • 8 posts
Posted January 18

When I reproduced it as another mod, it worked fine.

I'll port the code to this mod and test it.

I would appreciate it if you could tell me why it doesn't work.

https://github.com/Yuki-At/RenderMod

  • Quote

Share this post


Link to post
Share on other sites

Peyang    0

Peyang

Peyang    0

  • Tree Puncher
  • Peyang
  • Members
  • 0
  • 8 posts
Posted January 18

Apparently my repository is cursed.
It worked perfectly in other repositories.
Thank you very much.

  • Quote

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • troublemaker_47
      TeleportCommand Help

      By troublemaker_47 · Posted 1 hour ago

      Hello, I am a beginner minecraft modder and i have some problems with a bit of code that would teleport the player in the direction he's facing.can anyone tell me How to merge these lines together: player.getLookVec().scale(2.0F).add(player.getPositionVec()); TeleportCommand;   P.S: i need this to work in minecraft 1.16.5-36.0.15
    • skeletal
      unable to connect to my server

      By skeletal · Posted 1 hour ago

      hello, every time i try to join my modded server i get the "fatally missing registry entries" error and the "minecraft:wheat (net.minecraft.crafting.shapedrecipies) produces unregistered item minecraft:wheat" error and i dont know what to do, any help would be appreciated here is a screenshot of the console when i try to join:
    • <Gl33p_0r4nge>
      [1.16.4] Screen Render

      By <Gl33p_0r4nge> · Posted 2 hours ago

      Okay I see that no one probably know how but can you at least tell me where should I get the rendered player view?  
    • Luis_ST
      [1.16.5] Help with custom Backpack (slot background and mouse wheel move)

      By Luis_ST · Posted 3 hours ago

      I don't know what code I would still be helpful, so here are the relevant classes in my git repo: TextureStitchEvent: https://github.com/Luis-st/Forge-1.16.5-36.0.1-mdk/blob/main/forge-1.16.5-36.0.1-mdk/src/main/java/net/luis/cave/events/other/OnTextureStitchEvent.java BackpackContainer (with custom slot subclass): https://github.com/Luis-st/Forge-1.16.5-36.0.1-mdk/blob/main/forge-1.16.5-36.0.1-mdk/src/main/java/net/luis/cave/common/inventory/container/BackpackContainer.java   I think I understood after trying something: my message class requires 3 methods (encode, decode, handle) which I then have to specify when registering the message (parameter 3 - 6). Am I right?
    • troublemaker_47
      Teleport player in same direction as where he looks

      By troublemaker_47 · Posted 4 hours ago

      Can you please tell me how to use the teleportcommand method or its syntax. @diesieben07
  • Topics

    • troublemaker_47
      0
      TeleportCommand Help

      By troublemaker_47
      Started 1 hour ago

    • skeletal
      0
      unable to connect to my server

      By skeletal
      Started 1 hour ago

    • <Gl33p_0r4nge>
      1
      [1.16.4] Screen Render

      By <Gl33p_0r4nge>
      Started Monday at 02:58 PM

    • Luis_ST
      9
      [1.16.5] Help with custom Backpack (slot background and mouse wheel move)

      By Luis_ST
      Started Wednesday at 07:47 AM

    • troublemaker_47
      7
      Teleport player in same direction as where he looks

      By troublemaker_47
      Started 21 hours ago

  • Who's Online (See full list)

    • <Gl33p_0r4nge>
    • brok4d
    • DmitryLovin
    • Luis_ST
    • matezz
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.15.2] Display text in the upper right
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community