Jump to content
Search In
  • More options...
Find results that contain...
Find results in...


  • Posts

  • Joined

  • Last visited

Posts posted by Braydongem

  1. Hello,


    I've been trying to make my custom crop and I got stuck. The crop can be planted on farmland and growth can be sped up with bone meal but it doesn't want to grow by itself.

    Any help is appreciated!


    Custom crop class:

    package mariot7.xlfoodmod.blocks;
    import java.util.Random;
    import mariot7.xlfoodmod.XLFoodMod;
    import mariot7.xlfoodmod.init.ItemListXL;
    import net.minecraft.block.Block;
    import net.minecraft.block.BlockState;
    import net.minecraft.block.CropsBlock;
    import net.minecraft.block.FarmlandBlock;
    import net.minecraft.block.IGrowable;
    import net.minecraft.block.SoundType;
    import net.minecraft.block.material.Material;
    import net.minecraft.item.ItemStack;
    import net.minecraft.state.IntegerProperty;
    import net.minecraft.state.StateContainer;
    import net.minecraft.state.properties.BlockStateProperties;
    import net.minecraft.util.IItemProvider;
    import net.minecraft.util.math.BlockPos;
    import net.minecraft.world.IBlockReader;
    import net.minecraft.world.IWorldReader;
    import net.minecraft.world.World;
    import net.minecraftforge.api.distmarker.Dist;
    import net.minecraftforge.api.distmarker.OnlyIn;
    public class TomatoPlant extends CropsBlock implements IGrowable {
    	public static final IntegerProperty TOMATO_PLANT_AGE = BlockStateProperties.AGE_0_7;
        public TomatoPlant(String name)
            this.setRegistryName(XLFoodMod.MOD_ID, name);
            this.setDefaultState(this.stateContainer.getBaseState().with(this.getAgeProperty(), Integer.valueOf(0)));
        protected IItemProvider getSeedsItem()
           return ItemListXL.TOMATO_SEEDS;
        public ItemStack getItem(IBlockReader worldIn, BlockPos pos, BlockState state)
           return new ItemStack(this.getSeedsItem());
        protected boolean isValidGround(BlockState state, IBlockReader worldIn, BlockPos pos)
            return state.getBlock() instanceof FarmlandBlock;
        public IntegerProperty getAgeProperty()
            return TOMATO_PLANT_AGE;
        public int getMaxAge()
        	return 7;
        public boolean canGrow(IBlockReader worldIn, BlockPos pos, BlockState state, boolean isClient)
        	return !this.isMaxAge(state);
        public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, BlockState state)
        	return true;
        public void grow(World worldIn, Random rand, BlockPos pos, BlockState state)
        	this.grow(worldIn, pos, state);
        protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder)


    Edit: fixed. I forgot to add .tickRandomly() in properties.

    • Like 1
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.