monadmachines/src/main/kotlin/tf/bug/monadmachines/block/ProgramWorkstationGuiDescri...

40 lines
1.4 KiB
Kotlin

package tf.bug.monadmachines.block
import io.github.cottonmc.cotton.gui.SyncedGuiDescription
import io.github.cottonmc.cotton.gui.widget.WGridPanel
import io.github.cottonmc.cotton.gui.widget.WItemSlot
import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry
import net.minecraft.entity.player.PlayerInventory
import net.minecraft.screen.ScreenHandlerContext
import net.minecraft.screen.ScreenHandlerType
class ProgramWorkstationGuiDescription(syncId: Int, playerInventory: PlayerInventory, context: ScreenHandlerContext) : SyncedGuiDescription(type, syncId, playerInventory, getBlockInventory(context, inventorySize), getBlockPropertyDelegate(context)) {
init {
val root = WGridPanel()
setRootPanel(root)
root.setSize(300, 200)
val itemSlot = WItemSlot.of(blockInventory, 0)
root.add(itemSlot, 4, 1)
root.add(this.createPlayerInventoryPanel(), 0, 3)
root.validate(this)
}
companion object {
const val inventorySize: Int = 1
val type: ScreenHandlerType<ProgramWorkstationGuiDescription> =
ScreenHandlerRegistry.registerSimple(ProgramWorkstationBlock.id) { syncId: Int, playerInventory: PlayerInventory ->
ProgramWorkstationGuiDescription(
syncId,
playerInventory,
ScreenHandlerContext.EMPTY
)
}
}
}