use of forestry.api.genetics.ISpeciesRoot in project ForestryMC by ForestryMC.
the class EventHandlerCore method syncBreedingTrackers.
private static void syncBreedingTrackers(EntityPlayer player) {
IAlleleRegistry alleleRegistry = AlleleManager.alleleRegistry;
Collection<ISpeciesRoot> speciesRoots = alleleRegistry.getSpeciesRoot().values();
for (ISpeciesRoot speciesRoot : speciesRoots) {
IBreedingTracker breedingTracker = speciesRoot.getBreedingTracker(player.getEntityWorld(), player.getGameProfile());
breedingTracker.synchToPlayer(player);
}
}
use of forestry.api.genetics.ISpeciesRoot 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.ISpeciesRoot in project ForestryMC by ForestryMC.
the class GuiElementFactory method createMutation.
public IGuiElementLayout createMutation(int x, int y, int width, int height, IMutation mutation, IAllele species, IBreedingTracker breedingTracker) {
if (breedingTracker.isDiscovered(mutation)) {
GuiElementPanel element = new GuiElementPanel(x, y, width, height);
ISpeciesRoot speciesRoot = mutation.getRoot();
int speciesIndex = speciesRoot.getSpeciesChromosomeType().ordinal();
ISpeciesPlugin plugin = mutation.getRoot().getSpeciesPlugin();
Map<String, ItemStack> iconStacks = plugin.getIndividualStacks();
ItemStack partner = iconStacks.get(mutation.getPartner(species).getUID());
IAllele resultAllele = mutation.getTemplate()[speciesIndex];
ItemStack result = iconStacks.get(resultAllele.getUID());
element.addElements(new GuiElementItemStack(0, 0, partner), new GuiElementItemStack(33, 0, result));
element.addElements(createProbabilityArrow(mutation, 18, 4, breedingTracker));
return element;
}
// Do not display secret undiscovered mutations.
if (mutation.isSecret()) {
return null;
}
return createUnknownMutationGroup(x, y, width, height, mutation, breedingTracker);
}
use of forestry.api.genetics.ISpeciesRoot in project ForestryMC by ForestryMC.
the class ItemInventoryAlyzer method analyzeSpecimen.
private void analyzeSpecimen(ItemStack specimen) {
if (specimen.isEmpty()) {
return;
}
ItemStack convertedSpecimen = GeneticsUtil.convertToGeneticEquivalent(specimen);
if (!ItemStack.areItemStacksEqual(specimen, convertedSpecimen)) {
setInventorySlotContents(SLOT_SPECIMEN, convertedSpecimen);
specimen = convertedSpecimen;
}
ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(specimen);
// No individual, abort
if (speciesRoot == null) {
return;
}
IIndividual individual = speciesRoot.getMember(specimen);
// Analyze if necessary
if (individual != null && !individual.isAnalyzed()) {
final boolean requiresEnergy = ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.APICULTURE));
if (requiresEnergy) {
// Requires energy
if (!isAlyzingFuel(getStackInSlot(SLOT_ENERGY))) {
return;
}
}
if (individual.analyze()) {
IBreedingTracker breedingTracker = speciesRoot.getBreedingTracker(player.world, player.getGameProfile());
breedingTracker.registerSpecies(individual.getGenome().getPrimary());
breedingTracker.registerSpecies(individual.getGenome().getSecondary());
NBTTagCompound nbttagcompound = new NBTTagCompound();
individual.writeToNBT(nbttagcompound);
specimen.setTagCompound(nbttagcompound);
if (requiresEnergy) {
// Decrease energy
decrStackSize(SLOT_ENERGY, 1);
}
}
}
setInventorySlotContents(SLOT_ANALYZE_1, specimen);
setInventorySlotContents(SLOT_SPECIMEN, ItemStack.EMPTY);
}
use of forestry.api.genetics.ISpeciesRoot in project ForestryMC by ForestryMC.
the class TileDatabase method analyzeSpecimen.
// Called by the container on the server side
public ItemStack analyzeSpecimen(int selectedDatabaseSlot) {
if (selectedDatabaseSlot < 0) {
return ItemStack.EMPTY;
}
ItemStack specimen = getStackInSlot(selectedDatabaseSlot);
if (specimen.isEmpty()) {
return ItemStack.EMPTY;
}
ItemStack convertedSpecimen = GeneticsUtil.convertToGeneticEquivalent(specimen);
if (!ItemStack.areItemStacksEqual(specimen, convertedSpecimen)) {
setInventorySlotContents(selectedDatabaseSlot, convertedSpecimen);
specimen = convertedSpecimen;
}
ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(specimen);
// No individual, abort
if (speciesRoot == null) {
return specimen;
}
IIndividual individual = speciesRoot.getMember(specimen);
// Analyze if necessary
if (individual != null && !individual.isAnalyzed()) {
final boolean requiresEnergy = ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.APICULTURE));
if (requiresEnergy) {
// Requires energy
if (!analyzerInventory.isAlyzingFuel(analyzerInventory.getStackInSlot(InventoryDatabaseAnalyzer.SLOT_ENERGY))) {
return specimen;
}
}
if (individual.analyze()) {
IBreedingTracker breedingTracker = speciesRoot.getBreedingTracker(world, ownerHandler.getOwner());
breedingTracker.registerSpecies(individual.getGenome().getPrimary());
breedingTracker.registerSpecies(individual.getGenome().getSecondary());
NBTTagCompound nbttagcompound = new NBTTagCompound();
individual.writeToNBT(nbttagcompound);
specimen.setTagCompound(nbttagcompound);
if (requiresEnergy) {
// Decrease energy
analyzerInventory.decrStackSize(InventoryDatabaseAnalyzer.SLOT_ENERGY, 1);
}
}
setInventorySlotContents(selectedDatabaseSlot, specimen);
}
return specimen;
}
Aggregations