Search in sources :

Example 21 with IIndividual

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

the class WindowFieldKit method refreshSpecies.

private void refreshSpecies() {
    final ItemStack item = this.getWindowInventory().getStackInSlot(INDIVIDUAL_SLOT);
    if (item.isEmpty() || !AlleleManager.alleleRegistry.isIndividual(item)) {
        return;
    }
    final IIndividual ind = AlleleManager.alleleRegistry.getIndividual(item);
    if (ind == null) {
        return;
    }
    final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(item);
    if (root == null) {
        return;
    }
    IBreedingSystem system = Binnie.GENETICS.getSystem(root);
    this.chromo.setSystem(system);
    final Random rand = new Random();
    this.info.clear();
    for (final IChromosomeType type : root.getKaryotype()) {
        if (!Binnie.GENETICS.isInvalidChromosome(type)) {
            final IAllele allele = ind.getGenome().getActiveAllele(type);
            final List<String> infos = new ArrayList<>();
            int i = 0;
            for (String pref = root.getUID() + ".fieldkit." + type.getName().toLowerCase() + '.'; I18N.canLocalise(pref + i); ++i) {
                infos.add(I18N.localise(pref + i));
            }
            String text = system.getAlleleName(type, allele);
            if (!infos.isEmpty()) {
                text = infos.get(rand.nextInt(infos.size()));
            }
            this.info.put(type, text);
            this.chromo.setSystem(system);
        }
    }
}
Also used : IAllele(forestry.api.genetics.IAllele) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IIndividual(forestry.api.genetics.IIndividual) Random(java.util.Random) ArrayList(java.util.ArrayList) IBreedingSystem(binnie.core.api.genetics.IBreedingSystem) IChromosomeType(forestry.api.genetics.IChromosomeType) ItemStack(net.minecraft.item.ItemStack) Point(binnie.core.gui.geometry.Point)

Example 22 with IIndividual

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

the class GenepoolRecipeMaker method create.

public static List<GenepoolRecipeWrapper> create() {
    List<GenepoolRecipeWrapper> recipes = new ArrayList<>();
    Collection<ISpeciesRoot> roots = AlleleManager.alleleRegistry.getSpeciesRoot().values();
    for (ISpeciesRoot root : roots) {
        ISpeciesType[] speciesTypes = root.getIconType().getClass().getEnumConstants();
        IAllele[] defaultTemplate = root.getDefaultTemplate();
        IIndividual individual = root.templateAsIndividual(defaultTemplate);
        for (ISpeciesType speciesType : speciesTypes) {
            ItemStack memberStack = root.getMemberStack(individual, speciesType);
            memberStack.setItemDamage(OreDictionary.WILDCARD_VALUE);
            GenepoolRecipeWrapper recipeWrapper = new GenepoolRecipeWrapper(memberStack);
            recipes.add(recipeWrapper);
        }
    }
    return recipes;
}
Also used : IAllele(forestry.api.genetics.IAllele) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IIndividual(forestry.api.genetics.IIndividual) ISpeciesType(forestry.api.genetics.ISpeciesType) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack)

Example 23 with IIndividual

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

the class WindowAnalyst method setStack.

@SideOnly(Side.CLIENT)
public void setStack(ItemStack stack) {
    IIndividual ind = AlleleManager.alleleRegistry.getIndividual(stack);
    setIndividual(ind);
}
Also used : IIndividual(forestry.api.genetics.IIndividual) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 24 with IIndividual

use of forestry.api.genetics.IIndividual 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 25 with IIndividual

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

the class BreedingSystem method getConversionStack.

@Override
public ItemStack getConversionStack(final ItemStack stack) {
    IIndividual conversion = this.getConversion(stack);
    if (conversion == null) {
        return ItemStack.EMPTY;
    }
    ISpeciesType type = this.getSpeciesRoot().getType(stack);
    if (type == null) {
        type = this.getDefaultType();
    }
    return this.getSpeciesRoot().getMemberStack(conversion, type);
}
Also used : IIndividual(forestry.api.genetics.IIndividual) ISpeciesType(forestry.api.genetics.ISpeciesType)

Aggregations

IIndividual (forestry.api.genetics.IIndividual)49 ISpeciesRoot (forestry.api.genetics.ISpeciesRoot)30 ItemStack (net.minecraft.item.ItemStack)29 IAllele (forestry.api.genetics.IAllele)14 IGenome (forestry.api.genetics.IGenome)10 ISpeciesType (forestry.api.genetics.ISpeciesType)8 Nullable (javax.annotation.Nullable)7 Gene (binnie.core.genetics.Gene)6 IChromosomeType (forestry.api.genetics.IChromosomeType)6 ArrayList (java.util.ArrayList)6 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)5 Random (java.util.Random)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 IGene (binnie.core.api.genetics.IGene)4 IAlleleSpecies (forestry.api.genetics.IAlleleSpecies)4 IBreedingTracker (forestry.api.genetics.IBreedingTracker)3 IFilterData (forestry.api.genetics.IFilterData)3 Tolerance (binnie.core.genetics.Tolerance)2 Point (binnie.core.gui.geometry.Point)2 ControlItemDisplay (binnie.core.gui.minecraft.control.ControlItemDisplay)2