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().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 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 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;
}
use of com.minecolonies.coremod.colony.interactionhandling.StandardInteraction in project minecolonies by Minecolonies.
the class AbstractEntityAIRequestSmelter method craft.
@Override
protected IAIState craft() {
final FurnaceUserModule module = getOwnBuilding().getFirstModuleOccurance(FurnaceUserModule.class);
final List<ItemStack> possibleFuels = getAllowedFuel();
if (possibleFuels.isEmpty()) {
if (worker.getCitizenData() != null) {
worker.getCitizenData().triggerInteraction(new StandardInteraction(new TranslationTextComponent(FURNACE_USER_NO_FUEL), ChatPriority.BLOCKING));
}
return getState();
}
if (currentRecipeStorage != null) {
possibleFuels.removeIf(stack -> ItemStackUtils.compareItemStacksIgnoreStackSize(stack, currentRecipeStorage.getPrimaryOutput()));
// There is always only one input.
possibleFuels.removeIf(stack -> ItemStackUtils.compareItemStacksIgnoreStackSize(stack, currentRecipeStorage.getCleanedInput().get(0).getItemStack()));
}
if (walkToBuilding()) {
setDelay(STANDARD_DELAY);
return getState();
}
if (currentRecipeStorage != null && currentRequest == null) {
currentRequest = job.getCurrentTask();
}
if (currentRecipeStorage != null && currentRecipeStorage.getIntermediate() != Blocks.FURNACE) {
return super.craft();
}
if (module.getFurnaces().isEmpty()) {
if (worker.getCitizenData() != null) {
worker.getCitizenData().triggerInteraction(new StandardInteraction(new TranslationTextComponent(BAKER_HAS_NO_FURNACES_MESSAGE), ChatPriority.BLOCKING));
}
setDelay(STANDARD_DELAY);
return START_WORKING;
}
final BlockPos furnacePosWithUsedFuel = getPositionOfOvenToRetrieveFuelFrom();
if (furnacePosWithUsedFuel != null) {
walkTo = furnacePosWithUsedFuel;
worker.getCitizenStatusHandler().setLatestStatus(new TranslationTextComponent("com.minecolonies.coremod.status.retrieving"));
return RETRIEVING_USED_FUEL_FROM_FURNACE;
}
final BlockPos posOfOven = getPositionOfOvenToRetrieveFrom();
if (posOfOven != null) {
walkTo = posOfOven;
worker.getCitizenStatusHandler().setLatestStatus(new TranslationTextComponent("com.minecolonies.coremod.status.retrieving"));
return RETRIEVING_END_PRODUCT_FROM_FURNACE;
}
// Safety net, should get caught removing things from the furnace.
if (currentRequest != null && job.getMaxCraftingCount() > 0 && job.getCraftCounter() >= job.getMaxCraftingCount()) {
job.finishRequest(true);
currentRecipeStorage = null;
currentRequest = null;
resetValues();
return INVENTORY_FULL;
}
if (currentRequest != null && (currentRequest.getState() == RequestState.CANCELLED || currentRequest.getState() == RequestState.FAILED)) {
incrementActionsDone(getActionRewardForCraftingSuccess());
currentRecipeStorage = null;
currentRequest = null;
resetValues();
return START_WORKING;
}
return checkIfAbleToSmelt();
}
Aggregations