From 8696d268adb21cda7ab39b0f739c7b0d8068474e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 5 Mar 2025 13:03:42 +0700 Subject: [PATCH] Make IEnhancedContainer implement StackedContentsCompatible --- .../ru/dbotthepony/mc/otm/container/IEnhancedContainer.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/IEnhancedContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/IEnhancedContainer.kt index 1aae7b23f..1a4cb4267 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/IEnhancedContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/IEnhancedContainer.kt @@ -4,6 +4,8 @@ import it.unimi.dsi.fastutil.ints.IntCollection import it.unimi.dsi.fastutil.ints.IntSet import net.minecraft.world.Container import net.minecraft.world.entity.player.Player +import net.minecraft.world.entity.player.StackedContents +import net.minecraft.world.inventory.StackedContentsCompatible import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items @@ -20,7 +22,7 @@ import java.util.function.Predicate * This is useful because it allows to interact with actually enhanced and regular containers through unified interface, * and actual implementations of this interface are likely to provide efficient method implementations in place of derived/emulated ones. */ -interface IEnhancedContainer : IContainer, RecipeInput, Iterable { +interface IEnhancedContainer : IContainer, RecipeInput, Iterable, StackedContentsCompatible { // provide non-ambiguous "get" operator operator fun get(slot: Int): ItemStack { return getItem(slot) @@ -30,6 +32,10 @@ interface IEnhancedContainer : IContainer, RecipeInput, Iterable { return IContainerSlot.Simple(slot, this) } + override fun fillStackedContents(contents: StackedContents) { + forEach { contents.accountStack(it) } + } + /** * Returns iterator over **all** slots this container has */