Search in sources :

Example 1 with IFlowerRoot

use of binnie.botany.api.genetics.IFlowerRoot in project Binnie by ForestryMC.

the class FarmableVanillaFlower method plantSaplingAt.

@Override
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
    IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
    IFlower flower = flowerRoot.getConversion(germling);
    return flowerRoot.plant(world, pos, flower, player.getGameProfile());
}
Also used : IFlower(binnie.botany.api.genetics.IFlower) IFlowerRoot(binnie.botany.api.genetics.IFlowerRoot)

Example 2 with IFlowerRoot

use of binnie.botany.api.genetics.IFlowerRoot in project Binnie by ForestryMC.

the class FarmableFlower method plantSaplingAt.

@Override
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
    IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
    IFlower flower = flowerRoot.getMember(germling);
    flowerRoot.plant(world, pos, flower, player.getGameProfile());
    return true;
}
Also used : IFlower(binnie.botany.api.genetics.IFlower) IFlowerRoot(binnie.botany.api.genetics.IFlowerRoot)

Example 3 with IFlowerRoot

use of binnie.botany.api.genetics.IFlowerRoot in project Binnie by ForestryMC.

the class FarmableFlower method getCropAt.

@Nullable
@Override
public ICrop getCropAt(World world, BlockPos pos, IBlockState blockState) {
    IFlower flower = null;
    if (world.getTileEntity(pos) instanceof TileEntityFlower) {
        flower = ((TileEntityFlower) world.getTileEntity(pos)).getFlower();
    }
    // TODO Look at TileEntityFlower::onShear logic
    if (flower != null && flower.getAge() > 1) {
        IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
        ItemStack mature = flowerRoot.getMemberStack(flower, EnumFlowerStage.FLOWER);
        ItemStack seed = flowerRoot.getMemberStack(flower, EnumFlowerStage.SEED);
        if (!mature.isEmpty() && !seed.isEmpty()) {
            world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
            return new FlowerCrop(pos, mature, seed);
        }
    }
    return null;
}
Also used : IFlower(binnie.botany.api.genetics.IFlower) TileEntityFlower(binnie.botany.tile.TileEntityFlower) ItemStack(net.minecraft.item.ItemStack) IFlowerRoot(binnie.botany.api.genetics.IFlowerRoot) Nullable(javax.annotation.Nullable)

Example 4 with IFlowerRoot

use of binnie.botany.api.genetics.IFlowerRoot in project Binnie by ForestryMC.

the class ModuleFlowers method onPlantVanilla.

@Deprecated
public void onPlantVanilla(PlayerInteractEvent.RightClickBlock event) {
    BlockPos pos = event.getPos();
    World world = event.getWorld();
    EntityPlayer player = event.getEntityPlayer();
    ItemStack heldItem = player.getHeldItemMainhand();
    if (event.getWorld().isRemote) {
        return;
    }
    if (heldItem.isEmpty()) {
        return;
    }
    Block block = world.getBlockState(pos).getBlock();
    int py = -1;
    if (block instanceof IBlockSoil && (world.isAirBlock(pos.up()) || block.isReplaceable(world, pos))) {
        py = 1;
    }
    if (py < 0) {
        return;
    }
    IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
    IFlower flower = flowerRoot.getConversion(heldItem);
    if (flower != null && flowerRoot.plant(world, pos.add(0, py, 0), flower, player.getGameProfile()) && !player.capabilities.isCreativeMode) {
        heldItem.shrink(1);
    }
}
Also used : IBlockSoil(binnie.botany.api.gardening.IBlockSoil) IFlower(binnie.botany.api.genetics.IFlower) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack) IFlowerRoot(binnie.botany.api.genetics.IFlowerRoot)

Example 5 with IFlowerRoot

use of binnie.botany.api.genetics.IFlowerRoot in project Binnie by ForestryMC.

the class ModuleFlowers method plantVanilla.

@SubscribeEvent
public void plantVanilla(BlockEvent.PlaceEvent event) {
    World world = event.getWorld();
    BlockPos pos = event.getPos();
    Block block = world.getBlockState(pos.down()).getBlock();
    if (!BotanyCore.getGardening().isSoil(block)) {
        return;
    }
    EntityPlayer player = event.getPlayer();
    ItemStack heldItem = player.getHeldItem(event.getHand());
    IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
    IFlower flower = flowerRoot.getConversion(heldItem);
    if (flower != null) {
        flowerRoot.plant(world, pos, flower, player.getGameProfile());
    }
}
Also used : IFlower(binnie.botany.api.genetics.IFlower) Block(net.minecraft.block.Block) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack) IFlowerRoot(binnie.botany.api.genetics.IFlowerRoot) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

IFlowerRoot (binnie.botany.api.genetics.IFlowerRoot)7 IFlower (binnie.botany.api.genetics.IFlower)6 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 ItemStack (net.minecraft.item.ItemStack)3 TileEntityFlower (binnie.botany.tile.TileEntityFlower)2 Block (net.minecraft.block.Block)2 BlockPos (net.minecraft.util.math.BlockPos)2 World (net.minecraft.world.World)2 IBlockSoil (binnie.botany.api.gardening.IBlockSoil)1 FlowerRenderInfo (binnie.botany.tile.FlowerRenderInfo)1 GameProfile (com.mojang.authlib.GameProfile)1 Nullable (javax.annotation.Nullable)1 TileEntity (net.minecraft.tileentity.TileEntity)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1