I'm currently making a grass like block. I've setup it so that plants can grow on it and such but I'm also trying to figure out how to make the grass block spread to my dirt block as well. I feel like it has something to do with the updateTick but I'm not 100% sure. My code for my grass block is as follows.
package com.mja00.whyMod.blocks;
import java.util.Random;
import javax.annotation.Nonnull;
import com.mja00.whyMod.init.ModBlocks;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.world.World;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.EnumPlantType;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.fml.common.Mod;
public class GrussBlock extends BlockBase {
public GrussBlock(String name, Material material) {
super(name, material);
setSoundType(SoundType.GROUND);
setHardness(0.5f);
setResistance(2.5f);
setHarvestLevel("shovel", 0);
}
@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
return ModBlocks.DURT.getItemDropped(state, rand, 1);
}
@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand){
}
@Override
public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, IPlantable plantable)
{
IBlockState plant = plantable.getPlant(world, pos.offset(direction));
net.minecraftforge.common.EnumPlantType plantType = plantable.getPlantType(world, pos.offset(direction));
if(plant.getBlock() == Blocks.SAPLING)
return true;
if(plantType == EnumPlantType.Plains)
return true;
return false;
}
}
I'm just stuck and need a little guidance.