Jump to content

Recommended Posts

Posted

I have a block type with several instances that have different properties which I set in the constructor. I want the IPropertys that go into the BlockStateContainer to be dependent on the constructor parameters (nothing else needs to be overriden so I don't have subclasses), but createBlockState is called in the Block super constructor so that doesn't work. Is there any other way I can achieve this without having to manually override createBlockState for every instance of my block?

Posted

I have a sort of workaround. I'm constructing my own BlockStateContainer in my constructor (using my parameters), and then overriding getBlockState to return mine instead of Block#blockState. Although I also have to check if mine is null (meaning the method is being called from the super constructor) and return the default version if that's the case (which will then be ignored, but otherwise the super constructor throws an NPE). It's messy but, still less messy than making 10+ subclasses to override one method.

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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