package ru.dbotthepony.mc.otm.menu.widget

import net.minecraft.server.level.ServerPlayer
import ru.dbotthepony.mc.otm.block.entity.ExperienceStorage
import ru.dbotthepony.mc.otm.menu.MatteryMenu
import java.util.function.DoubleSupplier

class TakeExperienceWidget(menu: MatteryMenu, storage: ExperienceStorage?) {
	val input = menu.oneWayInput { storage!!.popExperience(menu.player as ServerPlayer) }
	val amount = menu.mSynchronizer.computedDouble(DoubleSupplier { storage?.experience ?: 0.0 })
	val maxAmount = menu.mSynchronizer.computedDouble(DoubleSupplier { storage?.maxExperience?.asDouble ?: Double.MAX_VALUE })

	init {
		input.filter { amount.get() >= 1.0 }
	}
}
