use of com.minecolonies.api.research.ILocalResearchTree in project AdvancedPeripherals by Seniorendi.
the class MineColonies method getResearch.
/**
* Returns a map with all possible researches
*
* @param branch The branch, there are only a few branches
* @param researches The primary researches of the branch
* @param colony The colony
* @return a map with all possible researches
*/
public static List<Object> getResearch(ResourceLocation branch, List<ResourceLocation> researches, IColony colony) {
List<Object> result = new ArrayList<>();
if (researches != null) {
for (ResourceLocation researchName : researches) {
// All global possible researches
IGlobalResearchTree globalTree = IGlobalResearchTree.getInstance();
// The research tree of the colony
ILocalResearchTree colonyTree = colony.getResearchManager().getResearchTree();
IGlobalResearch research = globalTree.getResearch(branch, researchName);
if (research == null)
continue;
ILocalResearch colonyResearch = colonyTree.getResearch(branch, researchName);
List<String> effects = new ArrayList<>();
for (IResearchEffect<?> researchEffect : research.getEffects()) effects.add(researchEffect.getDesc().toString());
Map<String, Object> map = new HashMap<>();
map.put("id", researchName.toString());
map.put("name", research.getName().getString());
map.put("researchEffects", effects);
map.put("status", colonyResearch == null ? ResearchState.NOT_STARTED.toString() : colonyResearch.getState());
List<Object> childrenResearch = getResearch(branch, research.getChildren(), colony);
if (!childrenResearch.isEmpty())
map.put("children", childrenResearch);
result.add(map);
}
}
return result;
}
Aggregations