Skip to content

Commit

Permalink
avoid setting too large stacks (#10488)
Browse files Browse the repository at this point in the history
Make sure to not create too large itemstacks with too many items in it.
  • Loading branch information
Raycoms authored Dec 1, 2024
1 parent f942ccd commit 2527a44
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.minecolonies.core.entity.ai.workers.production.herders;

import com.minecolonies.api.crafting.ItemStorage;
import com.minecolonies.api.entity.ai.statemachine.AITarget;
import com.minecolonies.api.entity.ai.statemachine.states.IAIState;
import com.minecolonies.api.entity.citizen.VisibleCitizenStatus;
Expand Down Expand Up @@ -178,7 +179,7 @@ public List<EquipmentTypeEntry> getExtraToolsNeeded()
* @return a list of items needed or empty.
*/
@NotNull
public List<ItemStack> getExtraItemsNeeded()
public List<ItemStorage> getExtraItemsNeeded()
{
return new ArrayList<>();
}
Expand Down Expand Up @@ -312,9 +313,9 @@ private IAIState prepareForHerding()
checkIfRequestForItemExistOrCreateAsync(breedingItem, breedingItem.getCount() * EXTRA_BREEDING_ITEMS_REQUEST, breedingItem.getCount());
}

for (final ItemStack item : getExtraItemsNeeded())
for (final ItemStorage item : getExtraItemsNeeded())
{
checkIfRequestForItemExistOrCreateAsync(item);
checkIfRequestForItemExistOrCreateAsync(item.getItemStack(), item.getAmount(), item.getAmount());
}

return DECIDE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,20 @@ else if (building != null && building.getFirstModuleOccurance(BuildingCowboy.Her

@NotNull
@Override
public List<ItemStack> getExtraItemsNeeded()
public List<ItemStorage> getExtraItemsNeeded()
{
final List<ItemStack> list = super.getExtraItemsNeeded();
final List<ItemStorage> list = super.getExtraItemsNeeded();
if (building != null && building.getFirstModuleOccurance(BuildingCowboy.HerdingModule.class).canTryToMilk() &&
!searchForAnimals(a -> a instanceof Cow && !(a instanceof MushroomCow)).isEmpty())
{
final ItemStack stack = building.getMilkInputItem().copy();
stack.setCount(building.getSetting(MILKING_AMOUNT).getValue());
final ItemStorage stack = new ItemStorage(building.getMilkInputItem().copy());
stack.setAmount(building.getSetting(MILKING_AMOUNT).getValue());
list.add(stack);
}
if (building != null && building.getFirstModuleOccurance(BuildingCowboy.HerdingModule.class).canTryToStew() &&
!searchForAnimals(a -> a instanceof MushroomCow).isEmpty())
{
list.add(new ItemStack(Items.BOWL));
list.add(new ItemStorage(Items.BOWL));
}
return list;
}
Expand Down

0 comments on commit 2527a44

Please sign in to comment.