use of com.minecolonies.api.colony.jobs.IJob in project minecolonies by ldtteam.
the class CitizenJobHandler method onJobChanged.
/**
* Defines job changes and state changes of the citizen.
*
* @param job the set job.
*/
@Override
public void onJobChanged(@Nullable final IJob<?> job) {
// Model
setModelDependingOnJob(job);
// AI Tasks
for (@NotNull final PrioritizedGoal task : new ArrayList<>(citizen.getTasks().availableGoals)) {
if (task.getGoal() instanceof AbstractAISkeleton) {
citizen.getTasks().removeGoal(task.getGoal());
}
}
citizen.getCitizenData().setIdleAtJob(false);
if (job != null) {
job.addWorkerAIToTaskList(citizen.getTasks());
if (citizen.getTicksExisted() > 0 && citizen.getCitizenColonyHandler().getWorkBuilding() != null && citizen.getDesiredActivity() == DesiredActivity.WORK) {
BlockPosUtil.tryMoveBaseCitizenEntityToXYZ(citizen, citizen.getCitizenColonyHandler().getWorkBuilding().getPosition());
}
// Calculate the number of guards for some advancements
if (job instanceof AbstractJobGuard) {
IColony colony = citizen.getCitizenColonyHandler().getColony();
int guards = ((int) colony.getCitizenManager().getCitizens().stream().filter(citizen -> citizen.getJob() instanceof AbstractJobGuard).count());
AdvancementUtils.TriggerAdvancementPlayersForColony(citizen.getCitizenColonyHandler().getColony(), player -> AdvancementTriggers.ARMY_POPULATION.trigger(player, guards));
}
job.initEntityValues(citizen);
}
}
use of com.minecolonies.api.colony.jobs.IJob in project minecolonies by Minecolonies.
the class CitizenJobHandler method onJobChanged.
/**
* Defines job changes and state changes of the citizen.
*
* @param job the set job.
*/
@Override
public void onJobChanged(@Nullable final IJob<?> job) {
// Model
setModelDependingOnJob(job);
// AI Tasks
for (@NotNull final PrioritizedGoal task : new ArrayList<>(citizen.getTasks().availableGoals)) {
if (task.getGoal() instanceof AbstractAISkeleton) {
citizen.getTasks().removeGoal(task.getGoal());
}
}
citizen.getCitizenData().setIdleAtJob(false);
if (job != null) {
job.addWorkerAIToTaskList(citizen.getTasks());
if (citizen.getTicksExisted() > 0 && citizen.getCitizenColonyHandler().getWorkBuilding() != null && citizen.getDesiredActivity() == DesiredActivity.WORK) {
BlockPosUtil.tryMoveBaseCitizenEntityToXYZ(citizen, citizen.getCitizenColonyHandler().getWorkBuilding().getPosition());
}
// Calculate the number of guards for some advancements
if (job instanceof AbstractJobGuard) {
IColony colony = citizen.getCitizenColonyHandler().getColony();
int guards = ((int) colony.getCitizenManager().getCitizens().stream().filter(citizen -> citizen.getJob() instanceof AbstractJobGuard).count());
AdvancementUtils.TriggerAdvancementPlayersForColony(citizen.getCitizenColonyHandler().getColony(), player -> AdvancementTriggers.ARMY_POPULATION.trigger(player, guards));
}
job.initEntityValues(citizen);
}
}
Aggregations