Search in sources :

Example 1 with PickupRequest

use of com.minecolonies.coremod.colony.requestsystem.requests.StandardRequests.PickupRequest in project minecolonies by Minecolonies.

the class EntityAIWorkDeliveryman method pickup.

/**
 * Pickup items from a hut that has requested a pickup.
 *
 * @return the next state to go to.
 */
private IAIState pickup() {
    final IRequest<? extends IDeliverymanRequestable> currentTask = job.getCurrentTask();
    if (!(currentTask instanceof PickupRequest)) {
        // The current task has changed since the Decision-state. Restart.
        return START_WORKING;
    }
    if (cannotHoldMoreItems()) {
        this.alreadyKept = new ArrayList<>();
        this.currentSlot = 0;
        return DUMPING;
    }
    worker.getCitizenData().setVisibleStatus(DELIVERING);
    worker.getCitizenStatusHandler().setLatestStatus(new TranslationTextComponent("com.minecolonies.coremod.status.gathering"));
    final BlockPos pickupTarget = currentTask.getRequester().getLocation().getInDimensionLocation();
    if (pickupTarget != BlockPos.ZERO && !worker.isWorkerAtSiteWithMove(pickupTarget, MIN_DISTANCE_TO_WAREHOUSE)) {
        setDelay(WALK_DELAY);
        return PICKUP;
    }
    final IBuilding pickupBuilding = getOwnBuilding().getColony().getBuildingManager().getBuilding(pickupTarget);
    if (pickupBuilding == null) {
        job.finishRequest(false);
        return START_WORKING;
    }
    if (pickupFromBuilding(pickupBuilding)) {
        this.alreadyKept = new ArrayList<>();
        this.currentSlot = 0;
        job.finishRequest(true);
        if (currentTask.getRequest().getPriority() >= PRIORITY_FORCING_DUMP) {
            return DUMPING;
        } else {
            return START_WORKING;
        }
    } else if (InventoryUtils.openSlotCount(worker.getInventoryCitizen()) <= 0) {
        this.alreadyKept = new ArrayList<>();
        this.currentSlot = 0;
        return DUMPING;
    }
    currentSlot++;
    return PICKUP;
}
Also used : IBuilding(com.minecolonies.api.colony.buildings.IBuilding) PickupRequest(com.minecolonies.coremod.colony.requestsystem.requests.StandardRequests.PickupRequest) ArrayList(java.util.ArrayList) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) BlockPos(net.minecraft.util.math.BlockPos)

Example 2 with PickupRequest

use of com.minecolonies.coremod.colony.requestsystem.requests.StandardRequests.PickupRequest in project minecolonies by ldtteam.

the class EntityAIWorkDeliveryman method pickup.

/**
 * Pickup items from a hut that has requested a pickup.
 *
 * @return the next state to go to.
 */
private IAIState pickup() {
    final IRequest<? extends IDeliverymanRequestable> currentTask = job.getCurrentTask();
    if (!(currentTask instanceof PickupRequest)) {
        // The current task has changed since the Decision-state. Restart.
        return START_WORKING;
    }
    if (cannotHoldMoreItems()) {
        this.alreadyKept = new ArrayList<>();
        this.currentSlot = 0;
        return DUMPING;
    }
    worker.getCitizenData().setVisibleStatus(DELIVERING);
    worker.getCitizenStatusHandler().setLatestStatus(new TranslationTextComponent("com.minecolonies.coremod.status.gathering"));
    final BlockPos pickupTarget = currentTask.getRequester().getLocation().getInDimensionLocation();
    if (pickupTarget != BlockPos.ZERO && !worker.isWorkerAtSiteWithMove(pickupTarget, MIN_DISTANCE_TO_WAREHOUSE)) {
        setDelay(WALK_DELAY);
        return PICKUP;
    }
    final IBuilding pickupBuilding = getOwnBuilding().getColony().getBuildingManager().getBuilding(pickupTarget);
    if (pickupBuilding == null) {
        job.finishRequest(false);
        return START_WORKING;
    }
    if (pickupFromBuilding(pickupBuilding)) {
        this.alreadyKept = new ArrayList<>();
        this.currentSlot = 0;
        job.finishRequest(true);
        if (currentTask.getRequest().getPriority() >= PRIORITY_FORCING_DUMP) {
            return DUMPING;
        } else {
            return START_WORKING;
        }
    } else if (InventoryUtils.openSlotCount(worker.getInventoryCitizen()) <= 0) {
        this.alreadyKept = new ArrayList<>();
        this.currentSlot = 0;
        return DUMPING;
    }
    currentSlot++;
    return PICKUP;
}
Also used : IBuilding(com.minecolonies.api.colony.buildings.IBuilding) PickupRequest(com.minecolonies.coremod.colony.requestsystem.requests.StandardRequests.PickupRequest) ArrayList(java.util.ArrayList) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

IBuilding (com.minecolonies.api.colony.buildings.IBuilding)2 PickupRequest (com.minecolonies.coremod.colony.requestsystem.requests.StandardRequests.PickupRequest)2 ArrayList (java.util.ArrayList)2 BlockPos (net.minecraft.util.math.BlockPos)2 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)2