Search in sources :

Example 1 with IFruitBearer

use of forestry.api.genetics.IFruitBearer in project MineFactoryReloaded by powercrystals.

the class FertilizableForestryLeaves method fertilize.

@Override
public boolean fertilize(World world, Random rand, int x, int y, int z, FertilizerType fertilizerType) {
    if (world.getBlockId(x, y, z) == this.getFertilizableBlockId()) {
        IFruitBearer f = ForestryUtils.getFruitBearer(world.getBlockTileEntity(x, y, z));
        if (f.hasFruit() && f.getRipeness() < 1.0f) {
            BonemealEvent event = new BonemealEvent(null, world, 1, x, y, z);
            MinecraftForge.EVENT_BUS.post(event);
            if (event.getResult().equals(BonemealEvent.Result.ALLOW)) {
                return true;
            }
        }
    }
    return false;
}
Also used : BonemealEvent(net.minecraftforge.event.entity.player.BonemealEvent) IFruitBearer(forestry.api.genetics.IFruitBearer)

Example 2 with IFruitBearer

use of forestry.api.genetics.IFruitBearer in project ForestryMC by ForestryMC.

the class CropFruit method harvestBlock.

@Override
protected NonNullList<ItemStack> harvestBlock(World world, BlockPos pos) {
    IFruitBearer tile = TileUtil.getTile(world, pos, IFruitBearer.class);
    if (tile == null) {
        return NonNullList.create();
    }
    IBlockState blockState = world.getBlockState(pos);
    PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.VisualFXType.BLOCK_BREAK, PacketFXSignal.SoundFXType.BLOCK_BREAK, pos, blockState);
    NetworkUtil.sendNetworkPacket(packet, pos, world);
    return tile.pickFruit(ItemStack.EMPTY);
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) PacketFXSignal(forestry.core.network.packets.PacketFXSignal) IFruitBearer(forestry.api.genetics.IFruitBearer)

Aggregations

IFruitBearer (forestry.api.genetics.IFruitBearer)2 PacketFXSignal (forestry.core.network.packets.PacketFXSignal)1 IBlockState (net.minecraft.block.state.IBlockState)1 BonemealEvent (net.minecraftforge.event.entity.player.BonemealEvent)1