use of com.minecolonies.coremod.entity.ai.util.AIState in project minecolonies by Minecolonies.
the class EntityAIWorkDeliveryman method tryToGatherItems.
/**
* Gather item from chest.
* Gathers only one stack of the item.
*
* @param buildingToDeliver building to deliver to.
*/
private AIState tryToGatherItems(@NotNull final AbstractBuilding buildingToDeliver) {
final BlockPos position;
if (buildingToDeliver instanceof BuildingHome) {
position = wareHouse.getTileEntity().getPositionOfChestWithItemStack(itemStack -> !InventoryUtils.isItemStackEmpty(itemStack) && itemStack.getItem() instanceof ItemFood);
} else if (itemsToDeliver.isEmpty()) {
final String tool = buildingToDeliver.getRequiredTool();
position = wareHouse.getTileEntity().getPositionOfChestWithTool(tool, Utils.PICKAXE.equals(tool) ? buildingToDeliver.getNeededPickaxeLevel() : buildingToDeliver.getBuildingLevel(), buildingToDeliver);
} else {
final ItemStack stack = itemsToDeliver.get(0);
position = wareHouse.getTileEntity().getPositionOfChestWithItemStack(stack);
}
if (position == null) {
((BuildingDeliveryman) getOwnBuilding()).setBuildingToDeliver(null);
itemsToDeliver.clear();
return START_WORKING;
}
if (!worker.isWorkerAtSiteWithMove(position, MIN_DISTANCE_TO_CHEST)) {
setDelay(DUMP_AND_GATHER_DELAY);
return GATHER_IN_WAREHOUSE;
}
return gatherItems(buildingToDeliver, position);
}
use of com.minecolonies.coremod.entity.ai.util.AIState in project minecolonies by Minecolonies.
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 AIState the fisherman should switch to, after executing this method.
*/
@Nullable
private AIState doFishing() {
@Nullable final AIState notReadyState = isReadyToFish();
if (notReadyState != null) {
return notReadyState;
}
if (caughtFish()) {
this.getOwnBuilding().getColony().incrementStatistic("fish");
playCaughtFishSound();
if (random.nextDouble() < CHANCE_NEW_POND) {
job.setWater(null);
return FISHERMAN_SEARCHING_WATER;
}
return FISHERMAN_WALKING_TO_WATER;
}
return throwOrRetrieveHook();
}
Aggregations