Search in sources :

Example 6 with IAlleleSpecies

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

the class EscritoireGameToken method setTokenSpecies.

private void setTokenSpecies(String speciesUid) {
    IAllele allele = AlleleManager.alleleRegistry.getAllele(speciesUid);
    if (allele instanceof IAlleleSpecies) {
        IAlleleSpecies species = (IAlleleSpecies) allele;
        ISpeciesRoot root = species.getRoot();
        IAllele[] template = root.getTemplate(species);
        this.tokenIndividual = root.templateAsIndividual(template);
        this.tokenStack = root.getMemberStack(this.tokenIndividual, root.getIconType());
    }
}
Also used : IAllele(forestry.api.genetics.IAllele) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies)

Example 7 with IAlleleSpecies

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

the class TileEscritoire method processTurnResult.

private void processTurnResult(GameProfile gameProfile) {
    if (getGame().getStatus() != EscritoireGame.Status.SUCCESS) {
        return;
    }
    IIndividual individual = AlleleManager.alleleRegistry.getIndividual(getStackInSlot(InventoryEscritoire.SLOT_ANALYZE));
    if (individual == null) {
        return;
    }
    IAlleleSpecies species = individual.getGenome().getPrimary();
    for (ItemStack itemstack : species.getResearchBounty(world, gameProfile, individual, game.getBountyLevel())) {
        InventoryUtil.addStack(getInternalInventory(), itemstack, InventoryEscritoire.SLOT_RESULTS_1, InventoryEscritoire.SLOTS_RESULTS_COUNT, true);
    }
}
Also used : IIndividual(forestry.api.genetics.IIndividual) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) ItemStack(net.minecraft.item.ItemStack)

Example 8 with IAlleleSpecies

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

the class WindowAbstractDatabase method initialiseClient.

@Override
@SideOnly(Side.CLIENT)
public void initialiseClient() {
    this.setSize(new Point(176 + this.selectionBoxWidth + 22 + 8, 208));
    this.addEventHandler(EventValueChanged.class, event -> {
        Object value = event.getValue();
        IWidget eventOriginParent = event.getOrigin().getParent();
        if (eventOriginParent instanceof ControlPage && !(value instanceof DatabaseTab)) {
            ControlPage parent = (ControlPage) eventOriginParent;
            if (parent.getValue() instanceof IDatabaseMode) {
                for (IWidget child : parent.getChildren()) {
                    if (child instanceof ControlPages) {
                        if (value == null) {
                            child.hide();
                        } else {
                            child.show();
                            for (IWidget widget : child.getChildren()) {
                                if (widget instanceof PageAbstract) {
                                    PageAbstract pageAbstract = (PageAbstract) widget;
                                    pageAbstract.onValueChanged(value);
                                }
                            }
                        }
                    }
                }
            }
        }
    });
    this.addEventHandler(EventTextEdit.class, EventHandlerOrigin.DIRECT_CHILD, this, event -> {
        for (final ModeWidgets widgets : WindowAbstractDatabase.this.modes.values()) {
            widgets.getListBox().setValidator(object -> {
                if (Objects.equals(event.getValue(), "")) {
                    return true;
                }
                ControlTextOption controlTextOption = (ControlTextOption) object;
                return controlTextOption.getText().toLowerCase().contains(event.getValue().toLowerCase());
            });
        }
    });
    new ControlHelp(this, 4, 4);
    (this.panelInformation = new Panel(this, 24, 24, 144, 176, MinecraftGUI.PanelType.BLACK)).setColor(860416);
    (this.panelSearch = new Panel(this, 176, 24, this.selectionBoxWidth, 160, MinecraftGUI.PanelType.BLACK)).setColor(860416);
    this.modePages = new ControlPages<>(this, 0, 0, this.getSize().xPos(), this.getSize().yPos());
    new ControlTextEdit(this, 176, 184, this.selectionBoxWidth, 16);
    this.createMode(Mode.SPECIES, new ModeWidgets(Mode.SPECIES, this, (area, modePage) -> {
        final GameProfile playerName = this.getUsername();
        final Collection<IAlleleSpecies> speciesList = this.master ? this.system.getAllSpecies() : this.system.getDiscoveredSpecies(this.getWorld(), playerName);
        ControlSpeciesBox controlSpeciesBox = new ControlSpeciesBox(modePage, area.xPos(), area.yPos(), area.width(), area.height());
        controlSpeciesBox.setOptions(speciesList);
        return controlSpeciesBox;
    }));
    this.createMode(Mode.BRANCHES, new ModeWidgets(Mode.BRANCHES, this, (area, modePage) -> {
        final EntityPlayer player = this.getPlayer();
        final GameProfile playerName = player.getGameProfile();
        final Collection<IClassification> speciesList = this.master ? this.system.getAllBranches() : this.system.getDiscoveredBranches(this.getWorld(), playerName);
        ControlBranchBox controlBranchBox = new ControlBranchBox(modePage, area.xPos(), area.yPos(), area.width(), area.height());
        controlBranchBox.setOptions(speciesList);
        return controlBranchBox;
    }));
    this.createMode(Mode.BREEDER, new ModeWidgets(Mode.BREEDER, this, (area, modePage) -> {
        return new ControlListBox(modePage, area.xPos(), area.yPos(), area.width(), area.height(), 12);
    }));
    this.addTabs();
    final ControlTabBar<IDatabaseMode> tab = new ControlTabBar<>(this, 176 + this.selectionBoxWidth, 24, 22, 176, Alignment.RIGHT, this.modePages.getValues(), DatabaseControlTab::new);
    CraftGUIUtil.linkWidgets(tab, this.modePages);
    this.changeMode(Mode.SPECIES);
    for (final IDatabaseMode mode : this.modes.keySet()) {
        ModeWidgets modeWidgets = this.modes.get(mode);
        modeWidgets.setInfoTabs(new ControlTabBar<>(modeWidgets.getModePage(), 8, 24, 16, 176, Alignment.LEFT, modeWidgets.getInfoPages().getValues()));
        CraftGUIUtil.linkWidgets(modeWidgets.getInfoTabs(), modeWidgets.getInfoPages());
    }
}
Also used : IBreedingTracker(forestry.api.genetics.IBreedingTracker) ControlTextOption(binnie.core.gui.controls.listbox.ControlTextOption) GameProfile(com.mojang.authlib.GameProfile) HashMap(java.util.HashMap) ControlListBox(binnie.core.gui.controls.listbox.ControlListBox) ControlTabBar(binnie.core.gui.controls.tab.ControlTabBar) Panel(binnie.core.gui.window.Panel) Side(net.minecraftforge.fml.relauncher.Side) Map(java.util.Map) IWidget(binnie.core.api.gui.IWidget) ControlTextEdit(binnie.core.gui.controls.ControlTextEdit) CraftGUIUtil(binnie.core.gui.geometry.CraftGUIUtil) MinecraftGUI(binnie.core.gui.minecraft.MinecraftGUI) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Nullable(javax.annotation.Nullable) IBreedingSystem(binnie.core.api.genetics.IBreedingSystem) ControlPages(binnie.core.gui.controls.page.ControlPages) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) Collection(java.util.Collection) EventTextEdit(binnie.core.gui.events.EventTextEdit) ControlTab(binnie.core.gui.controls.tab.ControlTab) EventValueChanged(binnie.core.gui.events.EventValueChanged) ControlHelp(binnie.core.gui.minecraft.control.ControlHelp) I18N(binnie.core.util.I18N) Objects(java.util.Objects) Alignment(binnie.core.api.gui.Alignment) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EventHandlerOrigin(binnie.core.api.gui.events.EventHandlerOrigin) ControlPage(binnie.core.gui.controls.page.ControlPage) IClassification(forestry.api.genetics.IClassification) Point(binnie.core.gui.geometry.Point) Window(binnie.core.gui.minecraft.Window) ControlPage(binnie.core.gui.controls.page.ControlPage) ControlTextEdit(binnie.core.gui.controls.ControlTextEdit) ControlListBox(binnie.core.gui.controls.listbox.ControlListBox) ControlTextOption(binnie.core.gui.controls.listbox.ControlTextOption) Point(binnie.core.gui.geometry.Point) ControlTabBar(binnie.core.gui.controls.tab.ControlTabBar) Panel(binnie.core.gui.window.Panel) ControlPages(binnie.core.gui.controls.page.ControlPages) GameProfile(com.mojang.authlib.GameProfile) ControlHelp(binnie.core.gui.minecraft.control.ControlHelp) Collection(java.util.Collection) EntityPlayer(net.minecraft.entity.player.EntityPlayer) IWidget(binnie.core.api.gui.IWidget) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 9 with IAlleleSpecies

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

the class ControlMutationBox method setSpecies.

public void setSpecies(@Nullable final IAlleleSpecies species) {
    if (species != this.species) {
        this.species = species;
        this.movePercentage(-100.0f);
        final IBreedingSystem system = ((WindowAbstractDatabase) this.getTopParent()).getBreedingSystem();
        final List<IMutation> discovered = system.getDiscoveredMutations(Window.get(this).getWorld(), Window.get(this).getUsername());
        if (species != null) {
            if (this.type == Type.Resultant) {
                this.setOptions(system.getResultantMutations(species));
            } else {
                final List<IMutation> mutations = system.getFurtherMutations(species);
                int i = 0;
                while (i < mutations.size()) {
                    final IMutation mutation = mutations.get(i);
                    if (!discovered.contains(mutation) && !((IAlleleSpecies) mutation.getTemplate()[0]).isCounted()) {
                        mutations.remove(i);
                    } else {
                        ++i;
                    }
                }
                this.setOptions(mutations);
            }
        }
    }
}
Also used : IMutation(forestry.api.genetics.IMutation) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) IBreedingSystem(binnie.core.api.genetics.IBreedingSystem)

Example 10 with IAlleleSpecies

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

the class TreeBreedingSystem method getTreesThatHaveWood.

@Override
public Collection<IAlleleSpecies> getTreesThatHaveWood(final ItemStack wood, final boolean master, final World world, final GameProfile player) {
    final Collection<IAlleleSpecies> set = master ? this.getAllSpecies() : this.getDiscoveredSpecies(world, player);
    final List<IAlleleSpecies> found = new ArrayList<>();
    for (final IAlleleSpecies species : set) {
        IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
        ITreeGenome genome = TreeManager.treeRoot.templateAsGenome(TreeManager.treeRoot.getTemplate(tSpecies));
        IAlleleTreeSpecies treeSpecies = genome.getPrimary();
        final ItemStack woodStack = treeSpecies.getWoodProvider().getWoodStack();
        if (woodStack.isItemEqual(wood)) {
            found.add(species);
        }
    }
    return found;
}
Also used : IAlleleTreeSpecies(forestry.api.arboriculture.IAlleleTreeSpecies) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) ITreeGenome(forestry.api.arboriculture.ITreeGenome)

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