Peyang Posted January 18, 2021 Share Posted January 18, 2021 (Please forgive me for using a translator. 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 Link to comment Share on other sites More sharing options...
Peyang Posted January 18, 2021 Author Share Posted January 18, 2021 (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, 2021 by Peyang Quote Link to comment Share on other sites More sharing options...
Peyang Posted January 18, 2021 Author Share Posted January 18, 2021 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 Link to comment Share on other sites More sharing options...
Peyang Posted January 18, 2021 Author Share Posted January 18, 2021 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); Quote Link to comment Share on other sites More sharing options...
Peyang Posted January 18, 2021 Author Share Posted January 18, 2021 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 Link to comment Share on other sites More sharing options...
Peyang Posted January 18, 2021 Author Share Posted January 18, 2021 Ah, I'm sorry. I will try to reproduce it in personal project. Quote Link to comment Share on other sites More sharing options...
Peyang Posted January 18, 2021 Author Share Posted January 18, 2021 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 Link to comment Share on other sites More sharing options...
Peyang Posted January 18, 2021 Author Share Posted January 18, 2021 Apparently my repository is cursed. It worked perfectly in other repositories. Thank you very much. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.