feat: made item name invisible when no Item is held

This commit is contained in:
moonleay 2024-01-31 14:04:34 +01:00
parent 76cf923aec
commit 3d253f6cf9
Signed by: moonleay
GPG key ID: 82667543CCD715FB
3 changed files with 5 additions and 3 deletions

View file

@ -11,7 +11,7 @@ plugins {
id("org.jetbrains.gradle.plugin.idea-ext") id("org.jetbrains.gradle.plugin.idea-ext")
} }
val mavenVersion = System.getenv("CI_COMMIT_TAG") ?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" } ?: "0.4.0-snap" val mavenVersion = System.getenv("CI_COMMIT_TAG") ?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" } ?: "0.4.2-snap"
val modId: String by project val modId: String by project
val modName: String by project val modName: String by project

View file

@ -10,7 +10,8 @@ class MainHandItem: MovableModule("Main Hand item", Category.HUD) {
val playerEntity = MinecraftClient.getInstance().player!! val playerEntity = MinecraftClient.getInstance().player!!
val stack = playerEntity.getStackInHand(Hand.MAIN_HAND) val stack = playerEntity.getStackInHand(Hand.MAIN_HAND)
val itemName = if (stack.item.name.string == "Air") "Empty" else stack.item.name.string val itemName = if (stack.item.name.string == "Air") "Empty" else stack.item.name.string
if(stack.maxDamage == 0) return " x" + stack.count + itemName if (itemName == "Empty") return ""
if(stack.maxDamage == 0) return itemName + " x" + stack.count
return "${itemName} ${stack.maxDamage - stack.damage}/${stack.maxDamage}" return "${itemName} ${stack.maxDamage - stack.damage}/${stack.maxDamage}"
} }
} }

View file

@ -10,7 +10,8 @@ class OffHandItem: MovableModule("Off Hand item", Category.HUD) {
val playerEntity = MinecraftClient.getInstance().player!! val playerEntity = MinecraftClient.getInstance().player!!
val stack = playerEntity.getStackInHand(Hand.OFF_HAND) val stack = playerEntity.getStackInHand(Hand.OFF_HAND)
val itemName = if (stack.item.name.string == "Air") "Empty" else stack.item.name.string val itemName = if (stack.item.name.string == "Air") "Empty" else stack.item.name.string
if(stack.maxDamage == 0) return " x" + stack.count + itemName if (itemName == "Empty") return ""
if(stack.maxDamage == 0) return itemName + " x" + stack.count
return "${itemName} ${stack.maxDamage - stack.damage}/${stack.maxDamage}" return "${itemName} ${stack.maxDamage - stack.damage}/${stack.maxDamage}"
} }
} }