diff --git a/src/main/java/biomesoplenty/common/block/BlockBOPDirt.java b/src/main/java/biomesoplenty/common/block/BlockBOPDirt.java index e24a0a813..6ad807ca9 100644 --- a/src/main/java/biomesoplenty/common/block/BlockBOPDirt.java +++ b/src/main/java/biomesoplenty/common/block/BlockBOPDirt.java @@ -8,8 +8,6 @@ package biomesoplenty.common.block; -import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.BlockDirt; import net.minecraft.block.material.Material; @@ -18,11 +16,11 @@ import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyEnum; 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.util.EnumFacing; import net.minecraft.util.IStringSerializable; +import net.minecraft.world.IBlockAccess; import biomesoplenty.api.block.BOPBlock; import biomesoplenty.api.block.BOPBlocks; @@ -72,6 +70,31 @@ public class BlockBOPDirt extends BOPBlock return (Boolean.TRUE.equals(state.getValue(COARSE)) ? "coarse_" : "") + ((BOPDirtType) state.getValue(VARIANT_PROP)).getName() + "_dirt"; } + @Override + public boolean canSustainPlant(IBlockAccess world, BlockPos pos, EnumFacing direction, net.minecraftforge.common.IPlantable plantable) + { + net.minecraftforge.common.EnumPlantType plantType = plantable.getPlantType(world, pos.offset(direction)); + + switch (plantType) + { + // support desert and plains plants + case Desert: case Plains: return true; + // support cave plants + case Cave: return isSideSolid(world, pos, EnumFacing.UP); + // support beach plants if there's water alongside + case Beach: + return ( + world.getBlockState(pos.east()).getBlock().getMaterial() == Material.water || + world.getBlockState(pos.west()).getBlock().getMaterial() == Material.water || + world.getBlockState(pos.north()).getBlock().getMaterial() == Material.water || + world.getBlockState(pos.south()).getBlock().getMaterial() == Material.water + ); + // don't support nether plants, water plants, or crops (require farmland), or anything else by default + default: + return false; + } + } + // enum representing the variants of dirt public static enum BOPDirtType implements IStringSerializable {