Search in sources :

Example 66 with IAIState

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

the class EntityAIWorkFisherman method doFishing.

/**
 * Main fishing methods, let's the fisherman gather xp orbs next to him, check if all requirements to fish are given. Actually fish, retrieve his rod if stuck or if a fish
 * bites.
 *
 * @return the next IAIState the fisherman should switch to, after executing this method.
 */
@Nullable
private IAIState doFishing() {
    worker.getCitizenStatusHandler().setLatestStatus(new TranslationTextComponent("com.minecolonies.coremod.status.fishing"));
    @Nullable final IAIState notReadyState = isReadyToFish();
    if (notReadyState != null) {
        return notReadyState;
    }
    if (caughtFish()) {
        playCaughtFishSound();
        this.incrementActionsDoneAndDecSaturation();
        if (worker.getRandom().nextDouble() < CHANCE_NEW_POND) {
            job.setWater(null);
            return FISHERMAN_SEARCHING_WATER;
        }
        return FISHERMAN_WALKING_TO_WATER;
    }
    return throwOrRetrieveHook();
}
Also used : IAIState(com.minecolonies.api.entity.ai.statemachine.states.IAIState) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) Nullable(org.jetbrains.annotations.Nullable) Nullable(org.jetbrains.annotations.Nullable)

Example 67 with IAIState

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

the class EntityAIWorkCowboy method decideWhatToDo.

@Override
public IAIState decideWhatToDo() {
    final IAIState result = super.decideWhatToDo();
    final BuildingCowboy building = getOwnBuilding();
    final boolean hasBucket = InventoryUtils.hasItemInItemHandler(worker.getInventoryCitizen(), Items.BUCKET);
    if (building != null && getOwnBuilding().getSetting(BuildingCowboy.MILKING).getValue() && result.equals(START_WORKING) && hasBucket) {
        return COWBOY_MILK;
    }
    return result;
}
Also used : BuildingCowboy(com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingCowboy) IAIState(com.minecolonies.api.entity.ai.statemachine.states.IAIState)

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