Search in sources :

Example 1 with IFlower

use of binnie.botany.api.genetics.IFlower 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 IFlower

use of binnie.botany.api.genetics.IFlower 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 IFlower

use of binnie.botany.api.genetics.IFlower 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 IFlower

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

the class ItemFlowerGE method pollinateFlower.

private EnumActionResult pollinateFlower(World world, BlockPos pos, EntityPlayer player, ItemStack stack) {
    IFlower flower = BotanyAPI.flowerRoot.getMember(stack);
    TileEntity target = world.getTileEntity(pos);
    if (!(target instanceof IPollinatable)) {
        return EnumActionResult.PASS;
    }
    IPollinatable pollinatable = (IPollinatable) target;
    if (!pollinatable.canMateWith(flower)) {
        return EnumActionResult.FAIL;
    }
    pollinatable.mateWith(flower);
    if (!player.capabilities.isCreativeMode) {
        stack.shrink(1);
    }
    return EnumActionResult.SUCCESS;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IFlower(binnie.botany.api.genetics.IFlower) IPollinatable(forestry.api.genetics.IPollinatable)

Example 5 with IFlower

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

the class PageSpeciesFlowerGenome method onValueChanged.

@Override
public void onValueChanged(IAlleleSpecies species) {
    deleteAllChildren();
    IAllele[] template = BotanyAPI.flowerRoot.getTemplate(species.getUID());
    if (template == null) {
        return;
    }
    IFlower flower = BotanyAPI.flowerRoot.templateAsIndividual(template);
    IFlowerGenome genome = flower.getGenome();
    IAlleleFlowerSpecies flowerSpecies = genome.getPrimary();
    int w = 144;
    int h = 176;
    new ControlText(this, new Area(0, 4, w, 16), I18N.localise(DatabaseConstants.BOTANY_GENOME_KEY + ".title"), TextJustification.MIDDLE_CENTER);
    ControlScrollableContent scrollable = new ControlScrollableContent(this, 4, 20, w - 8, h - 8 - 16, 12);
    Control contents = new Control(scrollable, 0, 0, w - 8 - 12, h - 8 - 16);
    int tw = w - 8 - 12;
    int w2 = 55;
    int w3 = tw - 50;
    int y = 0;
    int th = 14;
    int th2 = 18;
    new ControlText(contents, new Area(0, y, w2, th), I18N.localise(DatabaseConstants.BOTANY_GENOME_KEY + ".temp"), TextJustification.MIDDLE_RIGHT);
    new ControlText(contents, new Area(w2, y, w3, th), flowerSpecies.getTemperature().getName(), TextJustification.MIDDLE_LEFT);
    y += th;
    new ControlText(contents, new Area(0, y, w2, th), I18N.localise(DatabaseConstants.BOTANY_GENOME_KEY + ".moist"), TextJustification.MIDDLE_RIGHT);
    new ControlText(contents, new Area(w2, y, w3, th), EnumHelper.getLocalisedName(flowerSpecies.getMoisture(), false), TextJustification.MIDDLE_LEFT);
    y += th;
    new ControlText(contents, new Area(0, y, w2, th), I18N.localise(DatabaseConstants.BOTANY_GENOME_KEY + ".ph"), TextJustification.MIDDLE_RIGHT);
    new ControlText(contents, new Area(w2, y, w3, th), EnumHelper.getLocalisedName(flowerSpecies.getPH(), false), TextJustification.MIDDLE_LEFT);
    y += th;
    new ControlText(contents, new Area(0, y, w2, th), I18N.localise(DatabaseConstants.BOTANY_GENOME_KEY + ".fertility"), TextJustification.MIDDLE_RIGHT);
    new ControlText(contents, new Area(w2, y, w3, th), genome.getFertility() + "x", TextJustification.MIDDLE_LEFT);
    y += th;
    float lifespan = genome.getLifespan() * 68.27f / genome.getAgeChance() / 24000.0f;
    String lifespanValue = String.format("%.2f", lifespan);
    new ControlText(contents, new Area(0, y, w2, th), I18N.localise(DatabaseConstants.BOTANY_GENOME_KEY + ".lifespan"), TextJustification.MIDDLE_RIGHT);
    new ControlText(contents, new Area(w2, y, w3, th), I18N.localise(DatabaseConstants.BOTANY_GENOME_KEY + ".lifespan.value", lifespanValue), TextJustification.MIDDLE_LEFT);
    y += th;
    new ControlText(contents, new Area(0, y, w2, th), I18N.localise(DatabaseConstants.BOTANY_GENOME_KEY + ".nectar"), TextJustification.MIDDLE_RIGHT);
    new ControlText(contents, new Area(w2, y, w3, th), genome.getActiveAllele(EnumFlowerChromosome.SAPPINESS).getAlleleName(), TextJustification.MIDDLE_LEFT);
    y += th;
    int x = w2;
    int tot = 0;
    for (IIndividual vid : BotanyCore.getFlowerRoot().getIndividualTemplates()) {
        if (vid.getGenome().getPrimary() == flowerSpecies) {
            if (tot > 0 && tot % 3 == 0) {
                x -= 54;
                y += 18;
            }
            ItemStack stack = BotanyCore.getFlowerRoot().getMemberStack(vid, EnumFlowerStage.FLOWER);
            ControlItemDisplay display = new ControlItemDisplay(contents, x, y);
            display.setItemStack(stack);
            ++tot;
            x += 18;
        }
    }
    int numOfLines = 1 + (tot - 1) / 3;
    new ControlText(contents, new Area(0, y - (numOfLines - 1) * 18, w2, 4 + 18 * numOfLines), I18N.localise(DatabaseConstants.BOTANY_GENOME_KEY + ".varieties"), TextJustification.MIDDLE_RIGHT);
    y += th;
    contents.setSize(new Point(contents.getSize().xPos(), y));
    scrollable.setScrollableContent(contents);
}
Also used : IFlowerGenome(binnie.botany.api.genetics.IFlowerGenome) ControlItemDisplay(binnie.core.gui.minecraft.control.ControlItemDisplay) IFlower(binnie.botany.api.genetics.IFlower) IIndividual(forestry.api.genetics.IIndividual) ControlText(binnie.core.gui.controls.ControlText) Point(binnie.core.gui.geometry.Point) IAlleleFlowerSpecies(binnie.botany.api.genetics.IAlleleFlowerSpecies) Point(binnie.core.gui.geometry.Point) IAllele(forestry.api.genetics.IAllele) Area(binnie.core.gui.geometry.Area) Control(binnie.core.gui.controls.core.Control) ItemStack(net.minecraft.item.ItemStack) ControlScrollableContent(binnie.core.gui.controls.scroll.ControlScrollableContent)

Aggregations

IFlower (binnie.botany.api.genetics.IFlower)24 ItemStack (net.minecraft.item.ItemStack)10 IFlowerRoot (binnie.botany.api.genetics.IFlowerRoot)6 TileEntity (net.minecraft.tileentity.TileEntity)6 IFlowerGenome (binnie.botany.api.genetics.IFlowerGenome)5 TileEntityFlower (binnie.botany.tile.TileEntityFlower)5 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 Block (net.minecraft.block.Block)3 BlockPos (net.minecraft.util.math.BlockPos)3 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 EnumFlowerChromosome (binnie.botany.api.genetics.EnumFlowerChromosome)2 IAlleleFlowerSpecies (binnie.botany.api.genetics.IAlleleFlowerSpecies)2 Area (binnie.core.gui.geometry.Area)2 World (net.minecraft.world.World)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 EnumSoilType (binnie.botany.api.gardening.EnumSoilType)1 IBlockSoil (binnie.botany.api.gardening.IBlockSoil)1 FlowerRenderInfo (binnie.botany.tile.FlowerRenderInfo)1 ControlText (binnie.core.gui.controls.ControlText)1