@Override public void calculateMutations(ISpeciesRoot speciesRoot) { this.allMutations = new ArrayList<>(); List<? extends IMutation> speciesMutations = speciesRoot.getMutations(false); if (!speciesMutations.isEmpty()) { final Set<IMutation> mutations = new LinkedHashSet<>(speciesMutations); for (final IMutation mutation : mutations) { this.allMutations.add(mutation); final Set<IAlleleSpecies> participatingSpecies = new LinkedHashSet<>(); participatingSpecies.add(mutation.getAllele0()); participatingSpecies.add(mutation.getAllele1()); for (final IAlleleSpecies species : participatingSpecies) { this.allFurtherMutations.put(species, mutation); if (this.allActiveSpecies.contains(species)) { this.furtherMutations.put(species, mutation); } } IAllele[] template = mutation.getTemplate(); IAlleleSpecies speciesAllele = (IAlleleSpecies) template[0]; this.allResultantMutations.put(speciesAllele, mutation); this.resultantMutations.put(speciesAllele, mutation); } } }
@ModuleContainerObjectMethod.Inject( module = IntegrationForestry.analyzerMod, worldThread = false, modId = Constants.MOD_ID, doc = "function(root:string):table -- Get a list of all mutations in the given species root" ) public static Object[] getMutationsList(IContext<IModuleContainer> context, Object[] args) throws LuaException { String uid = ArgumentHelper.getString(args, 0); ISpeciesRoot root = getSpeciesRoot(uid); LuaList<Map<Object, Object>> mutations = root.getMutations(false).stream() .filter(s -> !s.isSecret()) .map(m -> context.makePartialChild(m).getMeta()) .collect(LuaList.toLuaList()); return new Object[]{mutations.asMap()}; } }