aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/events/PlayerInventoryUpdate.kt
blob: 88439a9c5b6ef48fe14d71ed37ef2e5cd090c6d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package moe.nea.firmament.events

import net.minecraft.item.ItemStack

sealed class PlayerInventoryUpdate : FirmamentEvent() {
	companion object : FirmamentEventBus<PlayerInventoryUpdate>()
	data class Single(val slot: Int, val stack: ItemStack) : PlayerInventoryUpdate() {
		override fun getOrNull(slot: Int): ItemStack? {
			if (slot == this.slot) return stack
			return null
		}

	}

	data class Multi(val contents: List<ItemStack>) : PlayerInventoryUpdate() {
		override fun getOrNull(slot: Int): ItemStack? {
			return contents.getOrNull(slot)
		}
	}

	abstract fun getOrNull(slot: Int): ItemStack?
}