package ru.dbotthepony.mc.otm.menu

import net.minecraft.world.inventory.MenuType
import net.minecraft.world.entity.player.Inventory
import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity
import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
import net.minecraft.world.SimpleContainer
import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting
import ru.dbotthepony.mc.otm.capability.matteryEnergy
import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback

abstract class MatteryPoweredMenu protected constructor(
	menuType: MenuType<*>,
	containerID: Int,
	inventory: Inventory,
	tile: MatteryPoweredBlockEntity? = null
) : MatteryMenu(menuType, containerID, inventory, tile) {
	val energyWidget = LevelGaugeWidget(this, tile?.matteryEnergy)
	val batterySlot = BatterySlot(tile?.batteryContainer ?: SimpleContainer(1), 0)
	val redstoneConfig = EnumInputWithFeedback<RedstoneSetting>(this)

	init {
		if (tile != null) {
			redstoneConfig.with(tile.redstoneControl::redstoneSetting)
		}

		addSlot(batterySlot)
		mapQuickMoveToInventory(batterySlot)
	}
}
