aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
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
parentb24b16da1d19931d6d91e72bcdbebe2acd8968d0 (diff)
downloadskyhanni-6173d681603839168db97e3fbd2cb74c2e7a2897.tar.gz
skyhanni-6173d681603839168db97e3fbd2cb74c2e7a2897.tar.bz2
skyhanni-6173d681603839168db97e3fbd2cb74c2e7a2897.zip
Created EntityClickEvent.
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ClickType.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt24
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/EntityClickEvent.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/ItemClickInHandEvent.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt3
6 files changed, 39 insertions, 10 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
diff --git a/src/main/java/at/hannibal2/skyhanni/events/EntityClickEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/EntityClickEvent.kt
new file mode 100644
index 000000000..56aa97bf7
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/events/EntityClickEvent.kt
@@ -0,0 +1,6 @@
+package at.hannibal2.skyhanni.events
+
+import at.hannibal2.skyhanni.data.ClickType
+import net.minecraft.entity.Entity
+
+class EntityClickEvent(val clickType: ClickType, val clickedEntity: Entity?): LorenzEvent() \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/events/ItemClickInHandEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/ItemClickInHandEvent.kt
index e1271b0a3..a328e599e 100644
--- a/src/main/java/at/hannibal2/skyhanni/events/ItemClickInHandEvent.kt
+++ b/src/main/java/at/hannibal2/skyhanni/events/ItemClickInHandEvent.kt
@@ -1,10 +1,6 @@
package at.hannibal2.skyhanni.events
+import at.hannibal2.skyhanni.data.ClickType
import net.minecraft.item.ItemStack
-class ItemClickInHandEvent(val clickType: ClickType, val itemInHand: ItemStack?): LorenzEvent() {
-
- enum class ClickType {
- LEFT_CLICK, RIGHT_CLICK
- }
-} \ No newline at end of file
+class ItemClickInHandEvent(val clickType: ClickType, val itemInHand: ItemStack?): LorenzEvent() \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt
index c301070af..115d9733b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.features.itemabilities
import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.ClickType
import at.hannibal2.skyhanni.events.ItemClickInHandEvent
import at.hannibal2.skyhanni.events.ReceiveParticleEvent
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
@@ -31,7 +32,7 @@ class FireVeilWandParticles {
@SubscribeEvent
fun onItemClick(event: ItemClickInHandEvent) {
if (!LorenzUtils.inSkyBlock) return
- if (event.clickType != ItemClickInHandEvent.ClickType.RIGHT_CLICK) return
+ if (event.clickType != ClickType.RIGHT_CLICK) return
val itemInHand = event.itemInHand ?: return
diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt
index 66a59d773..b39c85928 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt
@@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.slayer.blaze
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.core.util.render.TextRenderUtils
+import at.hannibal2.skyhanni.data.ClickType
import at.hannibal2.skyhanni.events.ItemClickInHandEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.PacketEvent
@@ -206,7 +207,7 @@ class BlazeSlayerDaggerHelper {
fun onItemClick(event: ItemClickInHandEvent) {
if (!isEnabled()) return
if (clientSideClicked) return
- if (event.clickType != ItemClickInHandEvent.ClickType.RIGHT_CLICK) return
+ if (event.clickType != ClickType.RIGHT_CLICK) return
val itemInHand = event.itemInHand ?: return
val dagger = getDaggerFromStack(itemInHand)