From eb68a59b4670d548fa4c0a493ad1d19029faeb5b Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Mon, 22 May 2023 20:06:36 +0200 Subject: Use getItemInHand() --- .../skyhanni/features/misc/discordrpc/DiscordStatus.kt | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/features/misc') 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?) }), 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?) }), 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) } -- cgit