Started by
SomeoneElse
on
Topic category: User side tutorials
(this tutorial is specifically for plants on vanilla blocks. Eventually, I might just redo this tutorial for any block)
- Create your plant element;
- Open the code of the plant element, add this line in the list of imports;
import net.minecraft.init.Blocks;
-
Add this
@Override protected boolean canSustainBush(IBlockState state) { return state.getBlock() == Blocks.BLOCK; }
-
You can change the blocks the plant can grow on by editing "Blocks.BLOCK" (typing Blocks. shows a list of all vanilla blocks)
You can add more blocks by adding "|| state.getBlock() == Blocks.BLOCK" to the list.
This doesn't prevent plants from growing on grass and dirt, but you can check my other comment for a fix.
You can also use materials instead of specific blocks by using:
import net.minecraft.block.material.Material;
state.getMaterial() == Material.MATERIAL
Edited by SomeoneElse on Mon, 09/30/2019 - 22:26
Where exactly do we add the:
@Override
protected boolean canSustainBush(IBlockState state)
{
return state.getBlock() == Blocks.BLOCK;
}
Pretty much anywhere inside of
Since I made this tutorial, I found a way to remove dirt and grass. The required code is
as well as
If you don't use Blocks.DIRT or Blocks.GRASS, the plant won't be able to grow on those blocks. Also, make sure the list of 'block ==' is the same in all the three methods. You might have to reformat the imports (ctrl+w)
Where do I add the "@Override protected boolean canSustainBush(IBlockState state) { return state.getBlock() == Blocks.BLOCK; }" Do I press shift and do it 1 line under and paste it? or do I paste it on the same line as "import net.minecraft.init.Blocks;" I'm not sure and I'm confused.
Sorry if I took a while to reply, I made some example code you can look at. Hopefully that should clear things up
is there a newer method? Its not working for me because the import doesnt exist /:
Are you using 1.14? This was made for 1.12; I'll try to find a way to do this in 1.14 too
You can make it so that if the block below the plant isn't the particular block, your plant breaks.
hi i am new on mcretor i wanted to ask if it is possible to make a plant created by me born on a block created by me?