Search in sources :

Example 6 with IGenome

use of forestry.api.genetics.IGenome in project Binnie by ForestryMC.

the class ToleranceSystem method canAlter.

public boolean canAlter(final ItemStack stack, final ItemStack acclim) {
    final IIndividual member = AlleleManager.alleleRegistry.getIndividual(stack);
    final IGenome genome = member.getGenome();
    final IAlleleTolerance tolAllele = (IAlleleTolerance) genome.getActiveAllele(this.chromosomeType);
    final Tolerance tol = Tolerance.get(tolAllele.getValue());
    final float effect = this.type.getEffect(acclim);
    return (effect > 0.0f && tol.getBounds()[1] < 5) || (effect < 0.0f && tol.getBounds()[0] > -5);
}
Also used : IGenome(forestry.api.genetics.IGenome) IAlleleTolerance(forestry.api.genetics.IAlleleTolerance) IIndividual(forestry.api.genetics.IIndividual) Tolerance(binnie.core.genetics.Tolerance) IAlleleTolerance(forestry.api.genetics.IAlleleTolerance)

Example 7 with IGenome

use of forestry.api.genetics.IGenome in project EnderIO by SleepyTrousers.

the class SpeciesItemFilter method setItem.

@Nonnull
private ItemStack setItem(int slot, @Nonnull ItemStack itemStack) {
    if (slot < 0 || slot >= items.size()) {
        return ItemStack.EMPTY;
    }
    ItemStack prevStack = items.get(slot);
    if (!prevStack.isEmpty()) {
        this.primarySpeciesUids[slot] = null;
        this.secondarySpeciesUids[slot] = null;
    }
    items.set(slot, itemStack);
    ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(itemStack);
    if (speciesRoot != null) {
        IIndividual member = speciesRoot.getMember(itemStack);
        if (member != null) {
            IGenome genome = member.getGenome();
            primarySpeciesUids[slot] = genome.getPrimary().getUID();
            secondarySpeciesUids[slot] = genome.getSecondary().getUID();
        }
    }
    return prevStack;
}
Also used : IGenome(forestry.api.genetics.IGenome) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IIndividual(forestry.api.genetics.IIndividual) ItemStack(net.minecraft.item.ItemStack) Nonnull(javax.annotation.Nonnull)

Example 8 with IGenome

use of forestry.api.genetics.IGenome in project ForestryMC by ForestryMC.

the class Genome method getChromosome.

private static IChromosome getChromosome(ItemStack itemStack, IChromosomeType chromosomeType, ISpeciesRoot speciesRoot) {
    NBTTagCompound nbtTagCompound = itemStack.getTagCompound();
    if (nbtTagCompound == null) {
        nbtTagCompound = new NBTTagCompound();
        itemStack.setTagCompound(nbtTagCompound);
    }
    NBTTagCompound genomeNbt = nbtTagCompound.getCompoundTag("Genome");
    if (genomeNbt.hasNoTags()) {
        Log.error("Got a genetic item with no genome, setting it to a default value.");
        genomeNbt = new NBTTagCompound();
        IAllele[] defaultTemplate = speciesRoot.getDefaultTemplate();
        IGenome genome = speciesRoot.templateAsGenome(defaultTemplate);
        genome.writeToNBT(genomeNbt);
        nbtTagCompound.setTag("Genome", genomeNbt);
    }
    IChromosome[] chromosomes = getChromosomes(genomeNbt, speciesRoot);
    return chromosomes[chromosomeType.ordinal()];
}
Also used : IAllele(forestry.api.genetics.IAllele) IGenome(forestry.api.genetics.IGenome) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IChromosome(forestry.api.genetics.IChromosome)

Example 9 with IGenome

use of forestry.api.genetics.IGenome in project ForestryMC by ForestryMC.

the class GuiAlyzer method drawAnalyticsPageMutations.

public void drawAnalyticsPageMutations(IIndividual individual) {
    textLayout.startPage(COLUMN_0, COLUMN_1, COLUMN_2);
    textLayout.drawLine(Translator.translateToLocal("for.gui.beealyzer.mutations") + ":", COLUMN_0);
    textLayout.newLine();
    RenderHelper.enableGUIStandardItemLighting();
    IGenome genome = individual.getGenome();
    ISpeciesRoot speciesRoot = genome.getSpeciesRoot();
    IAlleleSpecies species = genome.getPrimary();
    int columnWidth = 50;
    int x = 0;
    EntityPlayer player = Minecraft.getMinecraft().player;
    IBreedingTracker breedingTracker = speciesRoot.getBreedingTracker(player.world, player.getGameProfile());
    for (IMutation mutation : speciesRoot.getCombinations(species)) {
        if (breedingTracker.isDiscovered(mutation)) {
            drawMutationInfo(mutation, species, COLUMN_0 + x, breedingTracker);
        } else {
            // Do not display secret undiscovered mutations.
            if (mutation.isSecret()) {
                continue;
            }
            drawUnknownMutation(mutation, COLUMN_0 + x, breedingTracker);
        }
        x += columnWidth;
        if (x >= columnWidth * 4) {
            x = 0;
            textLayout.newLine(16);
        }
    }
    textLayout.endPage();
}
Also used : IGenome(forestry.api.genetics.IGenome) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IMutation(forestry.api.genetics.IMutation) IBreedingTracker(forestry.api.genetics.IBreedingTracker) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 10 with IGenome

use of forestry.api.genetics.IGenome in project ForestryMC by ForestryMC.

the class SpeciesWidget method handleMouseClick.

@Override
public void handleMouseClick(int mouseX, int mouseY, int mouseButton) {
    ItemStack stack = gui.mc.player.inventory.getItemStack();
    if (!stack.isEmpty()) {
        IIndividual individual = AlleleManager.alleleRegistry.getIndividual(stack);
        if (individual != null) {
            IGenome genome = individual.getGenome();
            onSelect(mouseButton == 0 ? genome.getPrimary() : genome.getSecondary());
            return;
        }
    }
    if (mouseButton == 1) {
        onSelect(null);
    } else {
        SoundUtil.playButtonClick();
        gui.onModuleClick(this);
    }
}
Also used : IGenome(forestry.api.genetics.IGenome) IIndividual(forestry.api.genetics.IIndividual) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IGenome (forestry.api.genetics.IGenome)13 IIndividual (forestry.api.genetics.IIndividual)10 IAllele (forestry.api.genetics.IAllele)7 ISpeciesRoot (forestry.api.genetics.ISpeciesRoot)7 ItemStack (net.minecraft.item.ItemStack)5 Gene (binnie.core.genetics.Gene)2 Tolerance (binnie.core.genetics.Tolerance)2 IAlleleTolerance (forestry.api.genetics.IAlleleTolerance)2 IChromosome (forestry.api.genetics.IChromosome)2 IChromosomeType (forestry.api.genetics.IChromosomeType)2 Random (java.util.Random)2 Nullable (javax.annotation.Nullable)2 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)1 IGene (binnie.core.api.genetics.IGene)1 MachineUtil (binnie.core.machines.MachineUtil)1 ErrorState (binnie.core.machines.errors.ErrorState)1 IAlleleSpecies (forestry.api.genetics.IAlleleSpecies)1 IBreedingTracker (forestry.api.genetics.IBreedingTracker)1 IFilterRuleType (forestry.api.genetics.IFilterRuleType)1 IMutation (forestry.api.genetics.IMutation)1