Skip to content

Commit

Permalink
Merge branch 'hannibal002:beta' into secret-chime
Browse files Browse the repository at this point in the history
  • Loading branch information
Ovi-111 authored Sep 7, 2024
2 parents ef8ce87 + b6593fc commit 7110af5
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
7 changes: 6 additions & 1 deletion src/main/java/at/hannibal2/skyhanni/data/model/TextInput.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.data.model

import at.hannibal2.skyhanni.utils.KeyboardManager
import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyClicked
import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.OSUtils
import at.hannibal2.skyhanni.utils.StringUtils.insert
Expand Down Expand Up @@ -73,7 +74,11 @@ class TextInput {

fun onGuiInput(ci: CallbackInfo) {
if (activeInstance != null) {
ci.cancel()
if (Keyboard.KEY_ESCAPE.isKeyHeld()) {
disable()
} else {
ci.cancel()
}
return
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ package at.hannibal2.skyhanni.features.misc.items.enchants
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.features.chroma.ChromaManager
import at.hannibal2.skyhanni.utils.ItemCategory
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull
import at.hannibal2.skyhanni.utils.ItemUtils.getItemCategoryOrNull
import at.hannibal2.skyhanni.utils.ItemUtils.itemNameWithoutColor
import at.hannibal2.skyhanni.utils.ItemUtils.itemName
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import com.google.gson.annotations.Expose
import io.github.notenoughupdates.moulconfig.observer.Property
import net.minecraft.item.ItemStack
import java.util.TreeSet
import net.minecraft.item.ItemStack

open class Enchant : Comparable<Enchant> {
@Expose
Expand Down Expand Up @@ -64,7 +66,8 @@ open class Enchant : Comparable<Enchant> {
val config = SkyHanniMod.feature.inventory.enchantParsing

val itemCategory = itemStack?.getItemCategoryOrNull()
val itemName = itemStack?.itemNameWithoutColor
val internalName = itemStack?.getInternalNameOrNull()
val itemName = internalName?.itemName?.removeColor()

if (this.nbtName == "efficiency") {
// If the item is a Stonk, or a non-mining tool with Efficiency 5 (whilst not being a Promising Shovel),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ import at.hannibal2.skyhanni.utils.ItemUtils.isEnchanted
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getEnchantments
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getExtraAttributes
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import java.lang.ArithmeticException
import net.minecraft.event.HoverEvent
import net.minecraft.item.ItemStack
import net.minecraft.util.ChatComponentText
Expand Down Expand Up @@ -202,7 +204,26 @@ object EnchantParser {
val insertEnchants: MutableList<String> = mutableListOf()

// Format enchants based on format config option
formatEnchants(insertEnchants)
try {
formatEnchants(insertEnchants)
} catch (e: ArithmeticException) {
ErrorManager.logErrorWithData(
e,
"Item has enchants in nbt but none were found?",
"item" to currentItem,
"loreList" to loreList,
"nbt" to currentItem?.getExtraAttributes()
)
return
} catch (e: ConcurrentModificationException) {
ErrorManager.logErrorWithData(
e,
"ConcurrentModificationException whilst formatting enchants",
"loreList" to loreList,
"format" to config.format.get(),
"orderedEnchants" to orderedEnchants
)
}

// Add our parsed enchants back into the lore
loreList.addAll(startEnchant, insertEnchants)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ object ItemUtils {
getAttributeFromShard()?.let {
return it.getAttributeName()
}
return getInternalName().itemName
return getInternalNameOrNull()?.itemName ?: "<null>"
}

fun ItemStack.getAttributeFromShard(): Pair<String, Int>? {
Expand Down

0 comments on commit 7110af5

Please sign in to comment.