Posted October 10, 20178 yr 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 ?
October 11, 20178 yr Author 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 ?
October 11, 20178 yr Author 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. Edited October 11, 20178 yr by Toinou9120 mistake
October 13, 20178 yr Author 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 ? Edited October 13, 20178 yr by Toinou9120 Mistakes
October 13, 20178 yr Use the ReflectionHelper class instead of doing it yourself. When built and released, the field will not be called "overlayPlayerList" but something like field_89034_b Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
October 13, 20178 yr Author 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 ?
October 13, 20178 yr java.lang.NoSuchFieldException: field_175196_v You need to pass in both names. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
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.