package ru.dbotthepony.mc.otm.menu.tech

import net.minecraft.server.level.ServerPlayer
import net.minecraft.world.SimpleContainer
import net.minecraft.world.entity.player.Inventory
import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity
import ru.dbotthepony.mc.otm.menu.MachineOutputSlot
import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu
import ru.dbotthepony.mc.otm.menu.MatterySlot
import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput
import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput
import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget
import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget
import ru.dbotthepony.mc.otm.registry.MMenus

class PlatePressMenu @JvmOverloads constructor(
	containerID: Int,
	inventory: Inventory,
	tile: PlatePressBlockEntity? = null
) : MatteryPoweredMenu(MMenus.PLATE_PRESS, containerID, inventory, tile) {
	val inputSlot = MatterySlot(tile?.inputContainer ?: SimpleContainer(1), 0)
	val outputSlot = MachineOutputSlot(tile?.outputContainer ?: SimpleContainer(1), 0) { tile?.popExperience(ply as ServerPlayer) }

	val progressGauge = ProgressGaugeWidget(this, tile)
	val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig, allowPush = true)
	val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig, allowPull = true)
	val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget)

	val upgrades = makeUpgradeSlots(3, tile?.upgrades)

	init {
		addStorageSlot(inputSlot)
		addStorageSlot(outputSlot)
		addInventorySlots()
	}
}
