Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

In previous versions, the Minecraft class had a method to getServerData(), which returned a variable which that class holds in memory.

 

    /**
     * Get the current ServerData instance.
     */
    public ServerData getServerData()
    {
        return this.currentServerData;
    }

 

I went back into my MCP 1.5.2 folder, and here is the exact code... currentServerData is a private variable and that's why I need the getter for it, the strangest thing about it is that the setter is there, but then the variable is never used.

  • Author

I need the serverdata simply to show servername and ip (hidden if hidden in the serverlist) above the playerlist gui.

 

I used reflection, but it causes issues because I'm not sure what the obfuscated name is... And I'm trying to stay away from becoming a coremod...

There are a few places I needed to do something similar,

I first try for the obfuscated name and if that fails check for the "normal" name

 

I've been looking up the obfuscated names in these files.

 

/mcp/config/fields.csv

/mcp/config/methods.csv

 

In this case it looks like field_71422_O is currentServerData

 

you can also go to the mcp irc channel and by whispering the bot get the data,

that way is much easier when there is a few that are similar in name (and the csv lacks a description) as the bot provides more info.

  • Author

Thanks ShetiPhian, but I just ended up doing this:

    public static ServerData getServerData() {
      Minecraft mc = Minecraft.getMinecraft();
      ServerData serverData = null;
      for (Field field : Minecraft.class.getDeclaredFields()) {
        if (field.getType() == ServerData.class) {
          field.setAccessible(true);
          try {
            serverData = (ServerData)field.get(mc);
          } catch (Exception e) {
            System.out.println("[TukMC] Unable to find server information ("  e.getCause().toString()")");
          }
        }
      }

      return serverData;
    }

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.