Make IEnhancedContainer implement StackedContentsCompatible

This commit is contained in:
DBotThePony 2025-03-05 13:03:42 +07:00
parent 8aae573110
commit 8696d268ad
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -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<ItemStack> {
interface IEnhancedContainer : IContainer, RecipeInput, Iterable<ItemStack>, StackedContentsCompatible {
// provide non-ambiguous "get" operator
operator fun get(slot: Int): ItemStack {
return getItem(slot)
@ -30,6 +32,10 @@ interface IEnhancedContainer : IContainer, RecipeInput, Iterable<ItemStack> {
return IContainerSlot.Simple(slot, this)
}
override fun fillStackedContents(contents: StackedContents) {
forEach { contents.accountStack(it) }
}
/**
* Returns iterator over **all** slots this container has
*/