diff options
author | Kevin <92656833+kevinthegreat1@users.noreply.github.com> | 2024-06-15 16:26:19 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-15 04:26:19 -0400 |
commit | 37d4d758844ee8b183338966e3efc2f36a2ca672 (patch) | |
tree | 8f0211a322901d22d3cbd1f1a4aff6a3f25085cd | |
parent | e825fbae40201cc74a78ba5f84371ad0b6dfa088 (diff) | |
download | Skyblocker-37d4d758844ee8b183338966e3efc2f36a2ca672.tar.gz Skyblocker-37d4d758844ee8b183338966e3efc2f36a2ca672.tar.bz2 Skyblocker-37d4d758844ee8b183338966e3efc2f36a2ca672.zip |
Add docs to ItemTooltip#getNeuName and ItemRepository#getItemStack (#772)
Fix farming hud icon stack id
3 files changed, 25 insertions, 15 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHudWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHudWidget.java index eb444813..d081910d 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHudWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHudWidget.java @@ -1,6 +1,7 @@ package de.hysky.skyblocker.skyblock.garden; import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.skyblock.item.tooltip.ItemTooltip; import de.hysky.skyblocker.skyblock.itemlist.ItemRepository; import de.hysky.skyblocker.skyblock.tabhud.util.Ico; import de.hysky.skyblocker.skyblock.tabhud.widget.Widget; @@ -62,7 +63,7 @@ public class FarmingHudWidget extends Widget { ItemStack farmingToolStack = client.player.getMainHandStack(); if (farmingToolStack == null) return; String cropItemId = FARMING_TOOLS.get(ItemUtils.getItemId(farmingToolStack)); - ItemStack cropStack = ItemRepository.getItemStack(cropItemId); + ItemStack cropStack = ItemRepository.getItemStack(ItemTooltip.getNeuName(cropItemId, cropItemId)); // The cropItemId is being used as the api id in the second parameter because the skyblock id and api id are the same for all crops. addSimpleIcoText(cropStack, FarmingHud.counterText(), Formatting.YELLOW, FarmingHud.NUMBER_FORMAT.format(FarmingHud.counter())); float cropsPerMinute = FarmingHud.cropsPerMinute(); 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 e6a364e4..dd8fdfc3 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 @@ -23,16 +23,22 @@ public class ItemTooltip { public static final GeneralConfig.ItemTooltip config = SkyblockerConfigManager.get().general.itemTooltip; private static volatile boolean sentNullWarning = false; + /** + * Gets the NEU id from an id and an api id. + * @param id the id of the skyblock item, gotten from {@link de.hysky.skyblocker.utils.ItemUtils#getItemId(net.minecraft.item.ItemStack) ItemUtils#getItemId(ItemStack)} or {@link net.minecraft.item.ItemStack#getSkyblockId() ItemStack#getSkyblockId()} + * @param apiId the api id of the skyblock item, matching the id of the item on the Skyblocker api, gotten from {@link net.minecraft.item.ItemStack#getSkyblockApiId() ItemStack#getSkyblockApiId()} + * @return the NEU id of the skyblock item, matching the id of the item gotten from {@link io.github.moulberry.repo.data.NEUItem#getSkyblockItemId() NEUItem#getSkyblockItemId()} or {@link net.minecraft.item.ItemStack#getNeuName() ItemStack#getNeuName()} + */ @NotNull - public static String getNeuName(String internalID, String neuName) { - switch (internalID) { + public static String getNeuName(String id, String apiId) { + switch (id) { case "PET" -> { - neuName = neuName.replaceAll("LVL_\\d*_", ""); - String[] parts = neuName.split("_"); + apiId = apiId.replaceAll("LVL_\\d*_", ""); + String[] parts = apiId.split("_"); String type = parts[0]; - neuName = neuName.replaceAll(type + "_", ""); - neuName = neuName + "-" + type; - neuName = neuName.replace("UNCOMMON", "1") + apiId = apiId.replaceAll(type + "_", ""); + apiId = apiId + "-" + type; + apiId = apiId.replace("UNCOMMON", "1") .replace("COMMON", "0") .replace("RARE", "2") .replace("EPIC", "3") @@ -40,13 +46,13 @@ public class ItemTooltip { .replace("MYTHIC", "5") .replace("-", ";"); } - case "RUNE" -> neuName = neuName.replaceAll("_(?!.*_)", ";"); - case "POTION" -> neuName = ""; + case "RUNE" -> apiId = apiId.replaceAll("_(?!.*_)", ";"); + case "POTION" -> apiId = ""; case "ATTRIBUTE_SHARD" -> - neuName = internalID + "+" + neuName.replace("SHARD-", "").replaceAll("_(?!.*_)", ";"); - default -> neuName = neuName.replace(":", "-"); + apiId = id + "+" + apiId.replace("SHARD-", "").replaceAll("_(?!.*_)", ";"); + default -> apiId = apiId.replace(":", "-"); } - return neuName; + return apiId; } public static void nullWarning() { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/itemlist/ItemRepository.java b/src/main/java/de/hysky/skyblocker/skyblock/itemlist/ItemRepository.java index 5ac0ba8d..b9e45af1 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/itemlist/ItemRepository.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/itemlist/ItemRepository.java @@ -114,9 +114,12 @@ public class ItemRepository { return items.stream(); } + /** + * @param neuId the NEU item id gotten through {@link NEUItem#getSkyblockItemId()}, {@link ItemStack#getNeuName()}, or {@link de.hysky.skyblocker.skyblock.item.tooltip.ItemTooltip#getNeuName(String, String) ItemTooltip#getNeuName(String, String)} + */ @Nullable - public static ItemStack getItemStack(String internalName) { - return itemsMap.get(internalName); + public static ItemStack getItemStack(String neuId) { + return itemsMap.get(neuId); } public static Stream<SkyblockCraftingRecipe> getRecipesStream() { |