Search in sources :

Example 1 with ISpeciesType

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

the class TileGeneticFilter method getValidDirections.

public Collection<EnumFacing> getValidDirections(ItemStack itemStack, EnumFacing from) {
    ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(itemStack);
    IIndividual individual = null;
    ISpeciesType type = null;
    if (root != null) {
        individual = root.getMember(itemStack);
        type = root.getType(itemStack);
    }
    IFilterData filterData = new FilterData(root, individual, type);
    List<EnumFacing> validFacings = new LinkedList<>();
    for (EnumFacing facing : EnumFacing.VALUES) {
        if (facing == from) {
            continue;
        }
        if (isValidFacing(facing, itemStack, filterData)) {
            validFacings.add(facing);
        }
    }
    return validFacings;
}
Also used : ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IIndividual(forestry.api.genetics.IIndividual) IFilterData(forestry.api.genetics.IFilterData) ISpeciesType(forestry.api.genetics.ISpeciesType) EnumFacing(net.minecraft.util.EnumFacing) IFilterData(forestry.api.genetics.IFilterData) FilterData(forestry.sorting.FilterData) LinkedList(java.util.LinkedList)

Example 2 with ISpeciesType

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

the class FilterLogic method isValid.

@Override
public boolean isValid(ItemStack itemStack, EnumFacing facing) {
    ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(itemStack);
    IIndividual individual = null;
    ISpeciesType type = null;
    if (root != null) {
        individual = root.getMember(itemStack);
        type = root.getType(itemStack);
    }
    return isValid(facing, itemStack, new FilterData(root, individual, type));
}
Also used : ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IIndividual(forestry.api.genetics.IIndividual) ISpeciesType(forestry.api.genetics.ISpeciesType) IFilterData(forestry.api.genetics.IFilterData)

Example 3 with ISpeciesType

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

the class WindowGenesis method refreshPickup.

private void refreshPickup() {
    this.panelPickup.deleteAllChildren();
    int i = 0;
    IBreedingSystem system = Binnie.GENETICS.getSystem(this.root);
    for (ISpeciesType type : system.getActiveTypes()) {
        IIndividual ind = this.root.templateAsIndividual(this.template);
        ind.analyze();
        ItemStack stack = this.root.getMemberStack(ind, type);
        ControlItemDisplay display = new ControlItemDisplay(this.panelPickup, 4 + i % 3 * 18, 4 + i / 3 * 18);
        display.setItemStack(stack);
        display.setTooltip();
        display.addEventHandler(EventMouse.Down.class, EventHandlerOrigin.SELF, display, event -> {
            NBTTagCompound nbt = new NBTTagCompound();
            stack.writeToNBT(nbt);
            Window.get(event.getOrigin()).sendClientAction(ACTION_GENESIS, nbt);
        });
        ++i;
    }
}
Also used : ControlItemDisplay(binnie.core.gui.minecraft.control.ControlItemDisplay) IIndividual(forestry.api.genetics.IIndividual) ISpeciesType(forestry.api.genetics.ISpeciesType) EventMouse(binnie.core.gui.events.EventMouse) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IBreedingSystem(binnie.core.api.genetics.IBreedingSystem) ItemStack(net.minecraft.item.ItemStack)

Example 4 with ISpeciesType

use of forestry.api.genetics.ISpeciesType 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 5 with ISpeciesType

use of forestry.api.genetics.ISpeciesType 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)8 ISpeciesType (forestry.api.genetics.ISpeciesType)8 ISpeciesRoot (forestry.api.genetics.ISpeciesRoot)6 ItemStack (net.minecraft.item.ItemStack)4 IAllele (forestry.api.genetics.IAllele)3 IFilterData (forestry.api.genetics.IFilterData)3 ArrayList (java.util.ArrayList)3 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)2 Gene (binnie.core.genetics.Gene)2 IChromosomeType (forestry.api.genetics.IChromosomeType)2 LinkedList (java.util.LinkedList)2 EnumFacing (net.minecraft.util.EnumFacing)2 EventMouse (binnie.core.gui.events.EventMouse)1 ControlItemDisplay (binnie.core.gui.minecraft.control.ControlItemDisplay)1 FilterData (forestry.sorting.FilterData)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1