Search in sources :

Example 6 with IBeeGenome

use of forestry.api.apiculture.IBeeGenome in project Binnie by ForestryMC.

the class PageSpeciesGenome method onValueChanged.

@Override
public void onValueChanged(IAlleleSpecies species) {
    IAllele[] template = BeeManager.beeRoot.getTemplate(species.getUID());
    if (template == null) {
        return;
    }
    IBeeGenome genome = BeeManager.beeRoot.templateAsGenome(template);
    IBee bee = BeeManager.beeRoot.getBee(genome);
    speedText.setValue(rateSpeed(genome.getSpeed()));
    lifespanText.setValue(rateLifespan(genome.getLifespan()));
    fertilityText.setValue(I18N.localise(DatabaseConstants.BEE_GENOME_KEY + ".children", genome.getFertility()));
    floweringText.setValue(rateFlowering(genome.getFlowering()));
    Vec3i area = genome.getTerritory();
    territoryText.setValue(area.getX() + "x" + area.getY() + 'x' + area.getZ());
    String behavior = I18N.localise(DatabaseConstants.BEE_GENOME_KEY + ".daytime");
    if (genome.getPrimary().isNocturnal()) {
        behavior = I18N.localise(DatabaseConstants.BEE_GENOME_KEY + ".nighttime");
    }
    if (genome.getNeverSleeps()) {
        behavior = I18N.localise(DatabaseConstants.BEE_GENOME_KEY + ".allDay");
    }
    nocturnalText.setValue(behavior);
    if (genome.getCaveDwelling()) {
        caveDwellingText.setValue(I18N.localise(DatabaseConstants.BEE_GENOME_KEY + ".notNeeded"));
    } else {
        caveDwellingText.setValue(I18N.localise(DatabaseConstants.BEE_GENOME_KEY + ".required"));
    }
    tolerantFlyerText.setValue(tolerated(genome.getToleratesRain()));
    if (genome.getFlowerProvider() != null) {
        flowerText.setValue(genome.getFlowerProvider().getDescription());
    } else {
        flowerText.setValue(AlleleHelper.toDisplay(EnumTolerance.NONE));
    }
    effectText.setValue(genome.getEffect().getAlleleName());
}
Also used : IAllele(forestry.api.genetics.IAllele) Vec3i(net.minecraft.util.math.Vec3i) IBee(forestry.api.apiculture.IBee) IBeeGenome(forestry.api.apiculture.IBeeGenome)

Example 7 with IBeeGenome

use of forestry.api.apiculture.IBeeGenome in project ForestryMC by ForestryMC.

the class TileHive method getContainedBee.

public IBee getContainedBee() {
    if (this.containedBee == null) {
        IBeeGenome beeGenome = null;
        ItemStack containedBee = contained.getStackInSlot(0);
        if (!containedBee.isEmpty()) {
            IBee bee = BeeManager.beeRoot.getMember(containedBee);
            if (bee != null) {
                beeGenome = bee.getGenome();
            }
        }
        if (beeGenome == null) {
            beeGenome = getGenomeFromBlock();
        }
        if (beeGenome == null) {
            beeGenome = BeeDefinition.FOREST.getGenome();
        }
        this.containedBee = BeeManager.beeRoot.getBee(beeGenome);
    }
    return this.containedBee;
}
Also used : IBee(forestry.api.apiculture.IBee) IBeeGenome(forestry.api.apiculture.IBeeGenome) ItemStack(net.minecraft.item.ItemStack)

Example 8 with IBeeGenome

use of forestry.api.apiculture.IBeeGenome in project ForestryMC by ForestryMC.

the class BeeRoot method registerTemplate.

@Override
public void registerTemplate(String identifier, IAllele[] template) {
    IBeeGenome beeGenome = BeeManager.beeRoot.templateAsGenome(template);
    IBee bee = new Bee(beeGenome);
    beeTemplates.add(bee);
    speciesTemplates.put(identifier, template);
}
Also used : IBee(forestry.api.apiculture.IBee) IBee(forestry.api.apiculture.IBee) IBeeGenome(forestry.api.apiculture.IBeeGenome)

Example 9 with IBeeGenome

use of forestry.api.apiculture.IBeeGenome in project ForestryMC by ForestryMC.

the class Bee method mutateSpecies.

@Nullable
private static IChromosome[] mutateSpecies(IBeeHousing housing, IBeeGenome genomeOne, IBeeGenome genomeTwo) {
    World world = housing.getWorldObj();
    IChromosome[] parent1 = genomeOne.getChromosomes();
    IChromosome[] parent2 = genomeTwo.getChromosomes();
    IBeeGenome genome0;
    IBeeGenome genome1;
    IAlleleBeeSpecies allele0;
    IAlleleBeeSpecies allele1;
    if (world.rand.nextBoolean()) {
        allele0 = (IAlleleBeeSpecies) parent1[EnumBeeChromosome.SPECIES.ordinal()].getPrimaryAllele();
        allele1 = (IAlleleBeeSpecies) parent2[EnumBeeChromosome.SPECIES.ordinal()].getSecondaryAllele();
        genome0 = genomeOne;
        genome1 = genomeTwo;
    } else {
        allele0 = (IAlleleBeeSpecies) parent2[EnumBeeChromosome.SPECIES.ordinal()].getPrimaryAllele();
        allele1 = (IAlleleBeeSpecies) parent1[EnumBeeChromosome.SPECIES.ordinal()].getSecondaryAllele();
        genome0 = genomeTwo;
        genome1 = genomeOne;
    }
    GameProfile playerProfile = housing.getOwner();
    IApiaristTracker breedingTracker = BeeManager.beeRoot.getBreedingTracker(world, playerProfile);
    List<IMutation> combinations = BeeManager.beeRoot.getCombinations(allele0, allele1, true);
    for (IMutation mutation : combinations) {
        IBeeMutation beeMutation = (IBeeMutation) mutation;
        float chance = beeMutation.getChance(housing, allele0, allele1, genome0, genome1);
        if (chance <= 0) {
            continue;
        }
        // boost chance for researched mutations
        if (breedingTracker.isResearched(beeMutation)) {
            float mutationBoost = chance * (Config.researchMutationBoostMultiplier - 1.0f);
            mutationBoost = Math.min(Config.maxResearchMutationBoostPercent, mutationBoost);
            chance += mutationBoost;
        }
        if (chance > world.rand.nextFloat() * 100) {
            breedingTracker.registerMutation(mutation);
            return BeeManager.beeRoot.templateAsChromosomes(mutation.getTemplate());
        }
    }
    return null;
}
Also used : IAlleleBeeSpecies(forestry.api.apiculture.IAlleleBeeSpecies) IMutation(forestry.api.genetics.IMutation) GameProfile(com.mojang.authlib.GameProfile) IBeeMutation(forestry.api.apiculture.IBeeMutation) IChromosome(forestry.api.genetics.IChromosome) IApiaristTracker(forestry.api.apiculture.IApiaristTracker) World(net.minecraft.world.World) IBeeGenome(forestry.api.apiculture.IBeeGenome) Nullable(javax.annotation.Nullable)

Example 10 with IBeeGenome

use of forestry.api.apiculture.IBeeGenome in project ForestryMC by ForestryMC.

the class CommandBeeGive method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if (args.length < 2) {
        printHelp(sender);
        return;
    }
    IBeeGenome beeGenome = getBeeGenome(args[0]);
    EnumBeeType beeType = getBeeType(args[1]);
    if (beeType == null) {
        printHelp(sender);
        return;
    }
    EntityPlayer player;
    if (args.length == 3) {
        player = CommandBase.getPlayer(server, sender, args[2]);
    } else {
        player = CommandBase.getPlayer(server, sender, sender.getName());
    }
    IBee bee = BeeManager.beeRoot.getBee(beeGenome);
    if (beeType == EnumBeeType.QUEEN) {
        bee.mate(bee);
    }
    ItemStack beeStack = BeeManager.beeRoot.getMemberStack(bee, beeType);
    player.dropItem(beeStack, false, true);
    CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.bee.give.given", player.getName(), bee.getGenome().getPrimary().getAlleleName(), beeType.getName());
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) IBee(forestry.api.apiculture.IBee) IBeeGenome(forestry.api.apiculture.IBeeGenome) ItemStack(net.minecraft.item.ItemStack) EnumBeeType(forestry.api.apiculture.EnumBeeType)

Aggregations

IBeeGenome (forestry.api.apiculture.IBeeGenome)13 IBee (forestry.api.apiculture.IBee)7 IAllele (forestry.api.genetics.IAllele)4 ItemStack (net.minecraft.item.ItemStack)3 World (net.minecraft.world.World)3 IChromosome (forestry.api.genetics.IChromosome)2 ArrayList (java.util.ArrayList)2 GameProfile (com.mojang.authlib.GameProfile)1 EnumBeeType (forestry.api.apiculture.EnumBeeType)1 IAlleleBeeSpecies (forestry.api.apiculture.IAlleleBeeSpecies)1 IApiaristTracker (forestry.api.apiculture.IApiaristTracker)1 IBeeMutation (forestry.api.apiculture.IBeeMutation)1 IBeeRoot (forestry.api.apiculture.IBeeRoot)1 IBeekeepingMode (forestry.api.apiculture.IBeekeepingMode)1 EnumHumidity (forestry.api.core.EnumHumidity)1 EnumTemperature (forestry.api.core.EnumTemperature)1 EnumTolerance (forestry.api.genetics.EnumTolerance)1 IMutation (forestry.api.genetics.IMutation)1 Bee (forestry.apiculture.genetics.Bee)1 Map (java.util.Map)1