diff --git a/common/biomesoplenty/integration/MFRIntegration.java b/common/biomesoplenty/integration/MFRIntegration.java index fc485ce92..e10cca736 100644 --- a/common/biomesoplenty/integration/MFRIntegration.java +++ b/common/biomesoplenty/integration/MFRIntegration.java @@ -7,6 +7,8 @@ import biomesoplenty.api.Items; import biomesoplenty.integration.minefactoryreloaded.Fertilizable; import biomesoplenty.integration.minefactoryreloaded.FruitLeaves; import biomesoplenty.integration.minefactoryreloaded.Harvestable; +import biomesoplenty.integration.minefactoryreloaded.Plantable; + import com.google.common.base.Optional; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; @@ -71,6 +73,7 @@ public class MFRIntegration for(Optional sapling : bopSaplings) { FactoryRegistry.registerFertilizable(new Fertilizable(sapling.get().blockID)); + FactoryRegistry.registerPlantable(new Plantable(sapling.get().blockID)); } for(Optional leaves : bopFruitLeaves) diff --git a/common/biomesoplenty/integration/minefactoryreloaded/Plantable.java b/common/biomesoplenty/integration/minefactoryreloaded/Plantable.java new file mode 100644 index 000000000..918381a89 --- /dev/null +++ b/common/biomesoplenty/integration/minefactoryreloaded/Plantable.java @@ -0,0 +1,63 @@ +package biomesoplenty.integration.minefactoryreloaded; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.IPlantable; +import powercrystals.minefactoryreloaded.api.IFactoryPlantable; + +public class Plantable implements IFactoryPlantable +{ + protected int blockId; + + public Plantable(int blockId) + { + this.blockId = blockId; + } + + @Override + public int getSeedId() + { + return this.blockId; + } + + @Override + public int getPlantedBlockId(World world, int x, int y, int z, ItemStack stack) + { + return this.blockId; + } + + @Override + public int getPlantedBlockMetadata(World world, int x, int y, int z, ItemStack stack) + { + return stack.getItemDamage(); + } + + @Override + public boolean canBePlantedHere(World world, int x, int y, int z, ItemStack stack) + { + int groundId = world.getBlockId(x, y - 1, z); + if(!world.isAirBlock(x, y, z)) + { + return false; + } + return + (Block.blocksList[blockId].canPlaceBlockAt(world, x, y, z) && Block.blocksList[blockId].canBlockStay(world, x, y, z)) || + (Block.blocksList[blockId] instanceof IPlantable && Block.blocksList[groundId] != null && + Block.blocksList[groundId].canSustainPlant(world, x, y, z, ForgeDirection.UP, ((IPlantable)Block.blocksList[blockId]))); + + } + + @Override + public void prePlant(World world, int x, int y, int z, ItemStack stack) + { + return; + } + + @Override + public void postPlant(World world, int x, int y, int z, ItemStack stack) + { + return; + } +}