Hi,
I'm having a problem reading the "large text" (titles/subtitles) displayed on screen.
The only reference to this problem I could find was in version 1.8 on this forum:
From that thread, the following code would retrieve the on-screen title by using Forge's ReflectionHelper to read protected fields:
String title = (String) ReflectionHelper.findField(GuiIngame.class, "displayedTitle", "field_175201_x").get(Minecraft.getMinecraft().ingameGUI);
alternatively using:
String title = ReflectionHelper.getPrivateValue(GuiIngame.class, Minecraft.getMinecraft().ingameGUI, "field_175201_x", "displayedTitle");
However, in 1.14, 1.12, and even 1.8 (for me), this returns an empty string no matter what, unless I manually set the field using
ReflectionHelper.findField(GuiIngame.class, "displayedTitle", "field_175201_x").set(ClientUtils.mc().ingameGUI, "Hey this is a title sort of");
Setting the field in this will NOT create a title onscreen, and the actual onscreen title has no bearing on this field- I tested with in-game title commands, and titles set via:
Minecraft.getMinecraft().ingameGUI.displayTitle("This will create an actual functional title", "But I can't access it with reflections", 0, 60, 1);
Is there an alternative to reflections in modern minecraft versions? Or am I missing something? I feel like I'm not accessing the correct instance of GuiInGame, however I can call methods on that instance just fine, so it might be reflections. I have never used reflections prior to this.
Using reflections without Forge's wrapper also produced the same result:
Field f = GuiIngame.class.getDeclaredField("displayedTitle");
f.setAccessible(true);
System.out.println(f.get(Minecraft.getMinecraft().ingameGUI));