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    7695

diesieben07

diesieben07    7695

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7695
  • 56361 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    7695

diesieben07

diesieben07    7695

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7695
  • 56361 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    7695

diesieben07

diesieben07    7695

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7695
  • 56361 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    7695

diesieben07

diesieben07    7695

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7695
  • 56361 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    7695

diesieben07

diesieben07    7695

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7695
  • 56361 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

    • cadbane86140
      Minecraft: Cereal UHC Season 2 Episode 5- THE FINALE!

      By cadbane86140 · Posted 2 hours ago

      Hello There! A bit of a late upload due to technical issues but ITS UP! So after a week of Cereal UHC we have finally reached the end of it! I am so thankful to be apart of this series and I can't wait for the next season! There are so many hilarious moments especially during the final battle! I hope you all enjoyed this series and if you did don't forget to like and sub for more!  
    • samjviana
      [1.16.5] How to make EnchantedBook go to Custom ItemGroup

      By samjviana · Posted 3 hours ago

      But how can i do that for an enchantment book, for normal items i was able to do that by calling the function "group" as you said, but with the enchantment seems to be different.
    • poopoodice
      [1.16.5] How to make EnchantedBook go to Custom ItemGroup

      By poopoodice · Posted 4 hours ago

      Just create an instance of ItemGroup, and set the group of the item in the item property builder.
    • poopoodice
      Trying to make a crop have an "X" shape model

      By poopoodice · Posted 4 hours ago

      Check the parent of their block model.
    • LexManos
      Forge says this file does not have an app associated with it.

      By LexManos · Posted 4 hours ago

      Some zip managers like to take control of the .jar file extension away from Java. Make sure you have Java installed and try running Jarfix once, then try the installer again.
  • Topics

    • cadbane86140
      0
      Minecraft: Cereal UHC Season 2 Episode 5- THE FINALE!

      By cadbane86140
      Started 2 hours ago

    • samjviana
      2
      [1.16.5] How to make EnchantedBook go to Custom ItemGroup

      By samjviana
      Started 6 hours ago

    • TheMajorN
      1
      Trying to make a crop have an "X" shape model

      By TheMajorN
      Started 5 hours ago

    • ESCCarp
      3
      Forge says this file does not have an app associated with it.

      By ESCCarp
      Started 8 hours ago

    • hammy3502
      0
      [1.16.4] Fluid Flowing Very Oddly

      By hammy3502
      Started 5 hours ago

  • Who's Online (See full list)

    • brok4d
  • 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