aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-05-22 20:06:36 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-05-22 20:06:36 +0200
commiteb68a59b4670d548fa4c0a493ad1d19029faeb5b (patch)
tree392483a857b584efbd8ea50fbfef9cb387e5e805
parent2e819d59253f91a5453d50cfaca7f998198a338b (diff)
downloadskyhanni-eb68a59b4670d548fa4c0a493ad1d19029faeb5b.tar.gz
skyhanni-eb68a59b4670d548fa4c0a493ad1d19029faeb5b.tar.bz2
skyhanni-eb68a59b4670d548fa4c0a493ad1d19029faeb5b.zip
Use getItemInHand()
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/OdgerWaypoint.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt2
8 files changed, 20 insertions, 20 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt b/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt
index eb6e20590..842cbcfcc 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt
@@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.events.BlockClickEvent
import at.hannibal2.skyhanni.events.EntityClickEvent
import at.hannibal2.skyhanni.events.ItemClickEvent
import at.hannibal2.skyhanni.events.PacketEvent
+import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.toLorenzVec
import net.minecraft.client.Minecraft
@@ -24,13 +25,11 @@ class ItemClickData {
BlockClickEvent(ClickType.RIGHT_CLICK, position, packet.stack).postAndCatch()
}
if (packet is C07PacketPlayerDigging && packet.status == C07PacketPlayerDigging.Action.START_DESTROY_BLOCK) {
- val itemInHand = Minecraft.getMinecraft().thePlayer.heldItem
val position = packet.position.toLorenzVec()
- BlockClickEvent(ClickType.LEFT_CLICK, position, itemInHand).postAndCatch()
+ BlockClickEvent(ClickType.LEFT_CLICK, position, InventoryUtils.getItemInHand()).postAndCatch()
}
if (packet is C0APacketAnimation) {
- val itemInHand = Minecraft.getMinecraft().thePlayer.heldItem
- ItemClickEvent(itemInHand).postAndCatch()
+ ItemClickEvent(InventoryUtils.getItemInHand()).postAndCatch()
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt
index f49bcf1ed..8d26638f4 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt
@@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.InventoryOpenEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.features.bingo.card.CommunityGoal
import at.hannibal2.skyhanni.features.bingo.card.PersonalGoal
+import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
@@ -123,8 +124,7 @@ class BingoCardDisplay {
if (!LorenzUtils.isBingoProfile) return
if (!config.enabled) return
- val stack = Minecraft.getMinecraft().thePlayer.heldItem //TODO into ItemUtils or InventoryUtils
- if (ItemUtils.isSkyBlockMenuItem(stack)) {
+ if (ItemUtils.isSkyBlockMenuItem(InventoryUtils.getItemInHand())) {
val sneaking = Minecraft.getMinecraft().thePlayer.isSneaking
if (lastSneak != sneaking) {
lastSneak = sneaking
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/OdgerWaypoint.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/OdgerWaypoint.kt
index 139b131e4..a41a174a0 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/OdgerWaypoint.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/OdgerWaypoint.kt
@@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.fishing
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
+import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzColor
@@ -41,7 +42,7 @@ class OdgerWaypoint {
}
private fun isLavaFishingRod(): Boolean {
- val heldItem = Minecraft.getMinecraft().thePlayer.heldItem ?: return false
+ val heldItem = InventoryUtils.getItemInHand() ?: return false
val isRod = heldItem.name?.contains("Rod") ?: return false
if (!isRod) return false
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt
index 914774af9..30f95f3e3 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt
@@ -3,11 +3,11 @@ package at.hannibal2.skyhanni.features.fishing
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.SeaCreatureFishEvent
+import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
-import net.minecraft.client.Minecraft
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
@@ -43,7 +43,7 @@ class SharkFishCounter {
}
private fun isWaterFishingRod(): Boolean {
- val heldItem = Minecraft.getMinecraft().thePlayer.heldItem ?: return false
+ val heldItem = InventoryUtils.getItemInHand() ?: return false
val isRod = heldItem.name?.contains("Rod") ?: return false
if (!isRod) return false
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt
index f5d6b7943..34a8e96a3 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt
@@ -12,6 +12,7 @@ import at.hannibal2.skyhanni.features.garden.farming.GardenBestCropTime
import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed
import at.hannibal2.skyhanni.features.garden.inventory.SkyMartCopperPrice
import at.hannibal2.skyhanni.utils.BlockUtils.isBabyCrop
+import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzVec
@@ -91,7 +92,7 @@ object GardenAPI {
}
private fun checkItemInHand() {
- val toolItem = Minecraft.getMinecraft().thePlayer.heldItem
+ val toolItem = InventoryUtils.getItemInHand()
val crop = toolItem?.getCropType()
val newTool = getToolInHand(toolItem, crop)
if (toolInHand != newTool) {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt
index aedcab012..129eba0eb 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt
@@ -12,6 +12,7 @@ import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.features.garden.GardenNextJacobContest
import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getSpeed
import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.isSpeedDataEmpty
+import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList
@@ -24,7 +25,6 @@ import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getReforgeName
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import kotlinx.coroutines.launch
-import net.minecraft.client.Minecraft
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
@@ -107,7 +107,7 @@ object CropMoneyDisplay {
var extraNetherWartPrices = 0.0
GardenAPI.getCurrentlyFarmedCrop()?.let {
- val reforgeName = Minecraft.getMinecraft().thePlayer.heldItem?.getReforgeName()
+ val reforgeName = InventoryUtils.getItemInHand()?.getReforgeName()
toolHasBountiful?.put(it, reforgeName == "bountiful")
if (GardenAPI.mushroomCowPet && it != CropType.MUSHROOM) {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt
index 9a57ddd5e..119351d63 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt
@@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.data.HypixelData
import at.hannibal2.skyhanni.data.ProfileStorageData
import at.hannibal2.skyhanni.data.ScoreboardData
import at.hannibal2.skyhanni.features.garden.GardenAPI.getCropType
+import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.colorCodeToRarity
import at.hannibal2.skyhanni.utils.StringUtils.firstLetterUppercase
@@ -85,12 +86,9 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?)
}),
ITEM({
- val player: net.minecraft.client.entity.EntityPlayerSP = net.minecraft.client.Minecraft.getMinecraft().thePlayer
- if (player.heldItem != null) {
- String.format("Holding ${player.heldItem.displayName.removeColor()}")
- } else {
- "No item in hand"
- }
+ InventoryUtils.getItemInHand()?.let {
+ String.format("Holding ${it.displayName.removeColor()}")
+ } ?: "No item in hand"
}),
TIME({
@@ -162,8 +160,7 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?)
}),
CROP_MILESTONES({
- val item = net.minecraft.client.Minecraft.getMinecraft().thePlayer.heldItem
- val crop = item.getCropType()
+ val crop = InventoryUtils.getItemInHand()?.getCropType()
val cropCounter = crop?.getCounter()
val tier = cropCounter?.let { getTierForCrops(it) }
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt
index b343b878a..4e49f4be2 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt
@@ -64,4 +64,6 @@ object InventoryUtils {
Minecraft.getMinecraft().thePlayer.inventory.armorInventory
fun inStorage() = openInventoryName().let { it.contains("Storage") || it.contains("Ender Chest") || it.contains("Backpack") }
+
+ fun getItemInHand(): ItemStack? = Minecraft.getMinecraft().thePlayer.heldItem
} \ No newline at end of file