diff options
author | Aaron <51387595+AzureAaron@users.noreply.github.com> | 2024-06-20 16:19:18 -0400 |
---|---|---|
committer | Aaron <51387595+AzureAaron@users.noreply.github.com> | 2024-06-20 16:19:18 -0400 |
commit | a750329670683eabc6701f4fead32c2c9e601915 (patch) | |
tree | 045ebe22ea66bbe9d0bd7587009bfdb72bb759bb /src/main | |
parent | d20243d7a4785b5640be6d9c45cb5e2f1faa4e17 (diff) | |
download | Skyblocker-a750329670683eabc6701f4fead32c2c9e601915.tar.gz Skyblocker-a750329670683eabc6701f4fead32c2c9e601915.tar.bz2 Skyblocker-a750329670683eabc6701f4fead32c2c9e601915.zip |
Implement new item-specific LBIN pricing
Diffstat (limited to 'src/main')
3 files changed, 53 insertions, 5 deletions
diff --git a/src/main/java/de/hysky/skyblocker/mixins/ItemStackMixin.java b/src/main/java/de/hysky/skyblocker/mixins/ItemStackMixin.java index 2154c4b5..3abbfbcd 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/ItemStackMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/ItemStackMixin.java @@ -1,10 +1,12 @@ package de.hysky.skyblocker.mixins; -import com.google.gson.JsonObject; +import com.google.gson.JsonParser; import com.llamalad7.mixinextras.injector.ModifyReturnValue; -import de.hysky.skyblocker.SkyblockerMod; +import com.mojang.serialization.JsonOps; + import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.injected.SkyblockerStack; +import de.hysky.skyblocker.skyblock.PetCache.PetInfo; import de.hysky.skyblocker.skyblock.item.tooltip.ItemTooltip; import de.hysky.skyblocker.utils.ItemUtils; import de.hysky.skyblocker.utils.Utils; @@ -165,6 +167,7 @@ public abstract class ItemStackMixin implements ComponentHolder, SkyblockerStack } // Transformation to API format. + //TODO future - remove this and just handle it directly for the NEU id conversion because this whole system is confusing and hard to follow if (customData.contains("is_shiny")) { return "ISSHINY_" + customDataString; } @@ -178,12 +181,14 @@ public abstract class ItemStackMixin implements ComponentHolder, SkyblockerStack return "ENCHANTMENT_" + enchant.toUpperCase(Locale.ENGLISH) + "_" + enchants.getInt(enchant); } } + case "PET" -> { 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(); + PetInfo petInfo = PetInfo.CODEC.parse(JsonOps.INSTANCE, JsonParser.parseString(customData.getString("petInfo"))).getOrThrow(); + return "LVL_1_" + petInfo.tier() + "_" + petInfo.type(); } } + case "POTION" -> { String enhanced = customData.contains("enhanced") ? "_ENHANCED" : ""; String extended = customData.contains("extended") ? "_EXTENDED" : ""; @@ -193,6 +198,7 @@ public abstract class ItemStackMixin implements ComponentHolder, SkyblockerStack + enhanced + extended + splash).toUpperCase(Locale.ENGLISH); } } + case "RUNE" -> { if (customData.contains("runes")) { NbtCompound runes = customData.getCompound("runes"); @@ -201,6 +207,7 @@ public abstract class ItemStackMixin implements ComponentHolder, SkyblockerStack return rune.toUpperCase(Locale.ENGLISH) + "_RUNE_" + runes.getInt(rune); } } + case "ATTRIBUTE_SHARD" -> { if (customData.contains("attributes")) { NbtCompound shards = customData.getCompound("attributes"); @@ -209,6 +216,42 @@ public abstract class ItemStackMixin implements ComponentHolder, SkyblockerStack return customDataString + "-" + shard.toUpperCase(Locale.ENGLISH) + "_" + shards.getInt(shard); } } + + case "NEW_YEAR_CAKE" -> { + return customDataString + "_" + customData.getInt("new_years_cake"); + } + + case "PARTY_HAT_CRAB", "PARTY_HAT_CRAB_ANIMATED", "BALLOON_HAT_2024" -> { + return customDataString + "_" + customData.getString("party_hat_color").toUpperCase(Locale.ENGLISH); + } + + case "PARTY_HAT_SLOTH" -> { + return customDataString + "_" + customData.getString("party_hat_emoji").toUpperCase(Locale.ENGLISH); + } + + case "CRIMSON_HELMET", "CRIMSON_CHESTPLATE", "CRIMSON_LEGGINGS", "CRIMSON_BOOTS" -> { + NbtCompound attributes = customData.getCompound("attributes"); + + if (attributes.contains("magic_find") && attributes.contains("veteran")) { + return customDataString + "-MAGIC_FIND-VETERAN"; + } + } + + case "AURORA_HELMET", "AURORA_CHESTPLATE", "AURORA_LEGGINGS", "AURORA_BOOTS" -> { + NbtCompound attributes = customData.getCompound("attributes"); + + if (attributes.contains("mana_pool") && attributes.contains("mana_regeneration")) { + return customDataString + "-MANA_POOL-MANA_REGENERATION"; + } + } + + case "TERROR_HELMET", "TERROR_CHESTPLATE", "TERROR_LEGGINGS", "TERROR_BOOTS" -> { + NbtCompound attributes = customData.getCompound("attributes"); + + if (attributes.contains("lifeline") && attributes.contains("mana_pool")) { + return customDataString + "-LIFELINE-MANA_POOL"; + } + } } return customDataString; } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/PetCache.java b/src/main/java/de/hysky/skyblocker/skyblock/PetCache.java index 179e4ed3..19714e41 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/PetCache.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/PetCache.java @@ -135,7 +135,7 @@ public class PetCache { } public record PetInfo(String type, double exp, String tier, String uuid) { - private static final Codec<PetInfo> CODEC = RecordCodecBuilder.create(instance -> instance.group( + public static final Codec<PetInfo> CODEC = RecordCodecBuilder.create(instance -> instance.group( Codec.STRING.fieldOf("type").forGetter(PetInfo::type), Codec.DOUBLE.fieldOf("exp").forGetter(PetInfo::exp), Codec.STRING.fieldOf("tier").forGetter(PetInfo::tier), 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 2f5408a1..cc3d2099 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 @@ -52,6 +52,11 @@ public class ItemTooltip { case "POTION" -> apiId = ""; case "ATTRIBUTE_SHARD" -> apiId = id + "+" + apiId.replace("SHARD-", "").replaceAll("_(?!.*_)", ";"); + case "NEW_YEAR_CAKE" -> apiId = id + "+" + apiId.replace("NEW_YEAR_CAKE_", ""); + case "PARTY_HAT_CRAB_ANIMATED" -> apiId = "PARTY_HAT_CRAB_" + apiId.replace("PARTY_HAT_CRAB_ANIMATED_", "") + "_ANIMATED"; + case "CRIMSON_HELMET", "CRIMSON_CHESTPLATE", "CRIMSON_LEGGINGS", "CRIMSON_BOOTS", + "AURORA_HELMET", "AURORA_CHESTPLATE", "AURORA_LEGGINGS", "AURORA_BOOTS", + "TERROR_HELMET", "TERROR_CHESTPLATE", "TERROR_LEGGINGS", "TERROR_BOOTS" -> apiId = id; default -> apiId = apiId.replace(":", "-"); } return apiId; |