Jump to content

Toinou9120

Members
  • Posts

    10
  • Joined

  • Last visited

Everything posted by Toinou9120

  1. Hello, In my mod, I use the Java URLConnection to connect to a website and get some stats. I connect to the website with a TickEvent.ClientTickEvent event, but it takes like 2-3 sec so the game freeze during this time. Is this possible to run this code in a background thread or something that will not freeze the game ?
  2. Problem solved, I now use this to get the player name : name = networkPlayerInfoIn.getGameProfile().getName();
  3. Hello, I want to get the raw name of a player rendered in the player list, but when I use getUnformattedComponentText(), the game crash. Here is my code : package com.example.examplemod; import java.util.List; import javax.annotation.Nullable; import com.mojang.authlib.GameProfile; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiIngame; import net.minecraft.client.gui.GuiPlayerTabOverlay; import net.minecraft.client.network.NetHandlerPlayClient; import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EnumPlayerModelParts; import net.minecraft.scoreboard.IScoreCriteria; import net.minecraft.scoreboard.ScoreObjective; import net.minecraft.scoreboard.ScorePlayerTeam; import net.minecraft.scoreboard.Scoreboard; import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextFormatting; import net.minecraft.world.GameType; import net.minecraftforge.fml.relauncher.ReflectionHelper; public class TabOverlay extends GuiPlayerTabOverlay { String playerName = ""; String name = ""; public TabOverlay(Minecraft mcIn, GuiIngame guiIngameIn) { super(mcIn, guiIngameIn); } ReflectionHelper ref; GuiPlayerTabOverlay gui; /** * Returns the name that should be renderd for the player supplied */ @Override public String getPlayerName(NetworkPlayerInfo networkPlayerInfoIn) { playerName = networkPlayerInfoIn.getDisplayName() != null ? networkPlayerInfoIn.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfoIn.getPlayerTeam(), networkPlayerInfoIn.getGameProfile().getName()); name = networkPlayerInfoIn.getDisplayName().getUnformattedComponentText(); // this is the line 48 //Rest of code } } And here is the error in the log : java.lang.NullPointerException: null at com.example.examplemod.TabOverlay.func_175243_a(TabOverlay.java:48) ~[TabOverlay.class:?] at net.minecraft.client.gui.GuiPlayerTabOverlay.func_175249_a(SourceFile:74) ~[bjq.class:?] at net.minecraftforge.client.GuiIngameForge.renderPlayerList(GuiIngameForge.java:837) ~[GuiIngameForge.class:?] at net.minecraftforge.client.GuiIngameForge.func_175180_a(GuiIngameForge.java:200) ~[GuiIngameForge.class:?] at net.minecraft.client.renderer.EntityRenderer.func_181560_a(EntityRenderer.java:1098) ~[buq.class:?] at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:1117) ~[bib.class:?] at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:397) [bib.class:?] at net.minecraft.client.main.Main.main(SourceFile:123) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_25] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_25] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_25] at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_25] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] I don't understand why there is this error. Does someone know ?
  4. So I used the ReflectionHelper class, so this is my new EventHandler class : @SubscribeEvent public void onTickEvent(TickEvent.ClientTickEvent e) { if(e.phase == Phase.START) { TabOverlay tab = new TabOverlay(Minecraft.getMinecraft(), Minecraft.getMinecraft().ingameGUI); try { ReflectionHelper ref = new ReflectionHelper(); ref.setPrivateValue(GuiIngame.class, Minecraft.getMinecraft().ingameGUI, tab, "field_175196_v"); } catch (SecurityException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IllegalArgumentException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } } But it throws a NoSuchFieldException, this is the crash report : net.minecraftforge.fml.relauncher.ReflectionHelper$UnableToAccessFieldException: net.minecraftforge.fml.relauncher.ReflectionHelper$UnableToFindFieldException: java.lang.NoSuchFieldException: field_175196_v at net.minecraftforge.fml.relauncher.ReflectionHelper.setPrivateValue(ReflectionHelper.java:170) at com.example.examplemod.Event.onTickEvent(Event.java:32) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_9_Event_onTickEvent_ClientTickEvent.invoke(.dynamic) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:179) at net.minecraftforge.fml.common.FMLCommonHandler.onPreClientTick(FMLCommonHandler.java:342) at net.minecraft.client.Minecraft.runTick(Minecraft.java:1815) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1171) at net.minecraft.client.Minecraft.run(Minecraft.java:436) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26) Caused by: net.minecraftforge.fml.relauncher.ReflectionHelper$UnableToFindFieldException: java.lang.NoSuchFieldException: field_175196_v at net.minecraftforge.fml.relauncher.ReflectionHelper.findField(ReflectionHelper.java:117) at net.minecraftforge.fml.relauncher.ReflectionHelper.setPrivateValue(ReflectionHelper.java:166) ... 21 more Caused by: java.lang.NoSuchFieldException: field_175196_v at java.lang.Class.getDeclaredField(Unknown Source) at net.minecraftforge.fml.relauncher.ReflectionHelper.findField(ReflectionHelper.java:108) ... 22 more Do you know what is the issue ?
  5. So I tried to do this, but it does not work. I think there are errors in my code. This is my TabOverlay class : public class TabOverlay extends GuiPlayerTabOverlay { public TabOverlay(Minecraft mcIn, GuiIngame guiIngameIn) { super(mcIn, guiIngameIn); } GuiPlayerTabOverlay gui; /** * Returns the name that should be renderd for the player supplied */ @Override public String getPlayerName(NetworkPlayerInfo networkPlayerInfoIn) { return gui.getPlayerName(networkPlayerInfoIn) + "a"; } } And this is my EventHandler class where I handle the TickEvent : @SubscribeEvent public void onTickEvent(TickEvent.ClientTickEvent e) { if(e.phase == Phase.START) { TabOverlay tab = new TabOverlay(Minecraft.getMinecraft(), Minecraft.getMinecraft().ingameGUI); try { Field overlay = GuiIngame.class.getDeclaredField("overlayPlayerList"); overlay.setAccessible(true); overlay.set(Minecraft.getMinecraft().ingameGUI, tab); } catch (NoSuchFieldException | SecurityException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IllegalArgumentException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IllegalAccessException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } } There is a layout problem with the code integration, but I don't know why. I rarely use reflection so maybe I don't use it correctly or maybe this is the TabOverlay class that is false. Can you help me ?
  6. Thank for your really complete answer, I'm not a native english speaker so I have some difficulties to understand the step. What i have understand is that : - I must create a class that extends GuiPlayerTabOverlay and override the getPlayerName method so I can modify what it return - Then I should get an instance of the GuiIngame But after, I can't grab the overlayPlayerList beacause it's protected, so I don't understand how to do this. Can you explain ? I'm sorry if it's simple and I just have a lack of vocabulary to understand what you said.
  7. Thank for your answer. When I meant level, I didn't mean xp level, I mean a server minigame level, that I get from a statistics website. When you say "draw", are you talking about the draw fonction in OpenGL ? And another question, I need to draw the level of the player after his name in the player liste, so how do I get the actual content of the player list to know where to draw the level of the player ?
  8. Hello, I'm making a client-sided mod where I need to write some infos about a player in the player list, like the level of the player ect. But I don't know how to modify the content of the player list. I looked in the RenderGameOverlayEvent class and thought about reflection but I don't know what I should get and modify in this class. Can someone help me ?
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.