From 571c7bc3390153ad6f01c85d5caab3a9841aa9ae Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 29 Mar 2025 13:33:07 +0700 Subject: [PATCH] Passing Int.MAX_VALUE to simple container slot factory will make its slots ignore max stack size completely --- .../dbotthepony/mc/otm/container/slotted/ContainerSlot.kt | 8 ++++++++ .../mc/otm/container/slotted/FilteredContainerSlot.kt | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/slotted/ContainerSlot.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/slotted/ContainerSlot.kt index 7d4821597..178ee81f5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/slotted/ContainerSlot.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/slotted/ContainerSlot.kt @@ -133,6 +133,13 @@ open class ContainerSlot( override val maxStackSize: Int get() = this@Simple.maxStackSize + override fun maxStackSize(item: ItemStack): Int { + if (maxStackSize == Int.MAX_VALUE) + return Int.MAX_VALUE + + return super.maxStackSize(item) + } + override fun notifyChanged(old: ItemStack) { super.notifyChanged(old) listener(item, old) @@ -160,6 +167,7 @@ open class ContainerSlot( } } + companion object { private val LOGGER = LogManager.getLogger() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/slotted/FilteredContainerSlot.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/slotted/FilteredContainerSlot.kt index 4e2d50f3d..11a59da02 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/slotted/FilteredContainerSlot.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/slotted/FilteredContainerSlot.kt @@ -68,6 +68,13 @@ open class FilteredContainerSlot( override val maxStackSize: Int get() = this@Simple.maxStackSize + override fun maxStackSize(item: ItemStack): Int { + if (maxStackSize == Int.MAX_VALUE) + return Int.MAX_VALUE + + return super.maxStackSize(item) + } + override fun notifyChanged(old: ItemStack) { super.notifyChanged(old) listener(item, old)