aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/data
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-01-28 14:39:42 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-01-28 14:39:42 +0100
commit6173d681603839168db97e3fbd2cb74c2e7a2897 (patch)
tree0dbb3041588c15a85c98a4bb1c98ebba8079d9cd /src/main/java/at/hannibal2/skyhanni/data
parentb24b16da1d19931d6d91e72bcdbebe2acd8968d0 (diff)
downloadskyhanni-6173d681603839168db97e3fbd2cb74c2e7a2897.tar.gz
skyhanni-6173d681603839168db97e3fbd2cb74c2e7a2897.tar.bz2
skyhanni-6173d681603839168db97e3fbd2cb74c2e7a2897.zip
Created EntityClickEvent.
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ClickType.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt24
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