use of com.minecolonies.coremod.colony.interactionhandling.StandardInteraction in project minecolonies by Minecolonies.
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().getLocation().equals(job.findQuarry().getPosition().below(2))) {
blockToMine = null;
job.complete();
building.setProgressPos(null, null);
return true;
}
return super.checkIfCanceled();
}
use of com.minecolonies.coremod.colony.interactionhandling.StandardInteraction in project minecolonies by Minecolonies.
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 Minecolonies.
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 Minecolonies.
the class EntityAIWorkCook method getSmeltAbleClass.
@Override
protected IRequestable getSmeltAbleClass() {
final List<ItemStorage> blockedItems = new ArrayList<>(building.getModuleMatching(ItemListModule.class, m -> m.getId().equals(FOOD_EXCLUSION_LIST)).getList());
for (final Map.Entry<ItemStorage, Integer> content : building.getTileEntity().getAllContent().entrySet()) {
if (content.getValue() > content.getKey().getItemStack().getMaxStackSize() * 6 && ItemStackUtils.CAN_EAT.test(content.getKey().getItemStack())) {
blockedItems.add(content.getKey());
}
}
blockedItems.removeIf(item -> item.getItem().getFoodProperties() == null || item.getItem().getFoodProperties().getNutrition() < building.getBuildingLevel() - 1);
if (!blockedItems.isEmpty()) {
if (IColonyManager.getInstance().getCompatibilityManager().getEdibles(building.getBuildingLevel() - 1).size() <= blockedItems.size()) {
if (worker.getCitizenData() != null) {
worker.getCitizenData().triggerInteraction(new StandardInteraction(new TranslationTextComponent(FURNACE_USER_NO_FOOD), ChatPriority.BLOCKING));
return null;
}
}
return new Food(STACKSIZE, blockedItems, building.getBuildingLevel() - 1);
}
return new Food(STACKSIZE, building.getBuildingLevel() - 1);
}
use of com.minecolonies.coremod.colony.interactionhandling.StandardInteraction in project minecolonies by Minecolonies.
the class EntityCitizen method determineDesiredActivity.
/**
* Determines the desired activity
*/
private boolean determineDesiredActivity() {
if (citizenJobHandler.getColonyJob() instanceof AbstractJobGuard) {
desiredActivity = DesiredActivity.WORK;
return false;
}
if (getCitizenColonyHandler().getColony().getRaiderManager().isRaided()) {
citizenData.triggerInteraction(new StandardInteraction(new TranslationTextComponent(COM_MINECOLONIES_COREMOD_ENTITY_CITIZEN_RAID), ChatPriority.IMPORTANT));
setVisibleStatusIfNone(RAIDED);
desiredActivity = DesiredActivity.SLEEP;
return false;
}
// Sleeping
if (!WorldUtil.isPastTime(CompatibilityUtils.getWorldFromCitizen(this), NIGHT - 2000)) {
if (desiredActivity == DesiredActivity.SLEEP) {
setVisibleStatusIfNone(SLEEP);
return false;
}
if (citizenSleepHandler.shouldGoSleep()) {
citizenData.onGoSleep();
citizenData.decreaseSaturation(citizenColonyHandler.getPerBuildingFoodCost() * 2);
citizenData.markDirty();
citizenStatusHandler.setLatestStatus(new TranslationTextComponent("com.minecolonies.coremod.status.sleeping"));
desiredActivity = DesiredActivity.SLEEP;
return false;
}
}
// Mourning
if (citizenData.getCitizenMournHandler().isMourning() && citizenData.getCitizenMournHandler().shouldMourn()) {
if (!getCitizenColonyHandler().getColony().getRaiderManager().isRaided()) {
citizenData.triggerInteraction(new StandardInteraction(new TranslationTextComponent(COM_MINECOLONIES_COREMOD_ENTITY_CITIZEN_MOURNING, citizenData.getCitizenMournHandler().getDeceasedCitizens().iterator().next()), new TranslationTextComponent(COM_MINECOLONIES_COREMOD_ENTITY_CITIZEN_MOURNING), ChatPriority.IMPORTANT));
}
setVisibleStatusIfNone(MOURNING);
desiredActivity = DesiredActivity.MOURN;
return false;
}
if (citizenSleepHandler.isAsleep() && !citizenDiseaseHandler.isSick()) {
citizenSleepHandler.onWakeUp();
}
// Raining
if (CompatibilityUtils.getWorldFromCitizen(this).isRaining() && !shouldWorkWhileRaining() && !WorldUtil.isNetherType(level)) {
citizenStatusHandler.setLatestStatus(new TranslationTextComponent("com.minecolonies.coremod.status.waiting"), new TranslationTextComponent("com.minecolonies.coremod.status.rainStop"));
setVisibleStatusIfNone(BAD_WEATHER);
if (!citizenData.getColony().getRaiderManager().isRaided() && !citizenData.getCitizenMournHandler().isMourning()) {
citizenData.triggerInteraction(new StandardInteraction(new TranslationTextComponent(COM_MINECOLONIES_COREMOD_ENTITY_CITIZEN_RAINING), ChatPriority.HIDDEN));
}
desiredActivity = DesiredActivity.SLEEP;
return false;
}
if (isBaby() && getCitizenJobHandler().getColonyJob() instanceof JobPupil && level.getDayTime() % 24000 > NOON) {
setVisibleStatusIfNone(HOUSE);
desiredActivity = DesiredActivity.IDLE;
return false;
}
if (getCitizenJobHandler().getColonyJob() != null) {
desiredActivity = DesiredActivity.WORK;
return false;
}
setVisibleStatusIfNone(HOUSE);
desiredActivity = DesiredActivity.IDLE;
return false;
}
Aggregations