use of com.minecolonies.coremod.entity.ai.basic.AbstractAISkeleton in project minecolonies by Minecolonies.
the class CitizenData method setWorkBuilding.
/**
* Sets the work building of a citizen.
*
* @param building work building.
*/
public void setWorkBuilding(@Nullable final AbstractBuildingWorker building) {
if (workBuilding != null && building != null && workBuilding != building) {
throw new IllegalStateException("CitizenData.setWorkBuilding() - already assigned a work building when setting a new work building");
} else if (workBuilding != building) {
workBuilding = building;
if (workBuilding != null) {
// We have a place to work, do we have the assigned Job?
if (job == null) {
// No job, create one!
setJob(workBuilding.createJob(this));
colony.getWorkManager().clearWorkForCitizen(this);
}
} else if (job != null) {
final EntityCitizen citizen = getCitizenEntity();
if (citizen != null) {
citizen.tasks.removeTask(citizen.tasks.taskEntries.stream().filter(task -> task.action instanceof AbstractAISkeleton).findFirst().orElse(null).action);
}
// No place of employment, get rid of our job
setJob(null);
colony.getWorkManager().clearWorkForCitizen(this);
}
markDirty();
}
}
Aggregations