Allow BlockBOPGeneric to support plants
This commit is contained in:
parent
37f6d16d93
commit
cf7537e7ef
2 changed files with 30 additions and 3 deletions
|
@ -8,6 +8,9 @@
|
||||||
|
|
||||||
package biomesoplenty.common.block;
|
package biomesoplenty.common.block;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import biomesoplenty.api.block.IBOPBlock;
|
import biomesoplenty.api.block.IBOPBlock;
|
||||||
import biomesoplenty.common.item.ItemBOPBlock;
|
import biomesoplenty.common.item.ItemBOPBlock;
|
||||||
import net.minecraft.block.Block;
|
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.properties.IProperty;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.item.ItemBlock;
|
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
|
public class BlockBOPGeneric extends Block implements IBOPBlock
|
||||||
{
|
{
|
||||||
|
@ -45,4 +52,24 @@ public class BlockBOPGeneric extends Block implements IBOPBlock
|
||||||
this.setStepSound(Block.soundTypePiston);
|
this.setStepSound(Block.soundTypePiston);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public Set<EnumPlantType> plantTypesICanSustain = new HashSet<EnumPlantType>();
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -9,7 +9,6 @@
|
||||||
package biomesoplenty.common.init;
|
package biomesoplenty.common.init;
|
||||||
|
|
||||||
import static biomesoplenty.api.block.BOPBlocks.*;
|
import static biomesoplenty.api.block.BOPBlocks.*;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockSlab;
|
import net.minecraft.block.BlockSlab;
|
||||||
import net.minecraft.block.BlockStairs;
|
import net.minecraft.block.BlockStairs;
|
||||||
|
@ -20,6 +19,7 @@ import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemBlock;
|
import net.minecraft.item.ItemBlock;
|
||||||
import net.minecraft.item.ItemDoor;
|
import net.minecraft.item.ItemDoor;
|
||||||
import net.minecraft.item.ItemSlab;
|
import net.minecraft.item.ItemSlab;
|
||||||
|
import net.minecraftforge.common.EnumPlantType;
|
||||||
import net.minecraftforge.fluids.BlockFluidBase;
|
import net.minecraftforge.fluids.BlockFluidBase;
|
||||||
import net.minecraftforge.fluids.Fluid;
|
import net.minecraftforge.fluids.Fluid;
|
||||||
import net.minecraftforge.fluids.FluidRegistry;
|
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);
|
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" );
|
ash_stone = registerBlock( new BlockBOPGeneric(), "ash_stone" );
|
||||||
crag_rock = registerBlock( (new BlockBOPGeneric()).setStepSound(Block.soundTypeStone), "crag_rock" );
|
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_dirt = registerBlock( (new BlockBOPGeneric()).setHardness(0.7F), "hard_dirt" );
|
||||||
hard_ice = registerBlock( (new BlockBOPGeneric()).setHardness(0.75F), "hard_ice" );
|
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_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");
|
mud_brick_stairs = registerBlock( BOPReflectionHelper.construct(BlockStairs.class, (IBlockState)mud_brick_block.getDefaultState()), "mud_brick_stairs");
|
||||||
|
|
Loading…
Reference in a new issue