use of com.minecolonies.api.research.ILocalResearch in project minecolonies by ldtteam.
the class BuildingUniversity method onColonyTick.
@Override
public void onColonyTick(@NotNull final IColony colony) {
super.onColonyTick(colony);
final List<ILocalResearch> inProgress = colony.getResearchManager().getResearchTree().getResearchInProgress();
final WorkerBuildingModule module = getModuleMatching(WorkerBuildingModule.class, m -> m.getJobEntry() == ModJobs.researcher);
int i = 1;
for (final ILocalResearch research : inProgress) {
if (i > module.getAssignedCitizen().size()) {
return;
}
for (final ICitizenData data : getAllAssignedCitizen()) {
data.getCitizenSkillHandler().addXpToSkill(module.getSecondarySkill(), 25.0, data);
}
if (colony.getResearchManager().getResearchTree().getResearch(research.getBranch(), research.getId()).research(colony.getResearchManager().getResearchEffects(), colony.getResearchManager().getResearchTree())) {
onSuccess(research);
}
i++;
}
}
use of com.minecolonies.api.research.ILocalResearch in project minecolonies by ldtteam.
the class LocalResearchFactory method deserialize.
@NotNull
@Override
public ILocalResearch deserialize(@NotNull final IFactoryController controller, @NotNull final CompoundNBT nbt) {
final int state = nbt.getInt(TAG_STATE);
final ResourceLocation id = new ResourceLocation(nbt.getString(TAG_ID));
final ResourceLocation branch = new ResourceLocation(nbt.getString(TAG_BRANCH));
final int depth = nbt.getInt(TAG_RESEARCH_LVL);
final int progress = nbt.getInt(TAG_PROGRESS);
final ILocalResearch research = getNewInstance(id, branch, depth);
research.setState(ResearchState.values()[state]);
research.setProgress(progress);
return research;
}
use of com.minecolonies.api.research.ILocalResearch in project minecolonies by ldtteam.
the class LocalResearchFactory method deserialize.
@Override
public ILocalResearch deserialize(IFactoryController controller, PacketBuffer buffer) throws Throwable {
final int state = buffer.readInt();
final ResourceLocation id = buffer.readResourceLocation();
final ResourceLocation branch = buffer.readResourceLocation();
final int progress = buffer.readInt();
final int depth = buffer.readInt();
final ILocalResearch research = getNewInstance(id, branch, depth);
research.setState(ResearchState.values()[state]);
research.setProgress(progress);
return research;
}
use of com.minecolonies.api.research.ILocalResearch 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