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

So in Minecraft 1.7.10, the Minecraft session field is private and final. I can change it to public with an access transformer (which is easy) but I can't actually modify the session id because it's final. Is there a way to edit this or would I have to code a fully custom client?

  • Author

So I used the same method as in the stackoverflow post but I get a field not found exception when I tell it to modify Minecraft.class.getField("session")

First of all, I suggest using either the ReflectionHelper or ObfuscationReflectionHelper classes - they make cleaner code, and change this:

 

try
{
    Field field = SomeClass.class.getDeclaredField("someFieldName");
    field.setAccessible(true);
    Object object = field.get(SOMECLASS_INSTANCE);
    //do stuff
}
catch (Exception e)
{
    try
    {
        Field field = SomeClass.class.getDeclaredField("field_SRG_NAME");
        field.setAccessible(true);
        Object object = field.get(SOMECLASS_INSTANCE);
        //do stuff
    }
    catch(Exception e2)
    {
        //Log exception
    }
}

 

into

 

Object object = ReflectionHelper.getPrivateValue(SomeClass.class, SOMECLASS_INSTANCE, "someFieldName", "field_SRG_NAME");

 

Much cleaner.

 

Example code

Field sessionField = ReflectionHelper.findField(Minecraft.class, "session", "field_71449_j");
ReflectionHelper.setPrivateValue(Field.class, sessionField, sessionField.getModifiers() & ~Modifier.FINAL, "modifiers");
ReflectionHelper.setPrivateValue(Minecraft.class, Minecraft.getMinecraft(), YOUR_SESSION_INSTANCE, "session", "field_71449_j");

BEFORE ASKING FOR HELP READ THE EAQ!

 

I'll help if I can. Apologies if I do something obviously stupid. :D

 

If you don't know basic Java yet, go and follow these tutorials.

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.