use of forestry.api.genetics.IIndividual in project Binnie by ForestryMC.
the class ControlIndividualDisplay method setSpecies.
public void setSpecies(final IAlleleSpecies species, EnumDiscoveryState state) {
final ISpeciesRoot speciesRoot = Binnie.GENETICS.getSpeciesRoot(species);
final IBreedingSystem system = Binnie.GENETICS.getSystem(speciesRoot);
final IAllele[] template = system.getSpeciesRoot().getTemplate(species);
final IIndividual ind = system.getSpeciesRoot().templateAsIndividual(template);
super.setItemStack(system.getSpeciesRoot().getMemberStack(ind, system.getDefaultType()));
this.species = species;
final GameProfile username = Window.get(this).getUsername();
if (state == EnumDiscoveryState.UNDETERMINED) {
state = (system.isSpeciesDiscovered(species, Window.get(this).getWorld(), username) ? EnumDiscoveryState.DISCOVERED : EnumDiscoveryState.UNDISCOVERED);
}
if (Window.get(this) instanceof WindowAbstractDatabase && ((WindowAbstractDatabase) Window.get(this)).isMaster()) {
state = EnumDiscoveryState.SHOW;
}
this.discovered = state;
this.addAttribute(Attribute.MOUSE_OVER);
}
use of forestry.api.genetics.IIndividual in project Binnie by ForestryMC.
the class ManagerGenetics method analyse.
public static ItemStack analyse(ItemStack stack, World world, GameProfile username) {
if (!stack.isEmpty()) {
ItemStack conv = Binnie.GENETICS.getConversionStack(stack).copy();
if (!conv.isEmpty()) {
conv.setCount(stack.getCount());
stack = conv;
}
ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(stack);
if (root != null) {
final IIndividual ind = root.getMember(stack);
ind.analyze();
IBreedingTracker breedingTracker = ind.getGenome().getSpeciesRoot().getBreedingTracker(world, username);
breedingTracker.registerBirth(ind);
final NBTTagCompound nbttagcompound = new NBTTagCompound();
ind.writeToNBT(nbttagcompound);
stack.setTagCompound(nbttagcompound);
return stack;
}
if (stack.getItem() instanceof IItemAnalysable) {
return ((IItemAnalysable) stack.getItem()).analyse(stack);
}
}
return stack;
}
use of forestry.api.genetics.IIndividual in project Binnie by ForestryMC.
the class InoculatorRecipeMaker method create.
public static List<InoculatorRecipeWrapper> create() {
List<InoculatorRecipeWrapper> recipes = new ArrayList<>();
for (IBreedingSystem system : Binnie.GENETICS.getActiveSystems()) {
ISpeciesRoot root = system.getSpeciesRoot();
IChromosomeType speciesChromosomeType = root.getSpeciesChromosomeType();
IAllele[] defaultTemplate = root.getDefaultTemplate();
IIndividual individual = root.templateAsIndividual(defaultTemplate);
for (ISpeciesType speciesType : system.getActiveTypes()) {
if (system.isDNAManipulable(speciesType)) {
ItemStack memberStack = root.getMemberStack(individual, speciesType);
memberStack.setItemDamage(OreDictionary.WILDCARD_VALUE);
IAllele species = defaultTemplate[speciesChromosomeType.ordinal()];
ItemStack serum = ItemSerum.create(new Gene(species, speciesChromosomeType, root));
// set fully charged
serum.setItemDamage(0);
recipes.add(new InoculatorRecipeWrapper(serum, memberStack));
recipes.add(new SplicerRecipeWrapper(serum, memberStack));
ItemStack serumArray = ItemSerumArray.create(new Gene(species, speciesChromosomeType, root));
// set fully charged
serumArray.setItemDamage(0);
for (IChromosomeType chromosomeType : root.getKaryotype()) {
if (chromosomeType != speciesChromosomeType) {
IAllele allele = defaultTemplate[chromosomeType.ordinal()];
Engineering.addGene(serumArray, new Gene(allele, chromosomeType, root));
}
}
recipes.add(new InoculatorRecipeWrapper(serumArray, memberStack));
recipes.add(new SplicerRecipeWrapper(serumArray, memberStack));
}
}
}
return recipes;
}
use of forestry.api.genetics.IIndividual in project Binnie by ForestryMC.
the class IsolatorRecipeMaker method create.
public static List<IsolatorRecipeWrapper> create() {
List<IsolatorRecipeWrapper> recipes = new ArrayList<>();
Collection<ISpeciesRoot> roots = AlleleManager.alleleRegistry.getSpeciesRoot().values();
for (ISpeciesRoot root : roots) {
ISpeciesType[] speciesTypes = root.getIconType().getClass().getEnumConstants();
IChromosomeType speciesChromosomeType = root.getSpeciesChromosomeType();
IAllele[] defaultTemplate = root.getDefaultTemplate();
IIndividual individual = root.templateAsIndividual(defaultTemplate);
for (ISpeciesType speciesType : speciesTypes) {
ItemStack memberStack = root.getMemberStack(individual, speciesType);
memberStack.setItemDamage(OreDictionary.WILDCARD_VALUE);
IAllele species = defaultTemplate[speciesChromosomeType.ordinal()];
ItemStack filledSequence = ItemSequence.create(new Gene(species, speciesChromosomeType, root), false);
IsolatorRecipeWrapper recipeWrapper = new IsolatorRecipeWrapper(memberStack, filledSequence);
recipes.add(recipeWrapper);
}
}
return recipes;
}
Aggregations