I'm making a mod(as with all the other posts on my profile) and want to make a 2 block tall crop(corn, originally enough). The problem is I don't know how to do this. My general idea is this:
Make the seedFood(places the bottom block, which does not grow, but places the growing half on top)
Make the crop class, which is where I have no clue what I'm doing(extend blockCrop and DoublePlant,. That's about it)
I apologize for not being very knowledgeable in the field of modding, but it's just something I want to try and have no clue how to do.
EDIT: I thought it would be a good note to make that I have searched google, but maybe not enough.
Well, you have the idea already. Pretty much copy what vanilla does. You need to make a block that extends BlockCrops. Then you should go through all the methods in BlockCrops and see if there is anything you want to change. For example, the canSustainBush() method in vanilla looks for FARMLAND, but maybe you want your crop to grow in a different type of soil so you would change that. the canBlockStay() method also refers to the block below to check if it recognizes your plant using its canSustainPlant() method so you probably want to change that to also check for your soil preference. You will definitely want to override the getSeed() and getCrop() methods as they default to wheat. That's probably it.
Then you need to make the seed item. Depending on what you want you should extend ItemSeedFood or ItemSeeds. Again just go through the methods and override the ones that need to be changed for what you need.
Of course you also need to register your block and item and also make sure you have all the blockstate, model and texture assets in proper locations. Again look at an existing crop to get ideas on what should go into those files.
Now, all the of the above will make a regular crop that is 1 block high. To make a crop that is 2 blocks high takes a little bit of thought. There are a few ways to do it, but probably good to follow the way that double tall grass does it. This block is called BlockDoublePlant so you should look at that code. In that code you'll notice that there is an additional property called HALF which indicates whether the block is the bottom or the top half. So you need to add a similar property to your block.
Then, basically you use the property as follows:
- initially when planted the first block should have the HALF property set to bottom. So you would do this in your ItemSeedFood code, when the block is set you make sure the state is set correctly.
- in your block's grow() method, you should check the HALF property. If it is bottom and there is still more grow stages left, then just grow it. But once you have reached max grow stage the grow method should place another block above it, this time with the HALF property set to top.
- in your block's harvest-related methods you should look at BlockDoublePlant for ideas on how to code yours. Basically, it you harvest the top block it should also destroy the bottom block.
That's mostly it. Just follow the vanilla code as example, change what you need to change, and combine the properties from the BlockCrops with BlockDoublePlant.
I'm making a mod(as with all the other posts on my profile) and want to make a 2 block tall crop(corn, originally enough). The problem is I don't know how to do this. My general idea is this:
Make the seedFood(places the bottom block, which does not grow, but places the growing half on top)
Make the crop class, which is where I have no clue what I'm doing(extend blockCrop and DoublePlant,. That's about it)
I apologize for not being very knowledgeable in the field of modding, but it's just something I want to try and have no clue how to do.
EDIT: I thought it would be a good note to make that I have searched google, but maybe not enough.
Well, you have the idea already. Pretty much copy what vanilla does. You need to make a block that extends BlockCrops. Then you should go through all the methods in BlockCrops and see if there is anything you want to change. For example, the canSustainBush() method in vanilla looks for FARMLAND, but maybe you want your crop to grow in a different type of soil so you would change that. the canBlockStay() method also refers to the block below to check if it recognizes your plant using its canSustainPlant() method so you probably want to change that to also check for your soil preference. You will definitely want to override the getSeed() and getCrop() methods as they default to wheat. That's probably it.
Then you need to make the seed item. Depending on what you want you should extend ItemSeedFood or ItemSeeds. Again just go through the methods and override the ones that need to be changed for what you need.
Of course you also need to register your block and item and also make sure you have all the blockstate, model and texture assets in proper locations. Again look at an existing crop to get ideas on what should go into those files.
Now, all the of the above will make a regular crop that is 1 block high. To make a crop that is 2 blocks high takes a little bit of thought. There are a few ways to do it, but probably good to follow the way that double tall grass does it. This block is called BlockDoublePlant so you should look at that code. In that code you'll notice that there is an additional property called HALF which indicates whether the block is the bottom or the top half. So you need to add a similar property to your block.
Then, basically you use the property as follows:
- initially when planted the first block should have the HALF property set to bottom. So you would do this in your ItemSeedFood code, when the block is set you make sure the state is set correctly.
- in your block's grow() method, you should check the HALF property. If it is bottom and there is still more grow stages left, then just grow it. But once you have reached max grow stage the grow method should place another block above it, this time with the HALF property set to top.
- in your block's harvest-related methods you should look at BlockDoublePlant for ideas on how to code yours. Basically, it you harvest the top block it should also destroy the bottom block.
That's mostly it. Just follow the vanilla code as example, change what you need to change, and combine the properties from the BlockCrops with BlockDoublePlant.