Search in sources :

Example 16 with IAIState

use of com.minecolonies.api.entity.ai.statemachine.states.IAIState in project minecolonies by ldtteam.

the class AbstractEntityAICrafting method getRecipe.

/**
 * Query the IRecipeStorage of the first request in the queue.
 *
 * @return the next state to go to.
 */
protected IAIState getRecipe() {
    final IRequest<? extends PublicCrafting> currentTask = job.getCurrentTask();
    if (currentTask == null) {
        return START_WORKING;
    }
    final ICraftingBuildingModule module = getOwnBuilding().getCraftingModuleForRecipe(currentTask.getRequest().getRecipeID());
    if (module == null) {
        job.finishRequest(false);
        incrementActionsDone(getActionRewardForCraftingSuccess());
        return START_WORKING;
    }
    currentRecipeStorage = module.getFirstFulfillableRecipe(stack -> ItemStackUtils.compareItemStacksIgnoreStackSize(stack, currentTask.getRequest().getStack()), 1, false);
    if (currentRecipeStorage == null) {
        job.finishRequest(false);
        incrementActionsDone(getActionRewardForCraftingSuccess());
        return START_WORKING;
    }
    currentRequest = currentTask;
    job.setMaxCraftingCount(currentRequest.getRequest().getCount());
    final int currentCount = InventoryUtils.getItemCountInItemHandler(worker.getInventoryCitizen(), stack -> ItemStackUtils.compareItemStacksIgnoreStackSize(stack, currentRecipeStorage.getPrimaryOutput()));
    final int inProgressCount = getExtendedCount(currentRecipeStorage.getPrimaryOutput());
    final int countPerIteration = currentRecipeStorage.getPrimaryOutput().getCount();
    final int doneOpsCount = currentCount / countPerIteration;
    final int progressOpsCount = inProgressCount / countPerIteration;
    final int remainingOpsCount = currentRequest.getRequest().getCount() - doneOpsCount - progressOpsCount;
    final List<ItemStorage> input = currentRecipeStorage.getCleanedInput();
    for (final ItemStorage inputStorage : input) {
        final ItemStack container = inputStorage.getItem().getContainerItem(inputStorage.getItemStack());
        final int remaining;
        if (!currentRecipeStorage.getCraftingToolsAndSecondaryOutputs().isEmpty() && ItemStackUtils.compareItemStackListIgnoreStackSize(currentRecipeStorage.getCraftingToolsAndSecondaryOutputs(), inputStorage.getItemStack(), false, true)) {
            remaining = inputStorage.getAmount();
        } else if (!ItemStackUtils.isEmpty(container) && ItemStackUtils.compareItemStacksIgnoreStackSize(inputStorage.getItemStack(), container, false, true)) {
            remaining = inputStorage.getAmount();
        } else {
            remaining = inputStorage.getAmount() * remainingOpsCount;
        }
        if (InventoryUtils.getCountFromBuilding(getOwnBuilding(), itemStack -> ItemStackUtils.compareItemStacksIgnoreStackSize(itemStack, inputStorage.getItemStack(), false, true)) + InventoryUtils.getItemCountInItemHandler(worker.getInventoryCitizen(), itemStack -> ItemStackUtils.compareItemStacksIgnoreStackSize(itemStack, inputStorage.getItemStack(), false, true)) + getExtendedCount(inputStorage.getItemStack()) < remaining) {
            job.finishRequest(false);
            incrementActionsDone(getActionRewardForCraftingSuccess());
            return START_WORKING;
        }
    }
    job.setCraftCounter(doneOpsCount);
    return QUERY_ITEMS;
}
Also used : ServerWorld(net.minecraft.world.server.ServerWorld) IRequest(com.minecolonies.api.colony.requestsystem.request.IRequest) ItemStackUtils(com.minecolonies.api.util.ItemStackUtils) IRecipeStorage(com.minecolonies.api.crafting.IRecipeStorage) AbstractJobCrafter(com.minecolonies.coremod.colony.jobs.AbstractJobCrafter) ItemStack(net.minecraft.item.ItemStack) AbstractAdvancedPathNavigate(com.minecolonies.api.entity.pathfinding.AbstractAdvancedPathNavigate) LootContext(net.minecraft.loot.LootContext) Tuple(com.minecolonies.api.util.Tuple) ImmutableList(com.google.common.collect.ImmutableList) IAIState(com.minecolonies.api.entity.ai.statemachine.states.IAIState) CraftingWorkerBuildingModule(com.minecolonies.coremod.colony.buildings.modules.CraftingWorkerBuildingModule) Hand(net.minecraft.util.Hand) AITarget(com.minecolonies.api.entity.ai.statemachine.AITarget) Log(com.minecolonies.api.util.Log) Stack(com.minecolonies.api.colony.requestsystem.requestable.Stack) RecipeStorage(com.minecolonies.api.crafting.RecipeStorage) Predicate(java.util.function.Predicate) ICraftingBuildingModule(com.minecolonies.api.colony.buildings.modules.ICraftingBuildingModule) RequestState(com.minecolonies.api.colony.requestsystem.request.RequestState) VisibleCitizenStatus(com.minecolonies.api.entity.citizen.VisibleCitizenStatus) LootParameters(net.minecraft.loot.LootParameters) AbstractBuilding(com.minecolonies.coremod.colony.buildings.AbstractBuilding) AIWorkerState(com.minecolonies.api.entity.ai.statemachine.states.AIWorkerState) DamageSource(net.minecraft.util.DamageSource) FakePlayerFactory(net.minecraftforge.common.util.FakePlayerFactory) DEFAULT_SPEED(com.minecolonies.api.util.constant.Constants.DEFAULT_SPEED) List(java.util.List) PublicCrafting(com.minecolonies.api.colony.requestsystem.requestable.crafting.PublicCrafting) InventoryUtils(com.minecolonies.api.util.InventoryUtils) ItemStorage(com.minecolonies.api.crafting.ItemStorage) NotNull(org.jetbrains.annotations.NotNull) FakePlayer(net.minecraftforge.common.util.FakePlayer) ICraftingBuildingModule(com.minecolonies.api.colony.buildings.modules.ICraftingBuildingModule) ItemStack(net.minecraft.item.ItemStack) ItemStorage(com.minecolonies.api.crafting.ItemStorage)

Example 17 with IAIState

use of com.minecolonies.api.entity.ai.statemachine.states.IAIState in project minecolonies by ldtteam.

the class EntityAIWorkBeekeeper method decideWhatToDo.

/**
 * Decides what job the beekeeper should switch to, breeding or harvesting.
 *
 * @return The next {@link IAIState} the beekeeper should switch to, after executing this method.
 */
private IAIState decideWhatToDo() {
    setDelay(DECIDING_DELAY + (99 / getSecondarySkillLevel() - 1));
    final Set<BlockPos> hives = getOwnBuilding().getHives();
    if (hives.isEmpty()) {
        worker.getCitizenData().triggerInteraction(new StandardInteraction(new TranslationTextComponent(NO_HIVES), ChatPriority.BLOCKING));
        setDelay(NO_HIVES_DELAY);
        return DECIDE;
    }
    ItemListModule flowersModule = getOwnBuilding().getModuleMatching(ItemListModule.class, m -> m.getId().equals(BUILDING_FLOWER_LIST));
    if (flowersModule.getList().isEmpty()) {
        worker.getCitizenData().triggerInteraction(new StandardInteraction(new TranslationTextComponent(COM_MINECOLONIES_COREMOD_BEEKEEPER_NOFLOWERS), ChatPriority.BLOCKING));
        setDelay(NO_FLOWERS_DELAY);
        return DECIDE;
    }
    for (BlockPos pos : hives) {
        if (!(world.getBlockState(pos).getBlock() instanceof BeehiveBlock)) {
            getOwnBuilding().removeHive(pos);
        }
    }
    final Optional<BlockPos> hive = getOwnBuilding().getHives().stream().filter(pos -> BeehiveTileEntity.getHoneyLevel(world.getBlockState(pos)) >= 5).findFirst();
    if (hive.isPresent()) {
        return BEEKEEPER_HARVEST;
    }
    final List<BeeEntity> bees = new ArrayList<>(searchForAnimals(world, getOwnBuilding()));
    final JobBeekeeper job = worker.getCitizenJobHandler().getColonyJob(JobBeekeeper.class);
    if (bees.isEmpty()) {
        if (getBeesInHives() <= 0) {
            job.tickNoBees();
            if (job.checkForBeeInteraction()) {
                worker.getCitizenData().triggerInteraction(new StandardInteraction(new TranslationTextComponent(NO_BEES), ChatPriority.BLOCKING));
            }
        } else {
            job.resetCounter();
        }
        setDelay(NO_ANIMALS_DELAY);
        return DECIDE;
    } else {
        job.resetCounter();
    }
    worker.getCitizenStatusHandler().setLatestStatus(new TranslationTextComponent(TranslationConstants.COM_MINECOLONIES_COREMOD_STATUS_DECIDING));
    final int breedableAnimals = (int) bees.stream().filter(animal -> animal.getAge() == 0).count();
    final boolean hasBreedingItem = InventoryUtils.hasItemInItemHandler(worker.getInventoryCitizen(), (stack) -> flowersModule.isItemInList(new ItemStorage(stack)));
    if (getOwnBuilding().getSetting(BuildingBeekeeper.BREEDING).getValue() && !hasMaxAnimals(bees) && breedableAnimals >= NUM_OF_ANIMALS_TO_BREED && hasBreedingItem) {
        return HERDER_BREED;
    }
    return START_WORKING;
}
Also used : ItemListModule(com.minecolonies.coremod.colony.buildings.modules.ItemListModule) BeeEntity(net.minecraft.entity.passive.BeeEntity) BeehiveBlock(net.minecraft.block.BeehiveBlock) java.util(java.util) StackList(com.minecolonies.api.colony.requestsystem.requestable.StackList) ItemStackUtils(com.minecolonies.api.util.ItemStackUtils) Item(net.minecraft.item.Item) BuildingBeekeeper(com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingBeekeeper) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Compatibility(com.minecolonies.api.compatibility.Compatibility) BUILDING_FLOWER_LIST(com.minecolonies.api.util.constant.BuildingConstants.BUILDING_FLOWER_LIST) TypeToken(com.google.common.reflect.TypeToken) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) ItemStack(net.minecraft.item.ItemStack) IAIState(com.minecolonies.api.entity.ai.statemachine.states.IAIState) BlockTags(net.minecraft.tags.BlockTags) BeehiveTileEntity(net.minecraft.tileentity.BeehiveTileEntity) JobBeekeeper(com.minecolonies.coremod.colony.jobs.JobBeekeeper) Hand(net.minecraft.util.Hand) AITarget(com.minecolonies.api.entity.ai.statemachine.AITarget) AnimalEntity(net.minecraft.entity.passive.AnimalEntity) TICKS_SECOND(com.minecolonies.api.util.constant.Constants.TICKS_SECOND) ItemListModule(com.minecolonies.coremod.colony.buildings.modules.ItemListModule) TranslationConstants(com.minecolonies.api.util.constant.TranslationConstants) AbstractEntityAIInteract(com.minecolonies.coremod.entity.ai.basic.AbstractEntityAIInteract) Entity(net.minecraft.entity.Entity) ItemTags(net.minecraft.tags.ItemTags) TOOL_LEVEL_WOOD_OR_GOLD(com.minecolonies.api.util.constant.ToolLevelConstants.TOOL_LEVEL_WOOD_OR_GOLD) World(net.minecraft.world.World) ChatPriority(com.minecolonies.api.colony.interactionhandling.ChatPriority) StandardInteraction(com.minecolonies.coremod.colony.interactionhandling.StandardInteraction) BlockPos(net.minecraft.util.math.BlockPos) Items(net.minecraft.item.Items) AIWorkerState(com.minecolonies.api.entity.ai.statemachine.states.AIWorkerState) Collectors(java.util.stream.Collectors) InventoryUtils(com.minecolonies.api.util.InventoryUtils) ToolType(com.minecolonies.api.util.constant.ToolType) ItemStorage(com.minecolonies.api.crafting.ItemStorage) NotNull(org.jetbrains.annotations.NotNull) BlockStateProperties(net.minecraft.state.properties.BlockStateProperties) StandardInteraction(com.minecolonies.coremod.colony.interactionhandling.StandardInteraction) BeehiveBlock(net.minecraft.block.BeehiveBlock) ItemStorage(com.minecolonies.api.crafting.ItemStorage) JobBeekeeper(com.minecolonies.coremod.colony.jobs.JobBeekeeper) BeeEntity(net.minecraft.entity.passive.BeeEntity) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) BlockPos(net.minecraft.util.math.BlockPos)

Example 18 with IAIState

use of com.minecolonies.api.entity.ai.statemachine.states.IAIState in project minecolonies by ldtteam.

the class EntityAIWorkBeekeeper method prepareForHerding.

/**
 * Prepares the beekeeper for herding
 *
 * @return The next {@link IAIState}.
 */
private IAIState prepareForHerding() {
    setDelay(DECIDING_DELAY);
    if (!getOwnBuilding().getHarvestTypes().equals(BuildingBeekeeper.HONEY)) {
        if (checkForToolOrWeapon(ToolType.SHEARS)) {
            return getState();
        }
    }
    if (!getOwnBuilding().getHarvestTypes().equals(BuildingBeekeeper.HONEYCOMB)) {
        checkIfRequestForItemExistOrCreateAsynch(new ItemStack(Items.GLASS_BOTTLE));
    }
    List<ItemStorage> allowedFlowers = getOwnBuilding().getModuleMatching(ItemListModule.class, m -> m.getId().equals(BUILDING_FLOWER_LIST)).getList();
    ;
    if (!InventoryUtils.hasItemInItemHandler(worker.getInventoryCitizen(), (stack) -> allowedFlowers.contains(new ItemStorage(stack))) && InventoryUtils.getCountFromBuilding(getOwnBuilding(), allowedFlowers) == 0 && !getOwnBuilding().hasWorkerOpenRequestsOfType(worker.getCitizenData().getId(), TypeToken.of(StackList.class))) {
        worker.getCitizenData().createRequestAsync(new StackList(allowedFlowers.stream().map((item) -> item.getItemStack()).peek((stack) -> stack.setCount(16)).collect(Collectors.toList()), COM_MINECOLONIES_COREMOD_REQUEST_FLOWERS, 16, 1));
    }
    return DECIDE;
}
Also used : ItemListModule(com.minecolonies.coremod.colony.buildings.modules.ItemListModule) BeeEntity(net.minecraft.entity.passive.BeeEntity) BeehiveBlock(net.minecraft.block.BeehiveBlock) java.util(java.util) StackList(com.minecolonies.api.colony.requestsystem.requestable.StackList) ItemStackUtils(com.minecolonies.api.util.ItemStackUtils) Item(net.minecraft.item.Item) BuildingBeekeeper(com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingBeekeeper) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Compatibility(com.minecolonies.api.compatibility.Compatibility) BUILDING_FLOWER_LIST(com.minecolonies.api.util.constant.BuildingConstants.BUILDING_FLOWER_LIST) TypeToken(com.google.common.reflect.TypeToken) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) ItemStack(net.minecraft.item.ItemStack) IAIState(com.minecolonies.api.entity.ai.statemachine.states.IAIState) BlockTags(net.minecraft.tags.BlockTags) BeehiveTileEntity(net.minecraft.tileentity.BeehiveTileEntity) JobBeekeeper(com.minecolonies.coremod.colony.jobs.JobBeekeeper) Hand(net.minecraft.util.Hand) AITarget(com.minecolonies.api.entity.ai.statemachine.AITarget) AnimalEntity(net.minecraft.entity.passive.AnimalEntity) TICKS_SECOND(com.minecolonies.api.util.constant.Constants.TICKS_SECOND) ItemListModule(com.minecolonies.coremod.colony.buildings.modules.ItemListModule) TranslationConstants(com.minecolonies.api.util.constant.TranslationConstants) AbstractEntityAIInteract(com.minecolonies.coremod.entity.ai.basic.AbstractEntityAIInteract) Entity(net.minecraft.entity.Entity) ItemTags(net.minecraft.tags.ItemTags) TOOL_LEVEL_WOOD_OR_GOLD(com.minecolonies.api.util.constant.ToolLevelConstants.TOOL_LEVEL_WOOD_OR_GOLD) World(net.minecraft.world.World) ChatPriority(com.minecolonies.api.colony.interactionhandling.ChatPriority) StandardInteraction(com.minecolonies.coremod.colony.interactionhandling.StandardInteraction) BlockPos(net.minecraft.util.math.BlockPos) Items(net.minecraft.item.Items) AIWorkerState(com.minecolonies.api.entity.ai.statemachine.states.AIWorkerState) Collectors(java.util.stream.Collectors) InventoryUtils(com.minecolonies.api.util.InventoryUtils) ToolType(com.minecolonies.api.util.constant.ToolType) ItemStorage(com.minecolonies.api.crafting.ItemStorage) NotNull(org.jetbrains.annotations.NotNull) BlockStateProperties(net.minecraft.state.properties.BlockStateProperties) StackList(com.minecolonies.api.colony.requestsystem.requestable.StackList) ItemStack(net.minecraft.item.ItemStack) ItemStorage(com.minecolonies.api.crafting.ItemStorage)

Example 19 with IAIState

use of com.minecolonies.api.entity.ai.statemachine.states.IAIState in project minecolonies by ldtteam.

the class EntityAIWorkLumberjack method findTree.

/**
 * Search for a tree.
 *
 * @return LUMBERJACK_GATHERING if job was canceled.
 */
private IAIState findTree() {
    final BuildingLumberjack building = getOwnBuilding();
    worker.getCitizenData().setVisibleStatus(SEARCH);
    if (pathResult != null && pathResult.isComputing()) {
        return getState();
    }
    if (pathResult == null) {
        if (building.shouldRestrict()) {
            final BlockPos startPos = building.getStartRestriction();
            final BlockPos endPos = building.getEndRestriction();
            pathResult = worker.getNavigation().moveToTree(startPos, endPos, 1.0D, building.getModuleMatching(ItemListModule.class, m -> m.getId().equals(SAPLINGS_LIST)).getList(), building.getSetting(BuildingLumberjack.DYNAMIC_TREES_SIZE).getValue(), worker.getCitizenColonyHandler().getColony());
        } else {
            pathResult = worker.getNavigation().moveToTree(SEARCH_RANGE + searchIncrement, 1.0D, building.getModuleMatching(ItemListModule.class, m -> m.getId().equals(SAPLINGS_LIST)).getList(), building.getSetting(BuildingLumberjack.DYNAMIC_TREES_SIZE).getValue(), worker.getCitizenColonyHandler().getColony());
        }
        return getState();
    }
    if (pathResult.isDone()) {
        return setNewTree(building);
    }
    // None of the above yielded a result, report no trees found.
    return LUMBERJACK_NO_TREES_FOUND;
}
Also used : ItemListModule(com.minecolonies.coremod.colony.buildings.modules.ItemListModule) Path(net.minecraft.pathfinding.Path) Item(net.minecraft.item.Item) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) ModTags.fungi(com.minecolonies.api.items.ModTags.fungi) Compatibility(com.minecolonies.api.compatibility.Compatibility) Direction(net.minecraft.util.Direction) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) IAIState(com.minecolonies.api.entity.ai.statemachine.states.IAIState) net.minecraft.block(net.minecraft.block) BlockTags(net.minecraft.tags.BlockTags) AbstractEntityAICrafting(com.minecolonies.coremod.entity.ai.basic.AbstractEntityAICrafting) Hand(net.minecraft.util.Hand) AITarget(com.minecolonies.api.entity.ai.statemachine.AITarget) com.minecolonies.api.util(com.minecolonies.api.util) TICKS_SECOND(com.minecolonies.api.util.constant.Constants.TICKS_SECOND) SoundCategory(net.minecraft.util.SoundCategory) Constants(com.minecolonies.api.util.constant.Constants) ItemListModule(com.minecolonies.coremod.colony.buildings.modules.ItemListModule) JobLumberjack(com.minecolonies.coremod.colony.jobs.JobLumberjack) MinecoloniesAdvancedPathNavigate(com.minecolonies.coremod.entity.pathfinding.MinecoloniesAdvancedPathNavigate) VisibleCitizenStatus(com.minecolonies.api.entity.citizen.VisibleCitizenStatus) BuildingLumberjack(com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingLumberjack) PathPoint(net.minecraft.pathfinding.PathPoint) ITag(net.minecraft.tags.ITag) BlockPos(net.minecraft.util.math.BlockPos) Items(net.minecraft.item.Items) AIWorkerState(com.minecolonies.api.entity.ai.statemachine.states.AIWorkerState) IPlantable(net.minecraftforge.common.IPlantable) Objects(java.util.Objects) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) PathResult(com.minecolonies.api.entity.pathfinding.PathResult) TreePathResult(com.minecolonies.api.entity.pathfinding.TreePathResult) Material(net.minecraft.block.material.Material) BlockItem(net.minecraft.item.BlockItem) MineColonies(com.minecolonies.coremod.MineColonies) WorkerUtil(com.minecolonies.coremod.util.WorkerUtil) ResourceLocation(net.minecraft.util.ResourceLocation) AbstractPathJob(com.minecolonies.coremod.entity.pathfinding.pathjobs.AbstractPathJob) ToolType(com.minecolonies.api.util.constant.ToolType) NotNull(org.jetbrains.annotations.NotNull) PathJobMoveToWithPassable(com.minecolonies.coremod.entity.pathfinding.pathjobs.PathJobMoveToWithPassable) BlockPos(net.minecraft.util.math.BlockPos) BuildingLumberjack(com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingLumberjack)

Example 20 with IAIState

use of com.minecolonies.api.entity.ai.statemachine.states.IAIState in project minecolonies by ldtteam.

the class EntityAIWorkHealer method cure.

/**
 * Give a citizen the cure.
 *
 * @return the next state to go to.
 */
private IAIState cure() {
    if (currentPatient == null) {
        return DECIDE;
    }
    final ICitizenData data = getOwnBuilding().getColony().getCitizenManager().getCivilian(currentPatient.getId());
    if (data == null || !data.getEntity().isPresent() || !data.getEntity().get().getCitizenDiseaseHandler().isSick()) {
        currentPatient = null;
        return DECIDE;
    }
    final EntityCitizen citizen = (EntityCitizen) data.getEntity().get();
    if (walkToBlock(data.getEntity().get().blockPosition())) {
        return CURE;
    }
    final String diseaseName = citizen.getCitizenDiseaseHandler().getDisease();
    final Disease disease = IColonyManager.getInstance().getCompatibilityManager().getDisease(diseaseName);
    if (diseaseName.isEmpty()) {
        currentPatient = null;
        citizen.heal(10);
        worker.getCitizenExperienceHandler().addExperience(BASE_XP_GAIN);
        citizen.markDirty();
        return DECIDE;
    }
    if (!hasCureInInventory(disease, worker.getInventoryCitizen())) {
        if (hasCureInInventory(disease, getOwnBuilding().getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElseGet(null))) {
            for (final ItemStack cure : disease.getCure()) {
                if (InventoryUtils.getItemCountInItemHandler(worker.getInventoryCitizen(), stack -> stack.sameItem(cure)) < cure.getCount()) {
                    needsCurrently = new Tuple<>(stack -> stack.sameItem(cure), 1);
                    return GATHERING_REQUIRED_MATERIALS;
                }
            }
        }
        currentPatient = null;
        return DECIDE;
    }
    if (!hasCureInInventory(disease, citizen.getInventoryCitizen())) {
        for (final ItemStack cure : disease.getCure()) {
            if (InventoryUtils.getItemCountInItemHandler(citizen.getInventoryCitizen(), stack -> stack.sameItem(cure)) < cure.getCount()) {
                if (InventoryUtils.isItemHandlerFull(citizen.getInventoryCitizen())) {
                    data.triggerInteraction(new StandardInteraction(new TranslationTextComponent(PATIENT_FULL_INVENTORY), ChatPriority.BLOCKING));
                    currentPatient = null;
                    return DECIDE;
                }
                InventoryUtils.transferXOfFirstSlotInItemHandlerWithIntoNextFreeSlotInItemHandler(worker.getInventoryCitizen(), cure::sameItem, cure.getCount(), citizen.getInventoryCitizen());
            }
        }
    }
    worker.getCitizenExperienceHandler().addExperience(BASE_XP_GAIN);
    currentPatient.setState(Patient.PatientState.TREATED);
    currentPatient = null;
    return DECIDE;
}
Also used : IItemHandler(net.minecraftforge.items.IItemHandler) IRequest(com.minecolonies.api.colony.requestsystem.request.IRequest) ICitizenData(com.minecolonies.api.colony.ICitizenData) TypeToken(com.google.common.reflect.TypeToken) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) ItemStack(net.minecraft.item.ItemStack) ImmutableList(com.google.common.collect.ImmutableList) IAIState(com.minecolonies.api.entity.ai.statemachine.states.IAIState) JobHealer(com.minecolonies.coremod.colony.jobs.JobHealer) AITarget(com.minecolonies.api.entity.ai.statemachine.AITarget) com.minecolonies.api.util(com.minecolonies.api.util) Network(com.minecolonies.coremod.Network) PATIENT_FULL_INVENTORY(com.minecolonies.api.util.constant.TranslationConstants.PATIENT_FULL_INVENTORY) StreamParticleEffectMessage(com.minecolonies.coremod.network.messages.client.StreamParticleEffectMessage) Stack(com.minecolonies.api.colony.requestsystem.requestable.Stack) AbstractEntityAIInteract(com.minecolonies.coremod.entity.ai.basic.AbstractEntityAIInteract) PlayerEntity(net.minecraft.entity.player.PlayerEntity) CircleParticleEffectMessage(com.minecolonies.coremod.network.messages.client.CircleParticleEffectMessage) IColonyManager(com.minecolonies.api.colony.IColonyManager) ChatPriority(com.minecolonies.api.colony.interactionhandling.ChatPriority) StandardInteraction(com.minecolonies.coremod.colony.interactionhandling.StandardInteraction) BlockPos(net.minecraft.util.math.BlockPos) AIWorkerState(com.minecolonies.api.entity.ai.statemachine.states.AIWorkerState) ParticleTypes(net.minecraft.particles.ParticleTypes) Nullable(org.jetbrains.annotations.Nullable) AbstractEntityCitizen(com.minecolonies.api.entity.citizen.AbstractEntityCitizen) BuildingHospital(com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingHospital) EntityCitizen(com.minecolonies.coremod.entity.citizen.EntityCitizen) CapabilityItemHandler(net.minecraftforge.items.CapabilityItemHandler) NotNull(org.jetbrains.annotations.NotNull) StandardInteraction(com.minecolonies.coremod.colony.interactionhandling.StandardInteraction) ICitizenData(com.minecolonies.api.colony.ICitizenData) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) AbstractEntityCitizen(com.minecolonies.api.entity.citizen.AbstractEntityCitizen) EntityCitizen(com.minecolonies.coremod.entity.citizen.EntityCitizen) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IAIState (com.minecolonies.api.entity.ai.statemachine.states.IAIState)67 ItemStack (net.minecraft.item.ItemStack)52 BlockPos (net.minecraft.util.math.BlockPos)45 AIWorkerState (com.minecolonies.api.entity.ai.statemachine.states.AIWorkerState)44 NotNull (org.jetbrains.annotations.NotNull)44 AITarget (com.minecolonies.api.entity.ai.statemachine.AITarget)42 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)42 ItemStorage (com.minecolonies.api.crafting.ItemStorage)35 InventoryUtils (com.minecolonies.api.util.InventoryUtils)32 StandardInteraction (com.minecolonies.coremod.colony.interactionhandling.StandardInteraction)32 Hand (net.minecraft.util.Hand)32 ItemStackUtils (com.minecolonies.api.util.ItemStackUtils)30 ChatPriority (com.minecolonies.api.colony.interactionhandling.ChatPriority)28 TranslationConstants (com.minecolonies.api.util.constant.TranslationConstants)24 ItemListModule (com.minecolonies.coremod.colony.buildings.modules.ItemListModule)24 TileEntity (net.minecraft.tileentity.TileEntity)24 Tuple (com.minecolonies.api.util.Tuple)22 List (java.util.List)22 TypeToken (com.google.common.reflect.TypeToken)20 IRequest (com.minecolonies.api.colony.requestsystem.request.IRequest)20