blob: a2e4ad2cac7a5e0073aee901e5f4083829a8f29c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
package moe.nea.firmament.util
import com.google.auto.service.AutoService
import net.minecraft.client.gui.screen.ingame.HandledScreen
import net.minecraft.item.ItemStack
import moe.nea.firmament.mixins.accessor.AccessorHandledScreen
import moe.nea.firmament.util.compatloader.CompatLoader
interface HoveredItemStackProvider {
fun provideHoveredItemStack(screen: HandledScreen<*>): ItemStack?
companion object : CompatLoader<HoveredItemStackProvider>(HoveredItemStackProvider::class)
}
@AutoService(HoveredItemStackProvider::class)
class VanillaScreenProvider : HoveredItemStackProvider {
override fun provideHoveredItemStack(screen: HandledScreen<*>): ItemStack? {
screen as AccessorHandledScreen
val vanillaSlot = screen.focusedSlot_Firmament?.stack
return vanillaSlot
}
}
val HandledScreen<*>.focusedItemStack: ItemStack?
get() =
HoveredItemStackProvider.allValidInstances
.firstNotNullOfOrNull { it.provideHoveredItemStack(this) }
|