diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/ClickType.kt | 5 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt | 24 |
2 files changed, 27 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ClickType.kt b/src/main/java/at/hannibal2/skyhanni/data/ClickType.kt new file mode 100644 index 000000000..06c37d039 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/ClickType.kt @@ -0,0 +1,5 @@ +package at.hannibal2.skyhanni.data + +enum class ClickType { + LEFT_CLICK, RIGHT_CLICK +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt b/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt index 6ce9be7c6..b7dccd76b 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt @@ -1,6 +1,8 @@ package at.hannibal2.skyhanni.data +import at.hannibal2.skyhanni.events.EntityClickEvent import at.hannibal2.skyhanni.events.ItemClickInHandEvent +import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.client.Minecraft import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.InputEvent @@ -13,12 +15,30 @@ class ItemClickData { if (!Mouse.getEventButtonState()) return val clickType = when (Mouse.getEventButton()) { - 0 -> ItemClickInHandEvent.ClickType.LEFT_CLICK - 1 -> ItemClickInHandEvent.ClickType.RIGHT_CLICK + 0 -> ClickType.LEFT_CLICK + 1 -> ClickType.RIGHT_CLICK else -> return } val itemStack = Minecraft.getMinecraft().thePlayer.heldItem ItemClickInHandEvent(clickType, itemStack).postAndCatch() } + + @SubscribeEvent + fun onEntityClick(event: InputEvent.MouseInputEvent) { + if (!LorenzUtils.inSkyBlock) return + + val minecraft = Minecraft.getMinecraft() + val clickedEntity = minecraft.pointedEntity + if (minecraft.thePlayer == null) return + if (clickedEntity == null) return + + val clickType = when (Mouse.getEventButton()) { + 0 -> ClickType.LEFT_CLICK + 1 -> ClickType.RIGHT_CLICK + else -> return + } + + EntityClickEvent(clickType, clickedEntity).postAndCatch() + } }
\ No newline at end of file |