use of com.minecolonies.api.research.ILocalResearch in project minecolonies by Minecolonies.
the class EntityAIWorkResearcher method study.
/**
* The AI task for the student to study. For this he should walk between the different bookcase hit them once and then stand around for a while.
*
* @return the next IAIState.
*/
private IAIState study() {
final IColony colony = getOwnBuilding().getColony();
final List<ILocalResearch> inProgress = colony.getResearchManager().getResearchTree().getResearchInProgress();
if (!inProgress.isEmpty() && job.getCurrentMana() > 0) {
final ILocalResearch research = inProgress.get(worker.getRandom().nextInt(inProgress.size()));
if (colony.getResearchManager().getResearchTree().getResearch(research.getBranch(), research.getId()).research(colony.getResearchManager().getResearchEffects(), colony.getResearchManager().getResearchTree())) {
getOwnBuilding().onSuccess(research);
}
job.reduceCurrentMana();
}
if (studyPos == null) {
studyPos = getOwnBuilding().getRandomBookShelf();
}
if (walkToBlock(studyPos)) {
return getState();
}
worker.decreaseSaturationForContinuousAction();
worker.getCitizenData().getCitizenSkillHandler().addXpToSkill(getModuleForJob().getPrimarySkill(), XP_PER_STUDYPOS, worker.getCitizenData());
studyPos = null;
return getState();
}
use of com.minecolonies.api.research.ILocalResearch in project minecolonies by Minecolonies.
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 minecolonies by ldtteam.
the class EntityAIWorkResearcher method study.
/**
* The AI task for the student to study. For this he should walk between the different bookcase hit them once and then stand around for a while.
*
* @return the next IAIState.
*/
private IAIState study() {
final IColony colony = getOwnBuilding().getColony();
final List<ILocalResearch> inProgress = colony.getResearchManager().getResearchTree().getResearchInProgress();
if (!inProgress.isEmpty() && job.getCurrentMana() > 0) {
final ILocalResearch research = inProgress.get(worker.getRandom().nextInt(inProgress.size()));
if (colony.getResearchManager().getResearchTree().getResearch(research.getBranch(), research.getId()).research(colony.getResearchManager().getResearchEffects(), colony.getResearchManager().getResearchTree())) {
getOwnBuilding().onSuccess(research);
}
job.reduceCurrentMana();
}
if (studyPos == null) {
studyPos = getOwnBuilding().getRandomBookShelf();
}
if (walkToBlock(studyPos)) {
return getState();
}
worker.decreaseSaturationForContinuousAction();
worker.getCitizenData().getCitizenSkillHandler().addXpToSkill(getModuleForJob().getPrimarySkill(), XP_PER_STUDYPOS, worker.getCitizenData());
studyPos = null;
return getState();
}
use of com.minecolonies.api.research.ILocalResearch in project minecolonies by Minecolonies.
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 Minecolonies.
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++;
}
}
Aggregations