Skip to content

Commit

Permalink
Fix builders requesting items again after already having them availab…
Browse files Browse the repository at this point in the history
…le. (#10404)

Builders will now check items in their inventory for the next bucket. Due to this change the last boolean of the method was always true, making it redundant, and thus removed.
  • Loading branch information
Thodor12 authored Nov 6, 2024
1 parent 7c4642e commit e7a4af7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -404,11 +404,10 @@ public Map<Integer, List<BlockPos>> getFluidsToRemove()
*
* @param requiredResources the bucket to check and request.
* @param worker the worker.
* @param workerInv if the worker inv should be checked too.
*/
public void checkOrRequestBucket(@Nullable final BuilderBucket requiredResources, final ICitizenData worker, final boolean workerInv)
public void checkOrRequestBucket(@Nullable final BuilderBucket requiredResources, final ICitizenData worker)
{
getFirstModuleOccurance(BuildingResourcesModule.class).checkOrRequestBucket(requiredResources, worker, workerInv);
getFirstModuleOccurance(BuildingResourcesModule.class).checkOrRequestBucket(requiredResources, worker);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,8 @@ public boolean requiresResourceForBuilding(final ItemStack stack)
*
* @param requiredResources the bucket to check and request.
* @param worker the worker.
* @param workerInv if the worker inv should be checked too.
*/
public void checkOrRequestBucket(@Nullable final BuilderBucket requiredResources, final ICitizenData worker, final boolean workerInv)
public void checkOrRequestBucket(@Nullable final BuilderBucket requiredResources, final ICitizenData worker)
{
if (requiredResources == null)
{
Expand All @@ -353,13 +352,10 @@ public void checkOrRequestBucket(@Nullable final BuilderBucket requiredResources
continue;
}

if (workerInv)
count += InventoryUtils.getItemCountInItemHandler(worker.getInventory(), stack -> ItemStackUtils.compareItemStacksIgnoreStackSize(stack, itemStack.getItemStack()));
if (count >= entry.getValue())
{
count += InventoryUtils.getItemCountInItemHandler(worker.getInventory(), stack -> ItemStackUtils.compareItemStacksIgnoreStackSize(stack, itemStack.getItemStack()));
if (count >= entry.getValue())
{
continue;
}
continue;
}

int requestCount = entry.getValue() - count;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ public IAIState pickUpMaterial()

if (neededItemsList.size() <= pickUpCount || InventoryUtils.openSlotCount(worker.getInventoryCitizen()) <= MIN_OPEN_SLOTS)
{
building.checkOrRequestBucket(building.getRequiredResources(), worker.getCitizenData(), true);
building.checkOrRequestBucket(building.getNextBucket(), worker.getCitizenData(), false);
building.checkOrRequestBucket(building.getRequiredResources(), worker.getCitizenData());
building.checkOrRequestBucket(building.getNextBucket(), worker.getCitizenData());
pickUpCount = 0;
return START_WORKING;
}
Expand Down Expand Up @@ -448,7 +448,7 @@ protected IAIState structureStep()
placer.executeStructureStep(world, null, progress, StructurePlacer.Operation.BLOCK_REMOVAL, () -> placer.getIterator().decrement(this::skipClearing), false);
if (result.getBlockResult().getResult() == BlockPlacementResult.Result.FINISHED)
{
building.checkOrRequestBucket(building.getRequiredResources(), worker.getCitizenData(), true);
building.checkOrRequestBucket(building.getRequiredResources(), worker.getCitizenData());
}
break;
}
Expand Down

0 comments on commit e7a4af7

Please sign in to comment.