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    7697

diesieben07

diesieben07    7697

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7697
  • 56382 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    7697

diesieben07

diesieben07    7697

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7697
  • 56382 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    7697

diesieben07

diesieben07    7697

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7697
  • 56382 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    7697

diesieben07

diesieben07    7697

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7697
  • 56382 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    7697

diesieben07

diesieben07    7697

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7697
  • 56382 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

    • GhostGamesFSM
      1.16 Ore generation.

      By GhostGamesFSM · Posted 10 minutes ago

      sorry for the txt, but thanks for the comment. I don't have a BiomeLoadingEvent, but I just have to see how I do that. When I have that I send you a message if that works.
    • HOTSAUCEMAN
      help with loading my world

      By HOTSAUCEMAN · Posted 11 minutes ago

      just ran it again to get more updated logs  debug-1.log.gz
    • HOTSAUCEMAN
      help with loading my world

      By HOTSAUCEMAN · Posted 15 minutes ago

      when loading into my world it says its loading, and then changes to a dirt background with no text; i've looked at multiple threads, forums and videos but i can't find any issue similar to mine (at least on a similar version)  debug-1.log.gz
    • Beethoven92
      [1.16.5] Beacon Overwrite (Screen Error)

      By Beethoven92 · Posted 22 minutes ago

      I apologize...i misread the part where you say that your custom beacon inventory actually opens fine! Yeah, the proximity check is doing its job, the problem seems to be that when pressing the confirm button you are sending a vanilla CUpdateBeaconPacket, then handled by the server, which will check if your open container is a BeaconContainer. It would be helpful to see the complete code you have, please post a link to your repository
    • Beethoven92
      [1.16.5] How to make EnchantedBook go to Custom ItemGroup

      By Beethoven92 · Posted 40 minutes ago

      Show what you tried then. It should be "enchantment.your_mod_id.your_enchantment_id"
  • Topics

    • GhostGamesFSM
      2
      1.16 Ore generation.

      By GhostGamesFSM
      Started 17 hours ago

    • HOTSAUCEMAN
      1
      help with loading my world

      By HOTSAUCEMAN
      Started 15 minutes ago

    • Nyko
      3
      [1.16.5] Beacon Overwrite (Screen Error)

      By Nyko
      Started Yesterday at 07:22 AM

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

      By samjviana
      Started Sunday at 10:00 PM

    • DrigglyEast
      0
      Fatally Missing Registry Entries

      By DrigglyEast
      Started 2 hours ago

  • Who's Online (See full list)

    • EdekaKuchen
    • alexro871
    • GhostGamesFSM
    • Beethoven92
    • IntentScarab
    • CookieLukas
    • Tavi007
    • HOTSAUCEMAN
    • zlappedx3
  • 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