Fixing MFR Integration.

This commit is contained in:
Amnet 2013-11-13 02:18:35 +01:00
parent bd2c295f3c
commit 5f8cd51400
2 changed files with 66 additions and 0 deletions

View File

@ -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<? extends Block> sapling : bopSaplings)
{
FactoryRegistry.registerFertilizable(new Fertilizable(sapling.get().blockID));
FactoryRegistry.registerPlantable(new Plantable(sapling.get().blockID));
}
for(Optional<? extends Block> leaves : bopFruitLeaves)

View File

@ -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;
}
}