aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt
blob: 6ce9be7c6a86f4b4ce2d947ee37536bf97c49447 (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
package at.hannibal2.skyhanni.data

import at.hannibal2.skyhanni.events.ItemClickInHandEvent
import net.minecraft.client.Minecraft
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.InputEvent
import org.lwjgl.input.Mouse

class ItemClickData {

    @SubscribeEvent
    fun onClick(event: InputEvent.MouseInputEvent) {
        if (!Mouse.getEventButtonState()) return

        val clickType = when (Mouse.getEventButton()) {
            0 -> ItemClickInHandEvent.ClickType.LEFT_CLICK
            1 -> ItemClickInHandEvent.ClickType.RIGHT_CLICK
            else -> return
        }

        val itemStack = Minecraft.getMinecraft().thePlayer.heldItem
        ItemClickInHandEvent(clickType, itemStack).postAndCatch()
    }
}