diff --git a/src/main/java/biomesoplenty/common/block/BlockBOPGeneric.java b/src/main/java/biomesoplenty/common/block/BlockBOPGeneric.java index fb2536033..b03ad01cc 100644 --- a/src/main/java/biomesoplenty/common/block/BlockBOPGeneric.java +++ b/src/main/java/biomesoplenty/common/block/BlockBOPGeneric.java @@ -8,6 +8,9 @@ package biomesoplenty.common.block; +import java.util.HashSet; +import java.util.Set; + import biomesoplenty.api.block.IBOPBlock; import biomesoplenty.common.item.ItemBOPBlock; import net.minecraft.block.Block; @@ -15,6 +18,10 @@ import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemBlock; +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.common.EnumPlantType; public class BlockBOPGeneric extends Block implements IBOPBlock { @@ -45,4 +52,24 @@ public class BlockBOPGeneric extends Block implements IBOPBlock this.setStepSound(Block.soundTypePiston); } + + + public Set plantTypesICanSustain = new HashSet(); + + public BlockBOPGeneric addSupportedPlantType(EnumPlantType... plantTypes) + { + for (EnumPlantType plantType : plantTypes) + { + this.plantTypesICanSustain.add(plantType); + } + return this; + } + + @Override + public boolean canSustainPlant(IBlockAccess world, BlockPos pos, EnumFacing direction, net.minecraftforge.common.IPlantable plantable) + { + EnumPlantType plantType = plantable.getPlantType(world, pos.offset(direction)); + return this.plantTypesICanSustain.contains(plantType); + } + } \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/init/ModBlocks.java b/src/main/java/biomesoplenty/common/init/ModBlocks.java index c9310682c..62b10c313 100644 --- a/src/main/java/biomesoplenty/common/init/ModBlocks.java +++ b/src/main/java/biomesoplenty/common/init/ModBlocks.java @@ -9,7 +9,6 @@ package biomesoplenty.common.init; import static biomesoplenty.api.block.BOPBlocks.*; - import net.minecraft.block.Block; import net.minecraft.block.BlockSlab; import net.minecraft.block.BlockStairs; @@ -20,6 +19,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemDoor; import net.minecraft.item.ItemSlab; +import net.minecraftforge.common.EnumPlantType; import net.minecraftforge.fluids.BlockFluidBase; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; @@ -74,10 +74,10 @@ public class ModBlocks bamboo_thatching = registerBlock( (new BlockBOPGeneric(Material.wood)).setStepSound(Block.soundTypeWood).setHardness(2.0F), "bamboo_thatching"); bamboo_thatching.setHarvestLevel("axe", 0); ash_stone = registerBlock( new BlockBOPGeneric(), "ash_stone" ); crag_rock = registerBlock( (new BlockBOPGeneric()).setStepSound(Block.soundTypeStone), "crag_rock" ); - dried_dirt = registerBlock( new BlockBOPGeneric(), "dried_dirt"); dried_dirt.setHarvestLevel("pickaxe",0); + dried_dirt = registerBlock( (new BlockBOPGeneric()).addSupportedPlantType(EnumPlantType.Desert), "dried_dirt"); dried_dirt.setHarvestLevel("pickaxe",0); hard_dirt = registerBlock( (new BlockBOPGeneric()).setHardness(0.7F), "hard_dirt" ); hard_ice = registerBlock( (new BlockBOPGeneric()).setHardness(0.75F), "hard_ice" ); - hard_sand = registerBlock( (new BlockBOPGeneric(Material.sand)).setHardness(0.9F).setStepSound(Block.soundTypeSand), "hard_sand" ); + hard_sand = registerBlock( (new BlockBOPGeneric(Material.sand)).addSupportedPlantType(EnumPlantType.Desert).setHardness(0.9F).setStepSound(Block.soundTypeSand), "hard_sand" ); mud_brick_block = registerBlock( (new BlockBOPGeneric()).setResistance(2.0F), "mud_brick_block" ); mud_brick_stairs = registerBlock( BOPReflectionHelper.construct(BlockStairs.class, (IBlockState)mud_brick_block.getDefaultState()), "mud_brick_stairs");