Jump to content

Recommended Posts

Posted (edited)

Vanilla creates class per plants, for example CarrotBlock, BeetrootBlock, PotatoCrop.

They all do the same thing except they return different items in getSeedsItem() which called form Block#getItem.

For me it seems a bit redundant, but since items are registered after blocks, you can't pass it through the constructor, so I have two question here:

1. What's the reason of overriding getItem and return getSeedsItem() (the only explanation I can think of is they are not block items), and is it necessary?

2. Is there an alternative way of creating class for each crop? Maybe annotation @ObjectHolder works here?

Edited by poopoodice
Posted

1. It's specifically used for the creative block pick button. It's a substitute from having no item given since an item form of the block doesn't exist. It's just handy to return the things you plant. Although technically each plantable item is the BlockItem of the crop.

2. I'm confused what you mean by this. A crop block is only for ticking the current age. Anything that makes the block it's actual self is handled by the loot table or the item placement.

Posted (edited)

What I mean in the second question is do I need to counterfeit how vanilla does it - create class for every single crop, or

1 hour ago, ChampionAsh5357 said:

Although technically each plantable item is the BlockItem of the crop.

it is not "needed".

 

If it has its necessarily, is there an alternative way rather than creating class for each crop, but achieves the same target as overriding getSeedsItem()? Since I can't just simply pass the items through the constructor (registration orders), how would I do? Maybe annotation @ObjectHolder can be used if I want to pass the item into the constructor?

Edited by poopoodice
Posted

Use a Supplier<Item>, same way you would for TabGroups.

  • Thanks 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
43 minutes ago, Draco18s said:

Use a Supplier<Item>, same way you would for TabGroups.

In addition, you could store the supplier in a Lazy. What they essentially do is use the supplier once to grab the item and then keep the first accessed result. This makes the result deterministic and unchangeable (which is pretty much what you're going for).

  • Thanks 1

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.