use of com.minecolonies.coremod.colony.interactionhandling.StandardInteraction in project minecolonies by ldtteam.
the class EntityAIQuarrier method startWorkingAtOwnBuilding.
// Miner wants to work but is not at building
@NotNull
private IAIState startWorkingAtOwnBuilding() {
worker.getCitizenData().setVisibleStatus(VisibleCitizenStatus.WORKING);
final IBuilding quarry = job.findQuarry();
if (quarry == null) {
walkToBuilding();
worker.getCitizenData().triggerInteraction(new StandardInteraction(new TranslationTextComponent(QUARRY_MINER_NO_QUARRY), ChatPriority.BLOCKING));
return IDLE;
}
if (quarry.getFirstModuleOccurance(QuarryModule.class).isFinished()) {
walkToBuilding();
worker.getCitizenData().triggerInteraction(new StandardInteraction(new TranslationTextComponent(QUARRY_MINER_FINISHED_QUARRY), ChatPriority.BLOCKING));
return IDLE;
}
if (walkToBlock(quarry.getPosition())) {
return getState();
}
// Miner is at building
return LOAD_STRUCTURE;
}
use of com.minecolonies.coremod.colony.interactionhandling.StandardInteraction in project minecolonies by ldtteam.
the class EntityAIQuarrier method checkIfCanceled.
@Override
protected boolean checkIfCanceled() {
if (job.findQuarry() == null) {
worker.getCitizenData().triggerInteraction(new StandardInteraction(new TranslationTextComponent(QUARRY_MINER_NO_QUARRY), ChatPriority.BLOCKING));
return true;
} else if (job.findQuarry().getFirstModuleOccurance(QuarryModule.class).isFinished()) {
worker.getCitizenData().triggerInteraction(new StandardInteraction(new TranslationTextComponent(QUARRY_MINER_FINISHED_QUARRY), ChatPriority.BLOCKING));
return true;
} else if (job.getWorkOrder() != null && !job.getWorkOrder().getSchematicLocation().equals(job.findQuarry().getPosition().below(2))) {
blockToMine = null;
job.complete();
getOwnBuilding().setProgressPos(null, null);
return true;
}
return super.checkIfCanceled();
}
use of com.minecolonies.coremod.colony.interactionhandling.StandardInteraction in project minecolonies by ldtteam.
the class EntityAIEatTask method hasFood.
/**
* Checks if the citizen has food in the inventory and makes a decision based on that.
*
* @return the next state to go to.
*/
private boolean hasFood() {
final int slot = InventoryUtils.findFirstSlotInProviderNotEmptyWith(citizen, stack -> CAN_EAT.test(stack) && canEat(citizen.getCitizenData(), stack));
if (slot != -1) {
foodSlot = slot;
return true;
}
final ICitizenData citizenData = citizen.getCitizenData();
if (InventoryUtils.hasItemInItemHandler(citizen.getInventoryCitizen(), ISCOOKABLE)) {
citizenData.triggerInteraction(new StandardInteraction(new TranslationTextComponent(RAW_FOOD), ChatPriority.PENDING));
} else if (InventoryUtils.hasItemInItemHandler(citizen.getInventoryCitizen(), stack -> CAN_EAT.test(stack) && !canEat(citizenData, stack))) {
if (citizenData.isChild()) {
citizenData.triggerInteraction(new StandardInteraction(new TranslationTextComponent(BETTER_FOOD_CHILDREN), ChatPriority.BLOCKING));
} else {
citizenData.triggerInteraction(new StandardInteraction(new TranslationTextComponent(BETTER_FOOD), ChatPriority.BLOCKING));
}
}
return false;
}
use of com.minecolonies.coremod.colony.interactionhandling.StandardInteraction in project minecolonies by ldtteam.
the class EntityAIEatTask method searchRestaurant.
/**
* Search for a placeToPath within the colony of the citizen.
*
* @return the next state to go to.
*/
private EatingState searchRestaurant() {
final ICitizenData citizenData = citizen.getCitizenData();
final IColony colony = citizenData.getColony();
if (citizenData.getWorkBuilding() != null) {
restaurantPos = colony.getBuildingManager().getBestBuilding(citizenData.getWorkBuilding().getPosition(), BuildingCook.class);
} else if (citizenData.getHomeBuilding() != null) {
restaurantPos = colony.getBuildingManager().getBestBuilding(citizenData.getHomeBuilding().getPosition(), BuildingCook.class);
} else {
restaurantPos = colony.getBuildingManager().getBestBuilding(citizen, BuildingCook.class);
}
final IJob<?> job = citizen.getCitizenJobHandler().getColonyJob();
if (job != null && citizenData.isWorking()) {
citizenData.setWorking(false);
}
if (restaurantPos == null) {
citizenData.triggerInteraction(new StandardInteraction(new TranslationTextComponent(NO_RESTAURANT), ChatPriority.BLOCKING));
return CHECK_FOR_FOOD;
}
return GO_TO_RESTAURANT;
}
use of com.minecolonies.coremod.colony.interactionhandling.StandardInteraction in project minecolonies by ldtteam.
the class EntityAISickTask method searchHospital.
/**
* Search for a placeToPath within the colony of the citizen.
*
* @return the next state to go to.
*/
private DiseaseState searchHospital() {
final IColony colony = citizenData.getColony();
placeToPath = colony.getBuildingManager().getBestBuilding(citizen, BuildingHospital.class);
if (placeToPath == null) {
final String id = citizen.getCitizenDiseaseHandler().getDisease();
if (id.isEmpty()) {
return IDLE;
}
final Disease disease = IColonyManager.getInstance().getCompatibilityManager().getDisease(id);
citizenData.triggerInteraction(new StandardInteraction(new TranslationTextComponent(NO_HOSPITAL, disease.getName(), disease.getCureString()), new TranslationTextComponent(NO_HOSPITAL), ChatPriority.BLOCKING));
return WANDER;
} else if (!citizen.getCitizenDiseaseHandler().getDisease().isEmpty()) {
final Disease disease = IColonyManager.getInstance().getCompatibilityManager().getDisease(citizen.getCitizenDiseaseHandler().getDisease());
citizenData.triggerInteraction(new StandardInteraction(new TranslationTextComponent(WAITING_FOR_CURE, disease.getName(), disease.getCureString()), new TranslationTextComponent(WAITING_FOR_CURE), ChatPriority.BLOCKING));
}
return GO_TO_HOSPITAL;
}
Aggregations