Implement IEnhancedCraftingContainer
This commit is contained in:
parent
8696d268ad
commit
5942ab2126
@ -0,0 +1,33 @@
|
|||||||
|
package ru.dbotthepony.mc.otm.container
|
||||||
|
|
||||||
|
import net.minecraft.world.entity.player.StackedContents
|
||||||
|
import net.minecraft.world.inventory.CraftingContainer
|
||||||
|
import net.minecraft.world.item.ItemStack
|
||||||
|
|
||||||
|
interface IEnhancedCraftingContainer : IEnhancedContainer, CraftingContainer {
|
||||||
|
override fun getItems(): MutableList<ItemStack> {
|
||||||
|
return toList()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun fillStackedContents(contents: StackedContents) {
|
||||||
|
forEach { contents.accountSimpleStack(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
class Wrapper<C : IEnhancedContainer>(val parent: C, private val width: Int, private val height: Int) : IEnhancedCraftingContainer, IEnhancedContainer by parent {
|
||||||
|
init {
|
||||||
|
require(width * height == parent.containerSize) { "Crafting container dimensions ($width x $height) do not match container size provided (${parent.containerSize})" }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getWidth(): Int {
|
||||||
|
return width
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getHeight(): Int {
|
||||||
|
return height
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun fillStackedContents(contents: StackedContents) {
|
||||||
|
super<IEnhancedCraftingContainer>.fillStackedContents(contents)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user