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.

Subclassing class with a private constructor - Access Transformer or reflection?

Featured Replies

Posted

I'm wanting to create a custom WorldType (similar to BOP), but the WorldType class has only private constructors.  What's the best way to get around this -- using Access Transformation, or Reflection?  I've looked at BOP, and it seems to be using Access Transformation since the WorldType class has public constructors there.

 

I understand how to use reflection for normal fields and methods, but I'm wondering how it could be used for a constructor since the super() call has to be the first line in the subclass's constructor.

 

Thanks for your assistance!

The best protection for all you meat-related data.

If you scroll to the Forge section in

WorldType

, you see Forge adds a constructor that only takes the name of the

WorldType

. You can use that.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

One question - why the heck do you need those constructors? Those 2 constructoors are internal ones that should NOT be touched.

 

Only one you should be overriding is:

/**
     * Creates a new world type, the ID is hidden and should not be referenced by modders.
     * It will automatically expand the underlying workdType array if there are no IDs left.
     * @param name
     */
    public WorldType(String name)
    {
        this(getNextID(), name);
    }

 

Edit: I didn't notice previous post ;o

1.7.10 is no longer supported by forge, you are on your own.

  • Author

Thanks all.  I didn't see that constructor because it was added by forge and "under the line" (i.e. at the bottom below the separator comment).  I'm used to constructors being at the top of a class by convention, so I didn't look down there.

 

I agree that is the one to use, now that I know it's there.

 

The best protection for all you meat-related data.

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.