Search in sources :

Example 1 with ISCOOKABLE

use of com.minecolonies.api.util.ItemStackUtils.ISCOOKABLE 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 2 with ISCOOKABLE

use of com.minecolonies.api.util.ItemStackUtils.ISCOOKABLE in project minecolonies by Minecolonies.

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) AbstractJobGuard(com.minecolonies.coremod.colony.jobs.AbstractJobGuard) IState(com.minecolonies.api.entity.ai.statemachine.states.IState) ItemStorage(com.minecolonies.api.crafting.ItemStorage) WorldUtil(com.minecolonies.api.util.WorldUtil) 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)

Aggregations

AdvancementTriggers (com.minecolonies.api.advancements.AdvancementTriggers)2 ICitizenData (com.minecolonies.api.colony.ICitizenData)2 IColony (com.minecolonies.api.colony.IColony)2 IBuilding (com.minecolonies.api.colony.buildings.IBuilding)2 ChatPriority (com.minecolonies.api.colony.interactionhandling.ChatPriority)2 IJob (com.minecolonies.api.colony.jobs.IJob)2 ItemStorage (com.minecolonies.api.crafting.ItemStorage)2 DesiredActivity (com.minecolonies.api.entity.ai.DesiredActivity)2 IState (com.minecolonies.api.entity.ai.statemachine.states.IState)2 TickRateStateMachine (com.minecolonies.api.entity.ai.statemachine.tickratestatemachine.TickRateStateMachine)2 TickingTransition (com.minecolonies.api.entity.ai.statemachine.tickratestatemachine.TickingTransition)2 VisibleCitizenStatus (com.minecolonies.api.entity.citizen.VisibleCitizenStatus)2 SATURATION (com.minecolonies.api.research.util.ResearchConstants.SATURATION)2 InventoryUtils (com.minecolonies.api.util.InventoryUtils)2 CAN_EAT (com.minecolonies.api.util.ItemStackUtils.CAN_EAT)2 ISCOOKABLE (com.minecolonies.api.util.ItemStackUtils.ISCOOKABLE)2 Log (com.minecolonies.api.util.Log)2 SoundUtils (com.minecolonies.api.util.SoundUtils)2 CitizenConstants (com.minecolonies.api.util.constant.CitizenConstants)2 LOW_SATURATION (com.minecolonies.api.util.constant.CitizenConstants.LOW_SATURATION)2