Search in sources :

Example 31 with IAlleleSpecies

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

the class SpeciesWidget method draw.

@Override
public void draw(int startX, int startY) {
    int x = xPos + startX;
    int y = yPos + startY;
    IFilterLogic logic = gui.getLogic();
    IAlleleSpecies allele = (IAlleleSpecies) logic.getGenomeFilter(facing, index, active);
    if (allele != null) {
        GuiUtil.drawItemStack(manager.gui, ITEMS.getOrDefault(allele, ItemStack.EMPTY), x, y);
    }
    TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
    if (this.gui.selection.isSame(this)) {
        textureManager.bindTexture(SelectionWidget.TEXTURE);
        gui.drawTexturedModalRect(x - 1, y - 1, 212, 0, 18, 18);
    }
}
Also used : TextureManager(net.minecraft.client.renderer.texture.TextureManager) IFilterLogic(forestry.api.genetics.IFilterLogic) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies)

Example 32 with IAlleleSpecies

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

the class PagePlanksTrees method getTreesThatMakePlanks.

private static Collection<IAlleleSpecies> getTreesThatMakePlanks(ItemStack fruit, boolean master, World world, GameProfile player) {
    if (fruit == null) {
        return new ArrayList<>();
    }
    ITreeRoot treeRoot = TreeManager.treeRoot;
    IBreedingSystem system = Binnie.GENETICS.getSystem(treeRoot);
    final Collection<IAlleleSpecies> set = master ? system.getAllSpecies() : system.getDiscoveredSpecies(world, player);
    final List<IAlleleSpecies> found = new ArrayList<>();
    for (final IAlleleSpecies species : set) {
        final IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
        ITreeGenome genome = treeRoot.templateAsGenome(treeRoot.getTemplate(tSpecies));
        IAlleleTreeSpecies treeSpecies = genome.getPrimary();
        final ItemStack woodStack = treeSpecies.getWoodProvider().getWoodStack();
        ItemStack plankProduct = LumbermillRecipeManager.getPlankProduct(woodStack, world);
        if (!plankProduct.isEmpty() && fruit.isItemEqual(plankProduct)) {
            found.add(species);
        }
    }
    return found;
}
Also used : IAlleleTreeSpecies(forestry.api.arboriculture.IAlleleTreeSpecies) ITreeRoot(forestry.api.arboriculture.ITreeRoot) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) ArrayList(java.util.ArrayList) IBreedingSystem(binnie.core.api.genetics.IBreedingSystem) ItemStack(net.minecraft.item.ItemStack) ITreeGenome(forestry.api.arboriculture.ITreeGenome)

Example 33 with IAlleleSpecies

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

the class ControlMutationSymbol method getTooltip.

@Override
public void getTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) {
    if (this.type == 1 && this.discovered) {
        final IAlleleSpecies species1 = this.value.getAllele0();
        final IAlleleSpecies species2 = this.value.getAllele1();
        final IBreedingSystem system = ((WindowAbstractDatabase) this.getTopParent()).getBreedingSystem();
        final float chance = system.getChance(this.value, Window.get(this).getPlayer(), species1, species2);
        tooltip.add(I18N.localise(DatabaseConstants.CONTROL_KEY + ".chance", chance));
        for (final String string : this.value.getSpecialConditions()) {
            tooltip.add(string);
        }
    }
}
Also used : IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) IBreedingSystem(binnie.core.api.genetics.IBreedingSystem)

Example 34 with IAlleleSpecies

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

the class ControlSpeciesBox method setBranch.

public void setBranch(final IClassification branch) {
    if (branch != this.branch) {
        this.branch = branch;
        final List<IAlleleSpecies> speciesList2 = new ArrayList<>();
        this.movePercentage(-100.0f);
        this.setOptions(speciesList2);
        // final EntityPlayer player = Window.get(this).getPlayer();
        final GameProfile playerName = Window.get(this).getUsername();
        final WindowAbstractDatabase db = Window.get(this);
        IBreedingSystem breedingSystem = db.getBreedingSystem();
        final Collection<IAlleleSpecies> speciesList3 = db.isMaster() ? breedingSystem.getAllSpecies() : breedingSystem.getDiscoveredSpecies(db.getWorld(), playerName);
        if (branch != null) {
            for (final IAlleleSpecies species : branch.getMemberSpecies()) {
                if (speciesList3.contains(species)) {
                    speciesList2.add(species);
                }
            }
        }
        this.setOptions(speciesList2);
    }
}
Also used : GameProfile(com.mojang.authlib.GameProfile) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) ArrayList(java.util.ArrayList) IBreedingSystem(binnie.core.api.genetics.IBreedingSystem)

Example 35 with IAlleleSpecies

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

the class BreedingSystem method syncTracker.

@Override
public final void syncTracker(final IBreedingTracker tracker) {
    if (allActiveSpecies.isEmpty()) {
        calculateArrays();
    }
    this.discoveredSpeciesPercentage = 0.0f;
    this.totalSpeciesCount = 0;
    this.discoveredSpeciesCount = 0;
    this.totalSecretCount = 0;
    this.discoveredSecretCount = 0;
    final Collection<IAlleleSpecies> discoveredSpecies = this.getDiscoveredSpecies(tracker);
    final Collection<IAlleleSpecies> allSpecies = this.getAllSpecies();
    for (final IAlleleSpecies species : allSpecies) {
        if (!this.isSecret(species)) {
            ++this.totalSpeciesCount;
            if (!this.isSpeciesDiscovered(species, tracker)) {
                continue;
            }
            ++this.discoveredSpeciesCount;
        } else {
            ++this.totalSecretCount;
            if (!this.isSpeciesDiscovered(species, tracker)) {
                continue;
            }
            ++this.discoveredSecretCount;
        }
    }
    this.discoveredBranchPercentage = 0.0f;
    this.totalBranchCount = 0;
    this.discoveredBranchCount = 0;
    final Collection<IClassification> discoveredBranches = this.getDiscoveredBranches(tracker);
    final Collection<IClassification> allBranches = this.getAllBranches();
    for (final IClassification branch : allBranches) {
        if (!this.isSecret(branch)) {
            ++this.totalBranchCount;
            if (!discoveredBranches.contains(branch)) {
                continue;
            }
            ++this.discoveredBranchCount;
        } else {
            ++this.totalSecretBranchCount;
            if (!discoveredBranches.contains(branch)) {
                continue;
            }
            ++this.discoveredSecretBranchCount;
        }
    }
    this.discoveredSpeciesPercentage = this.discoveredSpeciesCount / this.totalSpeciesCount;
    this.discoveredBranchPercentage = this.discoveredBranchCount / this.totalBranchCount;
    final String epithet = this.getEpitome();
    this.onSyncBreedingTracker(tracker);
}
Also used : IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) IClassification(forestry.api.genetics.IClassification)

Aggregations

IAlleleSpecies (forestry.api.genetics.IAlleleSpecies)37 ItemStack (net.minecraft.item.ItemStack)11 IAlleleTreeSpecies (forestry.api.arboriculture.IAlleleTreeSpecies)7 ITreeGenome (forestry.api.arboriculture.ITreeGenome)6 IAllele (forestry.api.genetics.IAllele)6 ArrayList (java.util.ArrayList)6 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)5 IIndividual (forestry.api.genetics.IIndividual)4 ISpeciesRoot (forestry.api.genetics.ISpeciesRoot)4 ControlText (binnie.core.gui.controls.ControlText)3 ControlSpeciesBox (binnie.core.gui.database.ControlSpeciesBox)3 WindowAbstractDatabase (binnie.core.gui.database.WindowAbstractDatabase)3 Area (binnie.core.gui.geometry.Area)3 IBreedingTracker (forestry.api.genetics.IBreedingTracker)3 IClassification (forestry.api.genetics.IClassification)3 IMutation (forestry.api.genetics.IMutation)3 Nullable (javax.annotation.Nullable)3 ITreeBreedingSystem (binnie.genetics.api.ITreeBreedingSystem)2 GameProfile (com.mojang.authlib.GameProfile)2 Alignment (binnie.core.api.gui.Alignment)1