Search in sources :

Example 6 with IFlowerRoot

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

the class BlockFlower method onBlockPlacedBy.

@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
    super.onBlockPlacedBy(world, pos, state, placer, stack);
    IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
    TileEntity flower = world.getTileEntity(pos);
    if (world.isRemote) {
        if (flower != null && flower instanceof TileEntityFlower) {
            IFlower f = flowerRoot.getMember(stack);
            if (f != null) {
                ((TileEntityFlower) flower).setRender(new FlowerRenderInfo(f, (TileEntityFlower) flower));
            }
        }
        return;
    }
    TileEntity below = world.getTileEntity(pos.down());
    if (flower != null && flower instanceof TileEntityFlower) {
        if (below instanceof TileEntityFlower) {
            ((TileEntityFlower) flower).setSection(((TileEntityFlower) below).getSection());
        } else {
            GameProfile owner = (placer instanceof EntityPlayer) ? ((EntityPlayer) placer).getGameProfile() : null;
            ((TileEntityFlower) flower).create(stack, owner);
        }
    }
    flowerRoot.tryGrowSection(world, pos);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) FlowerRenderInfo(binnie.botany.tile.FlowerRenderInfo) IFlower(binnie.botany.api.genetics.IFlower) GameProfile(com.mojang.authlib.GameProfile) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TileEntityFlower(binnie.botany.tile.TileEntityFlower) IFlowerRoot(binnie.botany.api.genetics.IFlowerRoot)

Example 7 with IFlowerRoot

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

the class TileEntityFlower method doFlowerAge.

private void doFlowerAge() {
    getFlower().age();
    if (getFlower().getAge() == 1) {
        IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
        flowerRoot.onGrowFromSeed(world, pos);
        if (getOwner() != null && getFlower() != null) {
            flowerRoot.getBreedingTracker(world, getOwner()).registerBirth(getFlower());
        }
    }
}
Also used : IFlowerRoot(binnie.botany.api.genetics.IFlowerRoot)

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