This is most likely pretty simple.
I have been trying to get my custom sapling to grow on my custom dirt block but I can't seem to find anything that I could edit to allow that to happen. I can place the sapling on my dirt just fine (but it will not grow), it also will grow just fine if placed on normal dirt or grass
and will grow just fine. Below is my code for my sapling and block bush (they are most likely pretty bad as this is my first time using forge/minecraft again in a few years).
BlockAmboynaSap
package epicarno.mystical.common.block;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFlower;
import net.minecraft.block.BlockPlanks;
import net.minecraft.block.BlockSapling;
import net.minecraft.block.IGrowable;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenBigTree;
import net.minecraft.world.gen.feature.WorldGenCanopyTree;
import net.minecraft.world.gen.feature.WorldGenForest;
import net.minecraft.world.gen.feature.WorldGenMegaJungle;
import net.minecraft.world.gen.feature.WorldGenMegaPineTree;
import net.minecraft.world.gen.feature.WorldGenSavannaTree;
import net.minecraft.world.gen.feature.WorldGenTaiga2;
import net.minecraft.world.gen.feature.WorldGenTrees;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import epicarno.mystical.common.di.GenAmboynaTree;
public class BlockAmboynaSap extends BlockEpicarnoBush implements IGrowable
{
private final String name = "AmboynaSap";
public static final PropertyEnum TYPE = PropertyEnum.create("type", BlockPlanks.EnumType.class);
public static final PropertyInteger STAGE = PropertyInteger.create("stage", 0, 1);
public BlockAmboynaSap()
{
this.setDefaultState(this.blockState.getBaseState().withProperty(TYPE, BlockPlanks.EnumType.OAK).withProperty(STAGE, Integer.valueOf(0)));
float f = 0.4F;
GameRegistry.registerBlock(this, name);
setUnlocalizedName(name);
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f);
this.setCreativeTab(CreativeTabs.tabDecorations);
}
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (!worldIn.isRemote)
{
super.updateTick(worldIn, pos, state, rand);
this.generateTree(worldIn, pos, state, rand);
if (worldIn.getLightFromNeighbors(pos.up()) >= 9 && rand.nextInt(7) == 0)
{
this.grow(worldIn, pos, state, rand);
}
}
}
public void grow(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (((Integer)state.getValue(STAGE)).intValue() == 0)
{
worldIn.setBlockState(pos, state.cycleProperty(STAGE), 4);
}
else
{
this.generateTree(worldIn, pos, state, rand);
}
}
public void generateTree(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
Object object = rand.nextInt(10) == 0 ? new WorldGenBigTree(true) : new WorldGenTrees(true);
int i = 0;
int j = 0;
boolean flag = false;
j = 0;
i = 0;
object = new GenAmboynaTree(true);
IBlockState iblockstate1 = Blocks.air.getDefaultState();
if (flag)
{
worldIn.setBlockState(pos.add(i, 0, j), iblockstate1, 4);
worldIn.setBlockState(pos.add(i + 1, 0, j), iblockstate1, 4);
worldIn.setBlockState(pos.add(i, 0, j + 1), iblockstate1, 4);
worldIn.setBlockState(pos.add(i + 1, 0, j + 1), iblockstate1, 4);
}
else
{
worldIn.setBlockState(pos, iblockstate1, 4);
}
if (!((WorldGenerator)object).generate(worldIn, rand, pos.add(i, 0, j)))
{
if (flag)
{
worldIn.setBlockState(pos.add(i, 0, j), state, 4);
worldIn.setBlockState(pos.add(i + 1, 0, j), state, 4);
worldIn.setBlockState(pos.add(i, 0, j + 1), state, 4);
worldIn.setBlockState(pos.add(i + 1, 0, j + 1), state, 4);
}
else
{
worldIn.setBlockState(pos, state, 4);
}
}
}
public boolean isTypeAt(World worldIn, BlockPos pos, BlockPlanks.EnumType type)
{
IBlockState iblockstate = worldIn.getBlockState(pos);
return iblockstate.getBlock() == this && iblockstate.getValue(TYPE) == type;
}
public int damageDropped(IBlockState state)
{
return ((BlockPlanks.EnumType)state.getValue(TYPE)).getMetadata();
}
public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, boolean isClient)
{
return true;
}
public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state)
{
return (double)worldIn.rand.nextFloat() < 0.45D;
}
public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state)
{
this.grow(worldIn, pos, state, rand);
}
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(TYPE, BlockPlanks.EnumType.byMetadata(meta & 7)).withProperty(STAGE, Integer.valueOf((meta & >> 3));
}
public int getMetaFromState(IBlockState state)
{
byte b0 = 0;
int i = b0 | ((BlockPlanks.EnumType)state.getValue(TYPE)).getMetadata();
i |= ((Integer)state.getValue(STAGE)).intValue() << 3;
return i;
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {TYPE, STAGE});
}
public String getName() {
return name;
}
}
Bush
package epicarno.mystical.common.block;
import java.util.Random;
import epicarno.mystical.common.mystical_epicarno_mod;
import net.minecraft.block.Block;
import net.minecraft.block.BlockBush;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockEpicarnoBush extends BlockBush implements net.minecraftforge.common.IPlantable
{
protected BlockEpicarnoBush(Material materialIn)
{
super(materialIn);
this.setTickRandomly(true);
float f = 0.2F;
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 3.0F, 0.5F + f);
this.setCreativeTab(CreativeTabs.tabDecorations);
}
protected BlockEpicarnoBush()
{
this(Material.plants);
}
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
return super.canPlaceBlockAt(worldIn, pos) && worldIn.getBlockState(pos.down()).getBlock().canSustainPlant(worldIn, pos.down(), net.minecraft.util.EnumFacing.UP, this);
}
@Override
protected boolean canPlaceBlockOn(Block ground)
{
return ground == mystical_epicarno_mod.EpicarnoGrass || ground == mystical_epicarno_mod.EpicarnoDirt;
}
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
super.onNeighborBlockChange(worldIn, pos, state, neighborBlock);
this.checkAndDropBlock(worldIn, pos, state);
}
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
this.checkAndDropBlock(worldIn, pos, state);
}
protected void checkAndDropBlock(World worldIn, BlockPos pos, IBlockState state)
{
if (!this.canBlockStay(worldIn, pos, state))
{
this.dropBlockAsItem(worldIn, pos, state, 0);
worldIn.setBlockState(pos, Blocks.air.getDefaultState(), 3);
}
}
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
{
return this.canPlaceBlockOn(worldIn.getBlockState(pos.down()).getBlock());
}
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
{
return null;
}
@Override
public net.minecraftforge.common.EnumPlantType getPlantType(net.minecraft.world.IBlockAccess world, BlockPos pos)
{
return net.minecraftforge.common.EnumPlantType.Plains;
}
public boolean isOpaqueCube()
{
return false;
}
public boolean isFullCube()
{
return false;
}
@SideOnly(Side.CLIENT)
public EnumWorldBlockLayer getBlockLayer()
{
return EnumWorldBlockLayer.CUTOUT;
}
@Override
public IBlockState getPlant(net.minecraft.world.IBlockAccess world, BlockPos pos)
{
IBlockState state = world.getBlockState(pos);
if (state.getBlock() != this) return getDefaultState();
return state;
}
}
Also how different is making a custom dimension in 1.8 to 1.7 as there does not seem to be any information on dimensions for 1.8 as far as I have looked.
Thanks.