Search in sources :

Example 1 with IBee

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

the class ItemBeeGE method getItemStackDisplayName.

@Override
public String getItemStackDisplayName(ItemStack itemstack) {
    if (itemstack.getTagCompound() == null) {
        return super.getItemStackDisplayName(itemstack);
    }
    IBee individual = getIndividual(itemstack);
    String customBeeKey = "for.bees.custom." + type.getName() + "." + individual.getGenome().getPrimary().getUnlocalizedName().replace("bees.species.", "");
    if (Translator.canTranslateToLocal(customBeeKey)) {
        return Translator.translateToLocal(customBeeKey);
    }
    String beeGrammar = Translator.translateToLocal("for.bees.grammar." + type.getName());
    String beeSpecies = individual.getDisplayName();
    String beeType = Translator.translateToLocal("for.bees.grammar." + type.getName() + ".type");
    return beeGrammar.replaceAll("%SPECIES", beeSpecies).replaceAll("%TYPE", beeType);
}
Also used : IBee(forestry.api.apiculture.IBee)

Example 2 with IBee

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

the class ItemInventoryImprinter method getSelectedBee.

public IBee getSelectedBee() {
    IBeeRoot beeRoot = BeeManager.beeRoot;
    List<IBee> individualTemplates = beeRoot.getIndividualTemplates();
    Map<String, IAllele[]> genomeTemplates = beeRoot.getGenomeTemplates();
    IAllele[] templateActive = genomeTemplates.get(individualTemplates.get(primaryIndex).getIdent());
    IAllele[] templateInactive = genomeTemplates.get(individualTemplates.get(secondaryIndex).getIdent());
    IBeeGenome genome = beeRoot.templateAsGenome(templateActive, templateInactive);
    return new Bee(genome);
}
Also used : IAllele(forestry.api.genetics.IAllele) IBee(forestry.api.apiculture.IBee) Bee(forestry.apiculture.genetics.Bee) IBeeRoot(forestry.api.apiculture.IBeeRoot) IBee(forestry.api.apiculture.IBee) IBeeGenome(forestry.api.apiculture.IBeeGenome)

Example 3 with IBee

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

the class BeekeepingLogic method canWork.

/* UPDATING */
@Override
public boolean canWork() {
    IErrorLogic errorLogic = housing.getErrorLogic();
    errorLogic.clearErrors();
    IBeeHousingInventory beeInventory = housing.getBeeInventory();
    boolean hasSpace = addPendingProducts(beeInventory, spawn);
    errorLogic.setCondition(!hasSpace, EnumErrorCode.NO_SPACE_INVENTORY);
    ItemStack queenStack = beeInventory.getQueen();
    EnumBeeType beeType = BeeManager.beeRoot.getType(queenStack);
    // check if we're breeding
    if (beeType == EnumBeeType.PRINCESS) {
        boolean hasDrone = BeeManager.beeRoot.isDrone(beeInventory.getDrone());
        errorLogic.setCondition(!hasDrone, EnumErrorCode.NO_DRONE);
        // not active (no bee FX) when we are breeding
        setActive(false);
        return !errorLogic.hasErrors();
    }
    if (beeType == EnumBeeType.QUEEN) {
        if (!isQueenAlive(queenStack)) {
            IBee dyingQueen = BeeManager.beeRoot.getMember(queenStack);
            Collection<ItemStack> spawned = killQueen(dyingQueen, housing, beeListener);
            spawn.addAll(spawned);
            queenStack = ItemStack.EMPTY;
        }
    } else {
        queenStack = ItemStack.EMPTY;
    }
    if (this.queenStack != queenStack) {
        if (!queenStack.isEmpty()) {
            this.queen = BeeManager.beeRoot.getMember(queenStack);
            if (this.queen != null) {
                hasFlowersCache.onNewQueen(queen, housing);
            }
        } else {
            this.queen = null;
        }
        this.queenStack = queenStack;
        queenCanWorkCache.clear();
    }
    if (errorLogic.setCondition(queen == null, EnumErrorCode.NO_QUEEN)) {
        setActive(false);
        beeProgress = 0;
        return false;
    }
    Set<IErrorState> queenErrors = queenCanWorkCache.queenCanWork(queen, housing);
    for (IErrorState errorState : queenErrors) {
        errorLogic.setCondition(true, errorState);
    }
    hasFlowersCache.update(queen, housing);
    boolean hasFlowers = hasFlowersCache.hasFlowers();
    boolean flowerCacheNeedsSync = hasFlowersCache.needsSync();
    errorLogic.setCondition(!hasFlowers, EnumErrorCode.NO_FLOWER);
    boolean canWork = !errorLogic.hasErrors();
    if (active != canWork) {
        setActive(canWork);
    } else if (flowerCacheNeedsSync) {
        syncToClient();
    }
    return canWork;
}
Also used : IBeeHousingInventory(forestry.api.apiculture.IBeeHousingInventory) IErrorState(forestry.api.core.IErrorState) IBee(forestry.api.apiculture.IBee) ItemStack(net.minecraft.item.ItemStack) IErrorLogic(forestry.api.core.IErrorLogic) EnumBeeType(forestry.api.apiculture.EnumBeeType)

Example 4 with IBee

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

the class Bee method copy.

@Override
public IBee copy() {
    NBTTagCompound nbttagcompound = new NBTTagCompound();
    this.writeToNBT(nbttagcompound);
    return new Bee(nbttagcompound);
}
Also used : IBee(forestry.api.apiculture.IBee) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 5 with IBee

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

the class Bee method createOffspring.

private IBee createOffspring(IBeeHousing housing, IBeeGenome mate, int generation) {
    World world = housing.getWorldObj();
    IChromosome[] chromosomes = new IChromosome[genome.getChromosomes().length];
    IChromosome[] parent1 = genome.getChromosomes();
    IChromosome[] parent2 = mate.getChromosomes();
    // Check for mutation. Replace one of the parents with the mutation
    // template if mutation occurred.
    IChromosome[] mutated1 = mutateSpecies(housing, genome, mate);
    if (mutated1 != null) {
        parent1 = mutated1;
    }
    IChromosome[] mutated2 = mutateSpecies(housing, mate, genome);
    if (mutated2 != null) {
        parent2 = mutated2;
    }
    for (int i = 0; i < parent1.length; i++) {
        if (parent1[i] != null && parent2[i] != null) {
            chromosomes[i] = Chromosome.inheritChromosome(world.rand, parent1[i], parent2[i]);
        }
    }
    IBeekeepingMode mode = BeeManager.beeRoot.getBeekeepingMode(world);
    return new Bee(new BeeGenome(chromosomes), mode.isNaturalOffspring(this), generation);
}
Also used : IBeeGenome(forestry.api.apiculture.IBeeGenome) IBee(forestry.api.apiculture.IBee) IChromosome(forestry.api.genetics.IChromosome) IBeekeepingMode(forestry.api.apiculture.IBeekeepingMode) World(net.minecraft.world.World)

Aggregations

IBee (forestry.api.apiculture.IBee)33 ItemStack (net.minecraft.item.ItemStack)17 IBeeGenome (forestry.api.apiculture.IBeeGenome)7 EnumBeeType (forestry.api.apiculture.EnumBeeType)6 World (net.minecraft.world.World)6 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)4 IBeeHousingInventory (forestry.api.apiculture.IBeeHousingInventory)3 IBeeRoot (forestry.api.apiculture.IBeeRoot)3 IAllele (forestry.api.genetics.IAllele)3 GuiAlyzer (forestry.core.gui.GuiAlyzer)3 TextLayoutHelper (forestry.core.gui.TextLayoutHelper)3 ArrayList (java.util.ArrayList)3 IBeekeepingMode (forestry.api.apiculture.IBeekeepingMode)2 IHiveDrop (forestry.api.apiculture.IHiveDrop)2 IHiveFrame (forestry.api.apiculture.IHiveFrame)2 IChromosome (forestry.api.genetics.IChromosome)2 Random (java.util.Random)2 Item (net.minecraft.item.Item)2 IncubatorRecipe (binnie.genetics.machine.incubator.IncubatorRecipe)1