aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/events/PlayerInventoryUpdate.kt
blob: 99bce9bf99b832425ee414d639a655035db21eb8 (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.world.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?
}