poopoodice Posted September 30, 2020 Share Posted September 30, 2020 (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 September 30, 2020 by poopoodice Quote Link to comment Share on other sites More sharing options...
ChampionAsh5357 Posted September 30, 2020 Share Posted September 30, 2020 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. Quote Link to comment Share on other sites More sharing options...
poopoodice Posted October 1, 2020 Author Share Posted October 1, 2020 (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 October 1, 2020 by poopoodice Quote Link to comment Share on other sites More sharing options...
Draco18s Posted October 1, 2020 Share Posted October 1, 2020 Use a Supplier<Item>, same way you would for TabGroups. 1 Quote 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. Link to comment Share on other sites More sharing options...
ChampionAsh5357 Posted October 1, 2020 Share Posted October 1, 2020 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). 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.