From 99c63307b64ae217ecd41a9b3b49d7d00a789df4 Mon Sep 17 00:00:00 2001 From: Raycoms Date: Fri, 29 Nov 2024 13:35:01 +0100 Subject: [PATCH] fix and log too large stack sizes. --- .../api/colony/requestsystem/requestable/Stack.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/minecolonies/api/colony/requestsystem/requestable/Stack.java b/src/main/java/com/minecolonies/api/colony/requestsystem/requestable/Stack.java index 722aa046f75..f99bc852aca 100755 --- a/src/main/java/com/minecolonies/api/colony/requestsystem/requestable/Stack.java +++ b/src/main/java/com/minecolonies/api/colony/requestsystem/requestable/Stack.java @@ -5,6 +5,7 @@ import com.minecolonies.api.colony.requestsystem.factory.IFactoryController; import com.minecolonies.api.crafting.ItemStorage; import com.minecolonies.api.util.ItemStackUtils; +import com.minecolonies.api.util.Log; import com.minecolonies.api.util.ReflectionUtils; import com.minecolonies.api.util.Utils; import com.minecolonies.api.util.constant.TypeConstants; @@ -165,7 +166,17 @@ public Stack(final ItemStack stack, final boolean matchDamage, final boolean mat throw new IllegalArgumentException("Cannot deliver Empty Stack."); } - this.theStack = stack.copy(); + if (stack.getCount() > stack.getMaxStackSize()) + { + Log.getLogger().error("Stack with ItemStack with too large stack size.: ", new Exception()); + this.theStack = stack.copy(); + this.theStack.setCount(this.theStack.getMaxStackSize()); + } + else + { + this.theStack = stack.copy(); + } + this.matchDamage = matchDamage; this.matchNBT = matchNBT; this.result = result;