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;
}
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;
}
Aggregations