aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
authorThunderblade73 <85900443+Thunderblade73@users.noreply.github.com>2024-02-05 12:22:12 +0100
committerGitHub <noreply@github.com>2024-02-05 12:22:12 +0100
commit0f8ba9557a058909b071e1c817f3d94b4066f6f7 (patch)
tree7df226f287e3923435491242aed7fe91410af009 /src/main/java/at
parentefc0fc65f2fede6204fa1cd9d3918a2f5d37dd92 (diff)
downloadskyhanni-0f8ba9557a058909b071e1c817f3d94b4066f6f7.tar.gz
skyhanni-0f8ba9557a058909b071e1c817f3d94b4066f6f7.tar.bz2
skyhanni-0f8ba9557a058909b071e1c817f3d94b4066f6f7.zip
Fix: Click Keybinds (Minion Feature) (#971)
Fixed Minion XP calculation not working when having differnt mouse settings. #971
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt19
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt28
2 files changed, 25 insertions, 22 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt b/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt
index f4621877a..4aa796b54 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt
@@ -13,7 +13,6 @@ import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement
import net.minecraft.network.play.client.C0APacketAnimation
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.InputEvent
-import org.lwjgl.input.Mouse
class ItemClickData {
@@ -39,20 +38,24 @@ class ItemClickData {
}
@SubscribeEvent
- fun onEntityClick(event: InputEvent.MouseInputEvent) {
+ fun onEntityClick(event: InputEvent) {
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
+ val attackKey = minecraft.gameSettings.keyBindAttack
+ val useKey = minecraft.gameSettings.keyBindUseItem
+
+ val clickType = when {
+ attackKey.isKeyDown -> ClickType.LEFT_CLICK
+ useKey.isKeyDown -> ClickType.RIGHT_CLICK
else -> return
}
+ val clickedEntity = minecraft.pointedEntity
+ if (minecraft.thePlayer == null) return
+ if (clickedEntity == null) return
+
EntityClickEvent(clickType, clickedEntity).postAndCatch()
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt
index 7cd0d7c9e..3495a35f1 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt
@@ -3,8 +3,11 @@ package at.hannibal2.skyhanni.features.minion
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.config.Storage
+import at.hannibal2.skyhanni.data.ClickType
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.data.ProfileStorageData
+import at.hannibal2.skyhanni.events.BlockClickEvent
+import at.hannibal2.skyhanni.events.EntityClickEvent
import at.hannibal2.skyhanni.events.InventoryCloseEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
import at.hannibal2.skyhanni.events.InventoryUpdatedEvent
@@ -50,11 +53,10 @@ import net.minecraftforge.client.event.RenderLivingEvent
import net.minecraftforge.event.entity.player.PlayerInteractEvent
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-import net.minecraftforge.fml.common.gameevent.InputEvent
-import org.lwjgl.input.Mouse
import java.awt.Color
class MinionFeatures {
+
private val config get() = SkyHanniMod.feature.minions
private var lastClickedEntity: LorenzVec? = null
private var newMinion: LorenzVec? = null
@@ -86,21 +88,19 @@ class MinionFeatures {
}
@SubscribeEvent
- fun onClick(event: InputEvent.MouseInputEvent) {
+ fun onEntityClick(event: EntityClickEvent) {
if (!enableWithHub()) return
+ if (event.clickType != ClickType.RIGHT_CLICK) return
- if (!Mouse.getEventButtonState()) return
- if (Mouse.getEventButton() != 1) return
+ lastClickedEntity = event.clickedEntity?.getLorenzVec() ?: return
+ }
- val minecraft = Minecraft.getMinecraft()
- val entity = minecraft.pointedEntity
- if (entity != null) {
- lastClickedEntity = entity.getLorenzVec()
- return
- }
- minecraft.thePlayer.rayTrace(16.0, 1.0f)?.let {
- lastStorage = it.blockPos.toLorenzVec()
- }
+ @SubscribeEvent
+ fun onBlockClick(event: BlockClickEvent) {
+ if (!enableWithHub()) return
+ if (event.clickType != ClickType.RIGHT_CLICK) return
+
+ lastStorage = event.position
}
@SubscribeEvent