package ru.dbotthepony.mc.otm.menu.storage

import net.minecraft.world.entity.player.Inventory
import ru.dbotthepony.mc.otm.block.entity.storage.StoragePowerSupplierBlockEntity
import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu
import ru.dbotthepony.mc.otm.registry.MMenus

class StoragePowerSupplierMenu @JvmOverloads constructor(
	p_38852_: Int,
	inventory: Inventory,
	tile: StoragePowerSupplierBlockEntity? = null
) : MatteryPoweredMenu(MMenus.STORAGE_POWER_SUPPLIER, p_38852_, inventory, tile)  {
	var totalTransferred by mSynchronizer.decimal()
	var activeNodes by mSynchronizer.int()

	init {
		addStorageSlot(batterySlot)
		addInventorySlots()
	}

	override fun broadcastChanges() {
		if (tile is StoragePowerSupplierBlockEntity) {
			totalTransferred = tile.powerPassed
			activeNodes = tile.cell.graph.powerDemandingNodes.size
		}

		super.broadcastChanges()
	}
}
