MineColonies

MineColonies

57M Downloads

Deliveryman should deliver food preemptively

cltnschlosser opened this issue · 7 comments

commented

The issue isn't necessarily with the deliveryman himself, but in the way food is requested. Currently he delivers the food a day late, and not enough at a time.

if (buildingToDeliver instanceof BuildingHome)
            {
                final int extraFood = worker.getCitizenData().getSaturation() < EntityCitizen.HIGH_SATURATION ? 1 : 0;

                //Tries to extract a certain amount of the item of the chest.
                if (InventoryUtils.transferXOfFirstSlotInProviderWithIntoNextFreeSlotInItemHandler(
                        tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null),
                        itemStack -> !InventoryUtils.isItemStackEmpty(itemStack) && itemStack.getItem() instanceof ItemFood,
                        buildingToDeliver.getBuildingLevel() + extraFood,
                        new InvWrapper(worker.getInventoryCitizen())))
                {
                    worker.setHeldItem(SLOT_HAND);
                    setDelay(DUMP_AND_GATHER_DELAY);
                    return DELIVERY;
                }

                ((BuildingDeliveryman) getOwnBuilding()).setBuildingToDeliver(null);
                itemsToDeliver.clear();
                return START_WORKING;
            }

Really only this line is important:

final int extraFood = worker.getCitizenData().getSaturation() < EntityCitizen.HIGH_SATURATION ? 1 : 0;

We use the deliveryman's saturation to detect if we need extra food, but we should check all the residents of that BuildingHome

commented
commented
commented

Actually, we use the deliveryman saturation to detect if we need extra food.
(Because if the dman is low on saturation he will eat the food he should
deliver)

Lol

commented
commented

Still with the latest release, I had to deliver the food myself

commented

He should deliver it now, even if its only a day late.

commented

Been worked on. Closed in favor of other issue.