Search in sources :

Example 11 with IFlower

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

the class TileEntityFlower method mateWith.

@Override
public void mateWith(IIndividual individual) {
    if (getFlower() == null || !(individual instanceof IFlower)) {
        return;
    }
    IAlleleFlowerSpecies primary = (IAlleleFlowerSpecies) individual.getGenome().getPrimary();
    IAlleleFlowerSpecies primary2 = getFlower().getGenome().getPrimary();
    if (primary == primary2 || world.rand.nextInt(4) == 0) {
        getFlower().mate((IFlower) individual);
        world.markBlockRangeForRenderUpdate(pos, pos);
    }
}
Also used : IFlower(binnie.botany.api.genetics.IFlower) IAlleleFlowerSpecies(binnie.botany.api.genetics.IAlleleFlowerSpecies)

Example 12 with IFlower

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

Example 13 with IFlower

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

the class Flower method copy.

@Override
public IFlower copy() {
    NBTTagCompound compound = new NBTTagCompound();
    writeToNBT(compound);
    return new Flower(compound);
}
Also used : IFlower(binnie.botany.api.genetics.IFlower) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 14 with IFlower

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

the class Flower method getOffspring.

@Override
public IFlower getOffspring(World world, BlockPos pos) {
    if (mate != null) {
        IChromosome[] chromosomes = new IChromosome[genome.getChromosomes().length];
        IChromosome[] parentFirst = mutateSpecies(world, pos, genome, mate);
        IChromosome[] parentSecond = mutateSpecies(world, pos, mate, genome);
        for (int i = 0; i < parentFirst.length; ++i) {
            if (parentFirst[i] != null && parentSecond[i] != null) {
                chromosomes[i] = Chromosome.inheritChromosome(world.rand, parentFirst[i], parentSecond[i]);
            }
        }
        return new Flower(new FlowerGenome(chromosomes), 0);
    }
    NBTTagCompound nbt = new NBTTagCompound();
    writeToNBT(nbt);
    return new Flower(nbt);
}
Also used : IFlower(binnie.botany.api.genetics.IFlower) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IChromosome(forestry.api.genetics.IChromosome) IFlowerGenome(binnie.botany.api.genetics.IFlowerGenome)

Example 15 with IFlower

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

the class ItemFlowerGE method addInformation.

@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemStack, @Nullable World worldIn, List<String> list, ITooltipFlag flagIn) {
    IFlower individual = (IFlower) getIndividual(itemStack);
    if (individual == null) {
        list.add(TextFormatting.DARK_RED + I18N.localise("item.botany.flower.destroy"));
        return;
    }
    IFlowerGenome genome = individual.getGenome();
    // Colors
    String primaryColor = genome.getPrimaryColor().getColorName();
    String secondaryColor = genome.getSecondaryColor().getColorName();
    String stemColor = genome.getStemColor().getColorName();
    String colorInfo;
    if (!primaryColor.equals(secondaryColor)) {
        colorInfo = I18N.localise("item.botany.grammar.flower.secondary", primaryColor, secondaryColor, stemColor);
    } else {
        colorInfo = I18N.localise("item.botany.grammar.flower", primaryColor, stemColor);
    }
    list.add(TextFormatting.YELLOW + colorInfo);
    if (individual.isAnalyzed()) {
        if (GuiScreen.isShiftKeyDown()) {
            individual.addTooltip(list);
        } else {
            list.add(TextFormatting.ITALIC + "<" + I18N.localise("for.gui.tooltip.tmi") + '>');
        }
    } else {
        list.add('<' + I18N.localise("for.gui.unknown") + '>');
    }
}
Also used : IFlowerGenome(binnie.botany.api.genetics.IFlowerGenome) IFlower(binnie.botany.api.genetics.IFlower) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

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