Search in sources :

Example 11 with StandardInteraction

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;
}
Also used : IBuilding(com.minecolonies.api.colony.buildings.IBuilding) StandardInteraction(com.minecolonies.coremod.colony.interactionhandling.StandardInteraction) QuarryModule(com.minecolonies.coremod.colony.buildings.modules.QuarryModule) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) NotNull(org.jetbrains.annotations.NotNull)

Example 12 with StandardInteraction

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();
}
Also used : StandardInteraction(com.minecolonies.coremod.colony.interactionhandling.StandardInteraction) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent)

Example 13 with StandardInteraction

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;
}
Also used : SittingEntity(com.minecolonies.coremod.entity.SittingEntity) SATURATION(com.minecolonies.api.research.util.ResearchConstants.SATURATION) BuildingCook(com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingCook) TickingTransition(com.minecolonies.api.entity.ai.statemachine.tickratestatemachine.TickingTransition) ICitizenData(com.minecolonies.api.colony.ICitizenData) ItemParticleEffectMessage(com.minecolonies.coremod.network.messages.client.ItemParticleEffectMessage) AdvancementUtils(com.minecolonies.coremod.util.AdvancementUtils) LOW_SATURATION(com.minecolonies.api.util.constant.CitizenConstants.LOW_SATURATION) SEEK_DOCTOR_HEALTH(com.minecolonies.coremod.entity.citizen.citizenhandlers.CitizenDiseaseHandler.SEEK_DOCTOR_HEALTH) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) Goal(net.minecraft.entity.ai.goal.Goal) CAN_EAT(com.minecolonies.api.util.ItemStackUtils.CAN_EAT) Hand(net.minecraft.util.Hand) Network(com.minecolonies.coremod.Network) Log(com.minecolonies.api.util.Log) CitizenConstants(com.minecolonies.api.util.constant.CitizenConstants) TICKS_SECOND(com.minecolonies.api.util.constant.Constants.TICKS_SECOND) EnumSet(java.util.EnumSet) ItemListModule(com.minecolonies.coremod.colony.buildings.modules.ItemListModule) TickRateStateMachine(com.minecolonies.api.entity.ai.statemachine.tickratestatemachine.TickRateStateMachine) TranslationConstants(com.minecolonies.api.util.constant.TranslationConstants) SECONDS_A_MINUTE(com.minecolonies.api.util.constant.Constants.SECONDS_A_MINUTE) DesiredActivity(com.minecolonies.api.entity.ai.DesiredActivity) EatingState(com.minecolonies.coremod.entity.ai.minimal.EntityAIEatTask.EatingState) VisibleCitizenStatus(com.minecolonies.api.entity.citizen.VisibleCitizenStatus) ChatPriority(com.minecolonies.api.colony.interactionhandling.ChatPriority) StandardInteraction(com.minecolonies.coremod.colony.interactionhandling.StandardInteraction) net.minecraft.item(net.minecraft.item) BlockPos(net.minecraft.util.math.BlockPos) SoundUtils(com.minecolonies.api.util.SoundUtils) BASIC_VOLUME(com.minecolonies.api.util.constant.GuardConstants.BASIC_VOLUME) SoundEvents(net.minecraft.util.SoundEvents) AdvancementTriggers(com.minecolonies.api.advancements.AdvancementTriggers) ISCOOKABLE(com.minecolonies.api.util.ItemStackUtils.ISCOOKABLE) EntityCitizen(com.minecolonies.coremod.entity.citizen.EntityCitizen) IBuilding(com.minecolonies.api.colony.buildings.IBuilding) InventoryUtils(com.minecolonies.api.util.InventoryUtils) IColony(com.minecolonies.api.colony.IColony) IState(com.minecolonies.api.entity.ai.statemachine.states.IState) ItemStorage(com.minecolonies.api.crafting.ItemStorage) IJob(com.minecolonies.api.colony.jobs.IJob) StandardInteraction(com.minecolonies.coremod.colony.interactionhandling.StandardInteraction) ICitizenData(com.minecolonies.api.colony.ICitizenData) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent)

Example 14 with StandardInteraction

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;
}
Also used : StandardInteraction(com.minecolonies.coremod.colony.interactionhandling.StandardInteraction) ICitizenData(com.minecolonies.api.colony.ICitizenData) IColony(com.minecolonies.api.colony.IColony) BuildingCook(com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingCook) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent)

Example 15 with StandardInteraction

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;
}
Also used : BuildingHospital(com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingHospital) StandardInteraction(com.minecolonies.coremod.colony.interactionhandling.StandardInteraction) IColony(com.minecolonies.api.colony.IColony) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent)

Aggregations

StandardInteraction (com.minecolonies.coremod.colony.interactionhandling.StandardInteraction)54 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)53 BlockPos (net.minecraft.util.math.BlockPos)26 ItemStack (net.minecraft.item.ItemStack)25 NotNull (org.jetbrains.annotations.NotNull)21 IAIState (com.minecolonies.api.entity.ai.statemachine.states.IAIState)19 ChatPriority (com.minecolonies.api.colony.interactionhandling.ChatPriority)17 ItemStorage (com.minecolonies.api.crafting.ItemStorage)15 AITarget (com.minecolonies.api.entity.ai.statemachine.AITarget)15 AIWorkerState (com.minecolonies.api.entity.ai.statemachine.states.AIWorkerState)15 InventoryUtils (com.minecolonies.api.util.InventoryUtils)12 TypeToken (com.google.common.reflect.TypeToken)11 StackList (com.minecolonies.api.colony.requestsystem.requestable.StackList)11 ItemStackUtils (com.minecolonies.api.util.ItemStackUtils)11 TranslationConstants (com.minecolonies.api.util.constant.TranslationConstants)11 Network (com.minecolonies.coremod.Network)11 Hand (net.minecraft.util.Hand)11 ICitizenData (com.minecolonies.api.colony.ICitizenData)10 ItemListModule (com.minecolonies.coremod.colony.buildings.modules.ItemListModule)10 TileEntity (net.minecraft.tileentity.TileEntity)9