Make IEnhancedContainer implement StackedContentsCompatible
This commit is contained in:
parent
8aae573110
commit
8696d268ad
@ -4,6 +4,8 @@ import it.unimi.dsi.fastutil.ints.IntCollection
|
|||||||
import it.unimi.dsi.fastutil.ints.IntSet
|
import it.unimi.dsi.fastutil.ints.IntSet
|
||||||
import net.minecraft.world.Container
|
import net.minecraft.world.Container
|
||||||
import net.minecraft.world.entity.player.Player
|
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.Item
|
||||||
import net.minecraft.world.item.ItemStack
|
import net.minecraft.world.item.ItemStack
|
||||||
import net.minecraft.world.item.Items
|
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,
|
* 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.
|
* 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
|
// provide non-ambiguous "get" operator
|
||||||
operator fun get(slot: Int): ItemStack {
|
operator fun get(slot: Int): ItemStack {
|
||||||
return getItem(slot)
|
return getItem(slot)
|
||||||
@ -30,6 +32,10 @@ interface IEnhancedContainer : IContainer, RecipeInput, Iterable<ItemStack> {
|
|||||||
return IContainerSlot.Simple(slot, this)
|
return IContainerSlot.Simple(slot, this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun fillStackedContents(contents: StackedContents) {
|
||||||
|
forEach { contents.accountStack(it) }
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns iterator over **all** slots this container has
|
* Returns iterator over **all** slots this container has
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user