use of forestry.api.genetics.IGenome in project Binnie by ForestryMC.
the class ToleranceSystem method canAlter.
public boolean canAlter(final ItemStack stack, final ItemStack acclim) {
final IIndividual member = AlleleManager.alleleRegistry.getIndividual(stack);
final IGenome genome = member.getGenome();
final IAlleleTolerance tolAllele = (IAlleleTolerance) genome.getActiveAllele(this.chromosomeType);
final Tolerance tol = Tolerance.get(tolAllele.getValue());
final float effect = this.type.getEffect(acclim);
return (effect > 0.0f && tol.getBounds()[1] < 5) || (effect < 0.0f && tol.getBounds()[0] > -5);
}
use of forestry.api.genetics.IGenome in project EnderIO by SleepyTrousers.
the class SpeciesItemFilter method setItem.
@Nonnull
private ItemStack setItem(int slot, @Nonnull ItemStack itemStack) {
if (slot < 0 || slot >= items.size()) {
return ItemStack.EMPTY;
}
ItemStack prevStack = items.get(slot);
if (!prevStack.isEmpty()) {
this.primarySpeciesUids[slot] = null;
this.secondarySpeciesUids[slot] = null;
}
items.set(slot, itemStack);
ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(itemStack);
if (speciesRoot != null) {
IIndividual member = speciesRoot.getMember(itemStack);
if (member != null) {
IGenome genome = member.getGenome();
primarySpeciesUids[slot] = genome.getPrimary().getUID();
secondarySpeciesUids[slot] = genome.getSecondary().getUID();
}
}
return prevStack;
}
use of forestry.api.genetics.IGenome in project ForestryMC by ForestryMC.
the class Genome method getChromosome.
private static IChromosome getChromosome(ItemStack itemStack, IChromosomeType chromosomeType, ISpeciesRoot speciesRoot) {
NBTTagCompound nbtTagCompound = itemStack.getTagCompound();
if (nbtTagCompound == null) {
nbtTagCompound = new NBTTagCompound();
itemStack.setTagCompound(nbtTagCompound);
}
NBTTagCompound genomeNbt = nbtTagCompound.getCompoundTag("Genome");
if (genomeNbt.hasNoTags()) {
Log.error("Got a genetic item with no genome, setting it to a default value.");
genomeNbt = new NBTTagCompound();
IAllele[] defaultTemplate = speciesRoot.getDefaultTemplate();
IGenome genome = speciesRoot.templateAsGenome(defaultTemplate);
genome.writeToNBT(genomeNbt);
nbtTagCompound.setTag("Genome", genomeNbt);
}
IChromosome[] chromosomes = getChromosomes(genomeNbt, speciesRoot);
return chromosomes[chromosomeType.ordinal()];
}
use of forestry.api.genetics.IGenome in project ForestryMC by ForestryMC.
the class GuiAlyzer method drawAnalyticsPageMutations.
public void drawAnalyticsPageMutations(IIndividual individual) {
textLayout.startPage(COLUMN_0, COLUMN_1, COLUMN_2);
textLayout.drawLine(Translator.translateToLocal("for.gui.beealyzer.mutations") + ":", COLUMN_0);
textLayout.newLine();
RenderHelper.enableGUIStandardItemLighting();
IGenome genome = individual.getGenome();
ISpeciesRoot speciesRoot = genome.getSpeciesRoot();
IAlleleSpecies species = genome.getPrimary();
int columnWidth = 50;
int x = 0;
EntityPlayer player = Minecraft.getMinecraft().player;
IBreedingTracker breedingTracker = speciesRoot.getBreedingTracker(player.world, player.getGameProfile());
for (IMutation mutation : speciesRoot.getCombinations(species)) {
if (breedingTracker.isDiscovered(mutation)) {
drawMutationInfo(mutation, species, COLUMN_0 + x, breedingTracker);
} else {
// Do not display secret undiscovered mutations.
if (mutation.isSecret()) {
continue;
}
drawUnknownMutation(mutation, COLUMN_0 + x, breedingTracker);
}
x += columnWidth;
if (x >= columnWidth * 4) {
x = 0;
textLayout.newLine(16);
}
}
textLayout.endPage();
}
use of forestry.api.genetics.IGenome in project ForestryMC by ForestryMC.
the class SpeciesWidget method handleMouseClick.
@Override
public void handleMouseClick(int mouseX, int mouseY, int mouseButton) {
ItemStack stack = gui.mc.player.inventory.getItemStack();
if (!stack.isEmpty()) {
IIndividual individual = AlleleManager.alleleRegistry.getIndividual(stack);
if (individual != null) {
IGenome genome = individual.getGenome();
onSelect(mouseButton == 0 ? genome.getPrimary() : genome.getSecondary());
return;
}
}
if (mouseButton == 1) {
onSelect(null);
} else {
SoundUtil.playButtonClick();
gui.onModuleClick(this);
}
}
Aggregations