Implement IEnhancedCraftingContainer

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

View File

@ -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)
}
}
}