diff options
author | Aaron <51387595+AzureAaron@users.noreply.github.com> | 2024-04-23 12:15:49 -0400 |
---|---|---|
committer | Aaron <51387595+AzureAaron@users.noreply.github.com> | 2024-04-26 16:23:21 -0400 |
commit | 330f8286d4e925f9a5c7ae5629e979edaf948363 (patch) | |
tree | d4b435e1596d7a73410cc945d5e7085b1cb62ac4 /src/main/java/de/hysky/skyblocker/skyblock | |
parent | 07f6469fffac314ac529794e159b266bc49fc6af (diff) | |
download | Skyblocker-330f8286d4e925f9a5c7ae5629e979edaf948363.tar.gz Skyblocker-330f8286d4e925f9a5c7ae5629e979edaf948363.tar.bz2 Skyblocker-330f8286d4e925f9a5c7ae5629e979edaf948363.zip |
Handle removal/flattening of the ExtraAttributes tag
The tag doesn't exist anymore, the data is no longer "nested" under it.
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/skyblock')
4 files changed, 37 insertions, 40 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/TeleportOverlay.java b/src/main/java/de/hysky/skyblocker/skyblock/TeleportOverlay.java index bc0eede8..392360e7 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/TeleportOverlay.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/TeleportOverlay.java @@ -28,7 +28,7 @@ public class TeleportOverlay { if (Utils.isOnSkyblock() && SkyblockerConfigManager.get().general.teleportOverlay.enableTeleportOverlays && client.player != null && client.world != null) { ItemStack heldItem = client.player.getMainHandStack(); String itemId = ItemTooltip.getInternalNameFromNBT(heldItem, true); - NbtCompound extraAttributes = ItemUtils.getExtraAttributes(heldItem); + NbtCompound customData = ItemUtils.getCustomData(heldItem); if (itemId != null) { switch (itemId) { @@ -43,20 +43,20 @@ public class TeleportOverlay { } } case "ASPECT_OF_THE_END", "ASPECT_OF_THE_VOID" -> { - if (SkyblockerConfigManager.get().general.teleportOverlay.enableEtherTransmission && client.options.sneakKey.isPressed() && extraAttributes != null && extraAttributes.getInt("ethermerge") == 1) { - render(wrc, extraAttributes, 57); + if (SkyblockerConfigManager.get().general.teleportOverlay.enableEtherTransmission && client.options.sneakKey.isPressed() && customData != null && customData.getInt("ethermerge") == 1) { + render(wrc, customData, 57); } else if (SkyblockerConfigManager.get().general.teleportOverlay.enableInstantTransmission) { - render(wrc, extraAttributes, 8); + render(wrc, customData, 8); } } case "ETHERWARP_CONDUIT" -> { if (SkyblockerConfigManager.get().general.teleportOverlay.enableEtherTransmission) { - render(wrc, extraAttributes, 57); + render(wrc, customData, 57); } } case "SINSEEKER_SCYTHE" -> { if (SkyblockerConfigManager.get().general.teleportOverlay.enableSinrecallTransmission) { - render(wrc, extraAttributes, 4); + render(wrc, customData, 4); } } case "NECRON_BLADE", "ASTRAEA", "HYPERION", "SCYLLA", "VALKYRIE" -> { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/CompactorDeletorPreview.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/CompactorDeletorPreview.java index 657db0c9..392ee100 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/CompactorDeletorPreview.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/CompactorDeletorPreview.java @@ -40,10 +40,9 @@ public class CompactorDeletorPreview { if (targetIndex == -1) return false; // Get items in compactor or deletor - NbtCompound extraAttributes = ItemUtils.getExtraAttributes(stack); - if (extraAttributes == null) return false; + NbtCompound customData = ItemUtils.getCustomData(stack); // Get the slots and their items from the nbt, which is in the format personal_compact_<slot_number> or personal_deletor_<slot_number> - List<IntObjectPair<ItemStack>> slots = extraAttributes.getKeys().stream().filter(slot -> slot.contains(type.toLowerCase().substring(0, 7))).map(slot -> IntObjectPair.of(Integer.parseInt(slot.substring(17)), ItemRepository.getItemStack(extraAttributes.getString(slot)))).toList(); + List<IntObjectPair<ItemStack>> slots = customData.getKeys().stream().filter(slot -> slot.contains(type.toLowerCase().substring(0, 7))).map(slot -> IntObjectPair.of(Integer.parseInt(slot.substring(17)), ItemRepository.getItemStack(customData.getString(slot)))).toList(); List<TooltipComponent> components = tooltips.stream().map(Text::asOrderedText).map(TooltipComponent::of).collect(Collectors.toList()); IntIntPair dimensions = DIMENSIONS.getOrDefault(size, DEFAULT_DIMENSION); @@ -60,9 +59,9 @@ public class CompactorDeletorPreview { // Add the preview tooltip component components.add(targetIndex, new CompactorPreviewTooltipComponent(slots, dimensions)); - if (extraAttributes.contains("PERSONAL_DELETOR_ACTIVE")) { + if (customData.contains("PERSONAL_DELETOR_ACTIVE")) { components.add(targetIndex, TooltipComponent.of(Text.literal("Active: ") - .append(extraAttributes.getBoolean("PERSONAL_DELETOR_ACTIVE") ? Text.literal("YES").formatted(Formatting.BOLD).formatted(Formatting.GREEN) : Text.literal("NO").formatted(Formatting.BOLD).formatted(Formatting.RED)).asOrderedText())); + .append(customData.getBoolean("PERSONAL_DELETOR_ACTIVE") ? Text.literal("YES").formatted(Formatting.BOLD).formatted(Formatting.GREEN) : Text.literal("NO").formatted(Formatting.BOLD).formatted(Formatting.RED)).asOrderedText())); } ((DrawContextInvoker) context).invokeDrawTooltip(client.textRenderer, components, x, y, HoveredTooltipPositioner.INSTANCE); return true; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ItemTooltip.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ItemTooltip.java index 16d64707..d4d34e0f 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ItemTooltip.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ItemTooltip.java @@ -140,17 +140,17 @@ public class ItemTooltip { }); if (SkyblockerConfigManager.get().general.dungeonQuality) { - NbtCompound ea = ItemUtils.getExtraAttributes(stack); - if (ea != null && ea.contains("baseStatBoostPercentage")) { - int baseStatBoostPercentage = ea.getInt("baseStatBoostPercentage"); + NbtCompound customData = ItemUtils.getCustomData(stack); + if (customData != null && customData.contains("baseStatBoostPercentage")) { + int baseStatBoostPercentage = customData.getInt("baseStatBoostPercentage"); boolean maxQuality = baseStatBoostPercentage == 50; if (maxQuality) { lines.add(Text.literal(String.format("%-17s", "Item Quality:") + baseStatBoostPercentage + "/50").formatted(Formatting.RED).formatted(Formatting.BOLD)); } else { lines.add(Text.literal(String.format("%-21s", "Item Quality:") + baseStatBoostPercentage + "/50").formatted(Formatting.BLUE)); } - if (ea.contains("item_tier")) { // sometimes it just isn't here? - int itemTier = ea.getInt("item_tier"); + if (customData.contains("item_tier")) { // sometimes it just isn't here? + int itemTier = customData.getInt("item_tier"); if (maxQuality) { lines.add(Text.literal(String.format("%-17s", "Floor Tier:") + itemTier + " (" + itemTierFloors.get(itemTier) + ")").formatted(Formatting.RED).formatted(Formatting.BOLD)); } else { @@ -189,8 +189,8 @@ public class ItemTooltip { lines.add(Text.literal(String.format(format, "Museum: (" + itemCategory + ")")) .formatted(Formatting.LIGHT_PURPLE)); } else { - NbtCompound extraAttributes = ItemUtils.getExtraAttributes(stack); - boolean isInMuseum = (extraAttributes.contains("donated_museum") && extraAttributes.getBoolean("donated_museum")) || MuseumItemCache.hasItemInMuseum(internalID); + NbtCompound customData = ItemUtils.getCustomData(stack); + boolean isInMuseum = (customData.contains("donated_museum") && customData.getBoolean("donated_museum")) || MuseumItemCache.hasItemInMuseum(internalID); Formatting donatedIndicatorFormatting = isInMuseum ? Formatting.GREEN : Formatting.RED; @@ -216,13 +216,13 @@ public class ItemTooltip { if (existingTooltip.startsWith("Color: ")) { correctLine = true; - addExoticTooltip(lines, internalID, ItemUtils.getCustomData(stack).copyNbt(), colorHex, expectedHex, existingTooltip); + addExoticTooltip(lines, internalID, ItemUtils.getCustomData(stack), colorHex, expectedHex, existingTooltip); break; } } if (!correctLine) { - addExoticTooltip(lines, internalID, ItemUtils.getCustomData(stack).copyNbt(), colorHex, expectedHex, ""); + addExoticTooltip(lines, internalID, ItemUtils.getCustomData(stack), colorHex, expectedHex, ""); } } } @@ -291,57 +291,57 @@ public class ItemTooltip { // TODO What in the world is this? public static String getInternalNameFromNBT(ItemStack stack, boolean internalIDOnly) { - NbtCompound ea = ItemUtils.getExtraAttributes(stack); + NbtCompound customData = ItemUtils.getCustomData(stack); - if (ea == null || !ea.contains(ItemUtils.ID, NbtElement.STRING_TYPE)) { + if (customData == null || !customData.contains(ItemUtils.ID, NbtElement.STRING_TYPE)) { return null; } - String internalName = ea.getString(ItemUtils.ID); + String internalName = customData.getString(ItemUtils.ID); if (internalIDOnly) { return internalName; } // Transformation to API format. - if (ea.contains("is_shiny")) { + if (customData.contains("is_shiny")) { return "ISSHINY_" + internalName; } switch (internalName) { case "ENCHANTED_BOOK" -> { - if (ea.contains("enchantments")) { - NbtCompound enchants = ea.getCompound("enchantments"); + if (customData.contains("enchantments")) { + NbtCompound enchants = customData.getCompound("enchantments"); Optional<String> firstEnchant = enchants.getKeys().stream().findFirst(); String enchant = firstEnchant.orElse(""); return "ENCHANTMENT_" + enchant.toUpperCase(Locale.ENGLISH) + "_" + enchants.getInt(enchant); } } case "PET" -> { - if (ea.contains("petInfo")) { - JsonObject petInfo = SkyblockerMod.GSON.fromJson(ea.getString("petInfo"), JsonObject.class); + if (customData.contains("petInfo")) { + JsonObject petInfo = SkyblockerMod.GSON.fromJson(customData.getString("petInfo"), JsonObject.class); return "LVL_1_" + petInfo.get("tier").getAsString() + "_" + petInfo.get("type").getAsString(); } } case "POTION" -> { - String enhanced = ea.contains("enhanced") ? "_ENHANCED" : ""; - String extended = ea.contains("extended") ? "_EXTENDED" : ""; - String splash = ea.contains("splash") ? "_SPLASH" : ""; - if (ea.contains("potion") && ea.contains("potion_level")) { - return (ea.getString("potion") + "_" + internalName + "_" + ea.getInt("potion_level") + String enhanced = customData.contains("enhanced") ? "_ENHANCED" : ""; + String extended = customData.contains("extended") ? "_EXTENDED" : ""; + String splash = customData.contains("splash") ? "_SPLASH" : ""; + if (customData.contains("potion") && customData.contains("potion_level")) { + return (customData.getString("potion") + "_" + internalName + "_" + customData.getInt("potion_level") + enhanced + extended + splash).toUpperCase(Locale.ENGLISH); } } case "RUNE" -> { - if (ea.contains("runes")) { - NbtCompound runes = ea.getCompound("runes"); + if (customData.contains("runes")) { + NbtCompound runes = customData.getCompound("runes"); Optional<String> firstRunes = runes.getKeys().stream().findFirst(); String rune = firstRunes.orElse(""); return rune.toUpperCase(Locale.ENGLISH) + "_RUNE_" + runes.getInt(rune); } } case "ATTRIBUTE_SHARD" -> { - if (ea.contains("attributes")) { - NbtCompound shards = ea.getCompound("attributes"); + if (customData.contains("attributes")) { + NbtCompound shards = customData.getCompound("attributes"); Optional<String> firstShards = shards.getKeys().stream().findFirst(); String shard = firstShards.orElse(""); return internalName + "-" + shard.toUpperCase(Locale.ENGLISH) + "_" + shards.getInt(shard); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/itemlist/ItemStackBuilder.java b/src/main/java/de/hysky/skyblocker/skyblock/itemlist/ItemStackBuilder.java index 19f89d3c..186d52b4 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/itemlist/ItemStackBuilder.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/itemlist/ItemStackBuilder.java @@ -48,11 +48,9 @@ public class ItemStackBuilder { // Create & Attach ExtraAttributes tag NbtCompound customData = new NbtCompound(); - NbtCompound extraAttributes = new NbtCompound(); - customData.put(ItemUtils.EXTRA_ATTRIBUTES, extraAttributes); // Add Skyblock Item Id - extraAttributes.put(ItemUtils.ID, NbtString.of(internalName)); + customData.put(ItemUtils.ID, NbtString.of(internalName)); // Item Name String name = injectData(item.getDisplayName(), injectors); |