- 12
- 2
- 0
Как получить buttonList или отображать свой gui поверх ванильного gui?
Пробовал это, не сработало
Пробовал это, не сработало
Java:
@SubscribeEvent
public void onMultiplayerMenu(GuiOpenEvent event) {
try
{
GuiScreen activeGUI = Minecraft.getMinecraft().currentScreen;
if(activeGUI != null && activeGUI instanceof GuiMultiplayer) //whatever GUI you want to add a/multiple button/s to
{
Field field = GuiScreen.class.getDeclaredField("buttonList");
field.setAccessible(true);
List buttonList = (List) field.get(activeGUI);
if(buttonList.size() < 1) //this has to be one smaller than the number of buttons it usually has, else you will keep adding your button over and oever again
{
buttonList.add(new GuiButton(100, 2, 5, "Nickname")); //you have to make a class extending GuiButton to add function to your button
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
}