Search in sources :

Example 1 with ILocalResearch

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();
}
Also used : ILocalResearch(com.minecolonies.api.research.ILocalResearch) IColony(com.minecolonies.api.colony.IColony)

Example 2 with ILocalResearch

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;
}
Also used : ILocalResearch(com.minecolonies.api.research.ILocalResearch) ResourceLocation(net.minecraft.util.ResourceLocation)

Example 3 with ILocalResearch

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();
}
Also used : ILocalResearch(com.minecolonies.api.research.ILocalResearch) IColony(com.minecolonies.api.colony.IColony)

Example 4 with ILocalResearch

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;
}
Also used : ILocalResearch(com.minecolonies.api.research.ILocalResearch) ResourceLocation(net.minecraft.util.ResourceLocation) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with ILocalResearch

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++;
    }
}
Also used : ILocalResearch(com.minecolonies.api.research.ILocalResearch) WorkerBuildingModule(com.minecolonies.coremod.colony.buildings.modules.WorkerBuildingModule) ICitizenData(com.minecolonies.api.colony.ICitizenData)

Aggregations

ILocalResearch (com.minecolonies.api.research.ILocalResearch)8 ResourceLocation (net.minecraft.util.ResourceLocation)4 ICitizenData (com.minecolonies.api.colony.ICitizenData)2 IColony (com.minecolonies.api.colony.IColony)2 WorkerBuildingModule (com.minecolonies.coremod.colony.buildings.modules.WorkerBuildingModule)2 NotNull (org.jetbrains.annotations.NotNull)2