@Override public NonNullList<ItemStack> getResearchBounty(World world, GameProfile researcher, IIndividual individual, int bountyLevel) { if (world.rand.nextFloat() < bountyLevel / 16.0f) { List<? extends IMutation> allMutations = getRoot().getCombinations(this); if (!allMutations.isEmpty()) { List<IMutation> unresearchedMutations = new ArrayList<>(); IBreedingTracker tracker = individual.getGenome().getSpeciesRoot().getBreedingTracker(world, researcher); for (IMutation mutation : allMutations) { if (!tracker.isResearched(mutation)) { unresearchedMutations.add(mutation); } } IMutation chosenMutation; if (!unresearchedMutations.isEmpty()) { chosenMutation = unresearchedMutations.get(world.rand.nextInt(unresearchedMutations.size())); } else { chosenMutation = allMutations.get(world.rand.nextInt(allMutations.size())); } ItemStack researchNote = AlleleManager.alleleRegistry.getMutationNoteStack(researcher, chosenMutation); NonNullList<ItemStack> bounty = NonNullList.create(); bounty.add(researchNote); return bounty; } } return NonNullList.create(); }
@Override public void registerPickup(IIndividual individual) { ISpeciesRoot speciesRoot = individual.getGenome().getPrimary().getRoot(); if (!speciesRoot.getUID().equals(speciesRootUID())) { return; } if (!individual.isPureBred(EnumBeeChromosome.SPECIES)) { return; } if (!speciesRoot.getCombinations(individual.getGenome().getPrimary()).isEmpty()) { return; } registerSpecies(individual.getGenome().getPrimary()); }
@Nullable private static IMutation getEncodedMutation(ISpeciesRoot root, NBTTagCompound compound) { IAllele allele0 = AlleleManager.alleleRegistry.getAllele(compound.getString("AL0")); IAllele allele1 = AlleleManager.alleleRegistry.getAllele(compound.getString("AL1")); if (allele0 == null || allele1 == null) { return null; } IAllele result = null; if (compound.hasKey("RST")) { result = AlleleManager.alleleRegistry.getAllele(compound.getString("RST")); } IMutation encoded = null; for (IMutation mutation : root.getCombinations(allele0)) { if (mutation.isPartner(allele1)) { if (result == null || mutation.getTemplate()[0].getUID().equals(result.getUID())) { encoded = mutation; break; } } } return encoded; }
@Override public void createElements(IDatabaseElement container, IIndividual individual, ItemStack itemStack) { IGenome genome = individual.getGenome(); ISpeciesRoot speciesRoot = genome.getSpeciesRoot(); IAlleleSpecies species = genome.getPrimary(); EntityPlayer player = Minecraft.getMinecraft().player; IBreedingTracker breedingTracker = speciesRoot.getBreedingTracker(player.world, player.getGameProfile()); IElementLayoutHelper groupHelper = container.layoutHelper((x, y) -> GuiElementFactory.INSTANCE.createHorizontal(x + 1, y, 16), 100, 0); Collection<? extends IMutation> mutations = getValidMutations(speciesRoot.getCombinations(species)); if (!mutations.isEmpty()) { container.label(Translator.translateToLocal("for.gui.database.mutations.further"), GuiElementAlignment.TOP_CENTER, GuiConstants.UNDERLINED_STYLE); mutations.forEach(mutation -> groupHelper.add(GuiElementFactory.INSTANCE.createMutation(0, 0, 50, 16, mutation, species, breedingTracker))); groupHelper.finish(true); } mutations = getValidMutations(speciesRoot.getResultantMutations(species)); if (mutations.isEmpty()) { return; } container.label(Translator.translateToLocal("for.gui.database.mutations.resultant"), GuiElementAlignment.TOP_CENTER, GuiConstants.UNDERLINED_STYLE); mutations.forEach(mutation -> groupHelper.add(GuiElementFactory.INSTANCE.createMutationResultant(0, 0, 50, 16, mutation, breedingTracker))); groupHelper.finish(true); }
private void displaySpeciesInformation(boolean analyzed, IAlleleSpecies species, ItemStack iconStack, int x) { if (!analyzed) { textLayout.drawLine(Translator.translateToLocal("for.gui.unknown"), x); return; } textLayout.drawLine(species.getAlleleName(), x); GuiUtil.drawItemStack(this, iconStack, guiLeft + x + 69, guiTop + textLayout.getLineY() - 2); textLayout.newLine(); // Viable Combinations int columnWidth = 16; int column = 10; for (IMutation combination : speciesRoot.getCombinations(species)) { if (combination.isSecret()) { continue; } if (breedingTracker.isDiscovered(combination)) { drawMutationIcon(combination, species, column); } else { drawUnknownIcon(combination, column); } column += columnWidth; if (column > 75) { column = 10; textLayout.newLine(18); } } textLayout.newLine(); textLayout.newLine(); }
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(); }