Search in sources :

Example 11 with IAlleleSpecies

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

the class TreeBreedingSystem method calculateArrays.

@Override
public final void calculateArrays() {
    super.calculateArrays();
    for (final IAlleleSpecies species : this.allActiveSpecies) {
        final IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
        final ITreeGenome genome = (ITreeGenome) this.getSpeciesRoot().templateAsGenome(this.getSpeciesRoot().getTemplate(tSpecies));
        IAlleleTreeSpecies treeSpecies = genome.getPrimary();
        final ItemStack wood = treeSpecies.getWoodProvider().getWoodStack();
        if (!wood.isEmpty()) {
            this.allWoods.add(wood);
        }
        /*for (final ItemStack wood : tSpecies.getRoot().templateAsIndividual(getSpeciesRoot().getTemplate(tSpecies.getUID())).getProduceList()) {
				this.allWoods.add(wood);
			}*/
        this.allFruits.addAll(genome.getFruitProvider().getProducts().keySet());
    }
}
Also used : IAlleleTreeSpecies(forestry.api.arboriculture.IAlleleTreeSpecies) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) ItemStack(net.minecraft.item.ItemStack) ITreeGenome(forestry.api.arboriculture.ITreeGenome)

Example 12 with IAlleleSpecies

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

the class TreeBreedingSystem method getTreesThatBearFruit.

@Override
public Collection<IAlleleSpecies> getTreesThatBearFruit(final ItemStack fruit, 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) {
        final IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
        final ITreeGenome genome = (ITreeGenome) this.getSpeciesRoot().templateAsGenome(this.getSpeciesRoot().getTemplate(tSpecies));
        for (final ItemStack fruit2 : genome.getFruitProvider().getProducts().keySet()) {
            if (fruit2.isItemEqual(fruit)) {
                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)

Example 13 with IAlleleSpecies

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

the class TreeBreedingSystem method getTreesThatCanBearFruit.

@Override
public Collection<IAlleleSpecies> getTreesThatCanBearFruit(final ItemStack fruit, 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<>();
    final Set<IFruitFamily> providers = new HashSet<>();
    for (final IAlleleSpecies species : set) {
        final IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
        final ITreeGenome genome = (ITreeGenome) this.getSpeciesRoot().templateAsGenome(this.getSpeciesRoot().getTemplate(tSpecies));
        for (final ItemStack fruit2 : genome.getFruitProvider().getProducts().keySet()) {
            if (fruit2.isItemEqual(fruit)) {
                providers.add(genome.getFruitProvider().getFamily());
            }
        }
    }
    for (final IAlleleSpecies species : set) {
        final IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
        for (final IFruitFamily family : providers) {
            if (tSpecies.getSuitableFruit().contains(family)) {
                found.add(species);
                break;
            }
        }
    }
    return found;
}
Also used : IAlleleTreeSpecies(forestry.api.arboriculture.IAlleleTreeSpecies) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) ArrayList(java.util.ArrayList) IFruitFamily(forestry.api.genetics.IFruitFamily) ItemStack(net.minecraft.item.ItemStack) ITreeGenome(forestry.api.arboriculture.ITreeGenome) HashSet(java.util.HashSet)

Example 14 with IAlleleSpecies

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

the class InoculatorRecipeCategory method setRecipe.

@Override
public void setRecipe(IRecipeLayout recipeLayout, InoculatorRecipeWrapper recipeWrapper, IIngredients ingredients) {
    if (!splicer) {
        IDrawable tank = GeneticsJeiPlugin.drawables.getTank();
        IDrawable tankOverlay = GeneticsJeiPlugin.drawables.getTankOverlay();
        IGuiFluidStackGroup fluidStacks = recipeLayout.getFluidStacks();
        fluidStacks.init(Inoculator.TANK_VEKTOR, true, 1, 1, 16, 58, 100, false, tankOverlay);
        fluidStacks.setBackground(Inoculator.TANK_VEKTOR, tank);
        fluidStacks.set(ingredients);
    }
    IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
    itemStacks.init(0, true, 22, 0);
    itemStacks.init(1, true, 42, 21);
    itemStacks.init(2, false, 92, 21);
    IDrawable slot = GeneticsJeiPlugin.guiHelper.getSlotDrawable();
    for (int i = 0; i <= 2; i++) {
        itemStacks.setBackground(i, slot);
    }
    recipeWrapper.setCurrentIngredients(itemStacks.getGuiIngredients());
    IFocus<?> focus = recipeLayout.getFocus();
    if (focus != null) {
        Object focusValue = focus.getValue();
        if (focusValue instanceof ItemStack) {
            ItemStack focusStack = (ItemStack) focusValue;
            if (AlleleManager.alleleRegistry.isIndividual(focusStack)) {
                if (focus.getMode() == IFocus.Mode.INPUT) {
                    ItemStack serum = recipeWrapper.getInputSerum();
                    ItemStack output = InoculatorLogic.applySerum(focusStack, serum);
                    itemStacks.set(0, serum);
                    itemStacks.set(1, focusStack);
                    itemStacks.set(2, output);
                    return;
                } else if (focus.getMode() == IFocus.Mode.OUTPUT) {
                    IIndividual individual = AlleleManager.alleleRegistry.getIndividual(focusStack);
                    if (individual != null) {
                        ISpeciesRoot speciesRoot = individual.getGenome().getSpeciesRoot();
                        IAlleleSpecies species = individual.getGenome().getPrimary();
                        ItemStack serum = ItemSerum.create(new Gene(species, speciesRoot.getSpeciesChromosomeType(), speciesRoot));
                        // set fully charged
                        serum.setItemDamage(0);
                        itemStacks.set(0, serum);
                        itemStacks.set(1, recipeWrapper.getWildcardTarget());
                        itemStacks.set(2, focusStack);
                        return;
                    }
                }
            } else if (focusStack.getItem() instanceof ItemSerum) {
                ItemStack input = recipeWrapper.getWildcardTarget();
                ItemStack output = InoculatorLogic.applySerum(input, focusStack);
                itemStacks.set(0, focusStack);
                itemStacks.set(1, input);
                itemStacks.set(2, output);
                return;
            }
        }
    }
    itemStacks.set(ingredients);
}
Also used : ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IIndividual(forestry.api.genetics.IIndividual) Gene(binnie.core.genetics.Gene) IGuiFluidStackGroup(mezz.jei.api.gui.IGuiFluidStackGroup) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) ItemSerum(binnie.genetics.item.ItemSerum) IGuiItemStackGroup(mezz.jei.api.gui.IGuiItemStackGroup) ItemStack(net.minecraft.item.ItemStack) IDrawable(mezz.jei.api.gui.IDrawable)

Example 15 with IAlleleSpecies

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

the class PageWood method onValueChanged.

@Override
public void onValueChanged(final ItemStack species) {
    this.deleteAllChildren();
    final WindowAbstractDatabase database = Window.get(this);
    new ControlText(this, new Area(0, 0, this.getSize().xPos(), 24), this.getValue().toString(), TextJustification.MIDDLE_CENTER);
    ITreeBreedingSystem breedingSystem = (ITreeBreedingSystem) database.getBreedingSystem();
    final Collection<IAlleleSpecies> trees = breedingSystem.getTreesThatHaveWood(species, database.isMaster(), database.getWorld(), database.getUsername());
    new ControlSpeciesBox(this, 4, 24, this.getSize().xPos() - 8, this.getSize().yPos() - 4 - 24).setOptions(trees);
}
Also used : ITreeBreedingSystem(binnie.genetics.api.ITreeBreedingSystem) Area(binnie.core.gui.geometry.Area) ControlText(binnie.core.gui.controls.ControlText) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) WindowAbstractDatabase(binnie.core.gui.database.WindowAbstractDatabase) ControlSpeciesBox(binnie.core.gui.database.ControlSpeciesBox)

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