use of com.minecolonies.coremod.entity.ai.minimal.EntityAISickTask.DiseaseState in project minecolonies by ldtteam.
the class EntityAISickTask method waitForCure.
/**
* Stay in bed while waiting to be cured.
*
* @return the next state to go to.
*/
private DiseaseState waitForCure() {
final IColony colony = citizenData.getColony();
placeToPath = colony.getBuildingManager().getBestBuilding(citizen, BuildingHospital.class);
if (placeToPath == null) {
return SEARCH_HOSPITAL;
}
final DiseaseState state = checkForCure();
if (state == APPLY_CURE) {
return APPLY_CURE;
} else if (state == IDLE) {
reset();
return IDLE;
}
if (citizen.getRandom().nextInt(10000) < CHANCE_FOR_RANDOM_CURE) {
cure();
return IDLE;
}
if (citizen.getCitizenSleepHandler().isAsleep()) {
final BlockPos hospital = colony.getBuildingManager().getBestBuilding(citizen, BuildingHospital.class);
if (hospital != null) {
final IBuilding building = colony.getBuildingManager().getBuilding(hospital);
if (building instanceof BuildingHospital && !((BuildingHospital) building).getBedList().contains(citizen.getCitizenSleepHandler().getBedLocation())) {
citizen.getCitizenSleepHandler().onWakeUp();
}
}
}
if (!citizen.getCitizenSleepHandler().isAsleep() && BlockPosUtil.getDistance2D(placeToPath, citizen.blockPosition()) > MINIMUM_DISTANCE_TO_HOSPITAL) {
return GO_TO_HOSPITAL;
}
if (!citizen.getCitizenSleepHandler().isAsleep()) {
return FIND_EMPTY_BED;
}
return WAIT_FOR_CURE;
}
use of com.minecolonies.coremod.entity.ai.minimal.EntityAISickTask.DiseaseState in project minecolonies by Minecolonies.
the class EntityAISickTask method waitForCure.
/**
* Stay in bed while waiting to be cured.
*
* @return the next state to go to.
*/
private DiseaseState waitForCure() {
final IColony colony = citizenData.getColony();
placeToPath = colony.getBuildingManager().getBestBuilding(citizen, BuildingHospital.class);
if (placeToPath == null) {
return SEARCH_HOSPITAL;
}
final DiseaseState state = checkForCure();
if (state == APPLY_CURE) {
return APPLY_CURE;
} else if (state == IDLE) {
reset();
return IDLE;
}
if (citizen.getRandom().nextInt(10000) < CHANCE_FOR_RANDOM_CURE) {
cure();
return IDLE;
}
if (citizen.getCitizenSleepHandler().isAsleep()) {
final BlockPos hospital = colony.getBuildingManager().getBestBuilding(citizen, BuildingHospital.class);
if (hospital != null) {
final IBuilding building = colony.getBuildingManager().getBuilding(hospital);
if (building instanceof BuildingHospital && !((BuildingHospital) building).getBedList().contains(citizen.getCitizenSleepHandler().getBedLocation())) {
citizen.getCitizenSleepHandler().onWakeUp();
}
}
}
if (!citizen.getCitizenSleepHandler().isAsleep() && BlockPosUtil.getDistance2D(placeToPath, citizen.blockPosition()) > MINIMUM_DISTANCE_TO_HOSPITAL) {
return GO_TO_HOSPITAL;
}
if (!citizen.getCitizenSleepHandler().isAsleep()) {
return FIND_EMPTY_BED;
}
return WAIT_FOR_CURE;
}
Aggregations