Skip to content

Commit

Permalink
Merge pull request #393 from kevinthegreat1/exotic-tooltip
Browse files Browse the repository at this point in the history
Exotic Tooltip & PriceInfoTooltip Cleanup
  • Loading branch information
kevinthegreat1 authored Oct 30, 2023
2 parents 38039bd + b944188 commit 1389107
Show file tree
Hide file tree
Showing 15 changed files with 426 additions and 178 deletions.
4 changes: 3 additions & 1 deletion src/main/java/de/hysky/skyblocker/SkyblockerMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import de.hysky.skyblocker.skyblock.dungeon.secrets.DungeonSecrets;
import de.hysky.skyblocker.skyblock.dwarven.DwarvenHud;
import de.hysky.skyblocker.skyblock.item.*;
import de.hysky.skyblocker.skyblock.item.tooltip.BackpackPreview;
import de.hysky.skyblocker.skyblock.item.tooltip.ItemTooltip;
import de.hysky.skyblocker.skyblock.itemlist.ItemRepository;
import de.hysky.skyblocker.skyblock.quicknav.QuickNav;
import de.hysky.skyblocker.skyblock.rift.TheRift;
Expand Down Expand Up @@ -73,7 +75,7 @@ public void onInitializeClient() {
NEURepoManager.init();
ItemRepository.init();
HotbarSlotLock.init();
PriceInfoTooltip.init();
ItemTooltip.init();
WikiLookup.init();
FairySouls.init();
Relics.init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public static class General {
public FairySouls fairySouls = new FairySouls();

@SerialEntry
public MythologicalRitual mythologicalRitual = new MythologicalRitual();
public MythologicalRitual mythologicalRitual = new MythologicalRitual();

@SerialEntry
public ItemCooldown itemCooldown = new ItemCooldown();
Expand Down Expand Up @@ -485,6 +485,9 @@ public static class ItemTooltip {

@SerialEntry
public boolean enableMuseumDate = true;

@SerialEntry
public boolean enableExoticTooltip = true;
}

public static class ItemInfoDisplay {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,14 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
newValue -> config.general.itemTooltip.enableMuseumDate = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.itemTooltip.enableExoticTooltip"))
.description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.general.itemTooltip.enableExoticTooltip.@Tooltip")))
.binding(defaults.general.itemTooltip.enableExoticTooltip,
() -> config.general.itemTooltip.enableExoticTooltip,
newValue -> config.general.itemTooltip.enableExoticTooltip = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.build())

//Item Info Display
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
import de.hysky.skyblocker.skyblock.experiment.ExperimentSolver;
import de.hysky.skyblocker.skyblock.experiment.SuperpairsSolver;
import de.hysky.skyblocker.skyblock.experiment.UltrasequencerSolver;
import de.hysky.skyblocker.skyblock.item.*;
import de.hysky.skyblocker.skyblock.item.ItemProtection;
import de.hysky.skyblocker.skyblock.item.ItemRarityBackgrounds;
import de.hysky.skyblocker.skyblock.item.WikiLookup;
import de.hysky.skyblocker.skyblock.item.tooltip.BackpackPreview;
import de.hysky.skyblocker.skyblock.item.tooltip.CompactorDeletorPreview;
import de.hysky.skyblocker.utils.ItemUtils;
import de.hysky.skyblocker.utils.Utils;
import de.hysky.skyblocker.utils.render.gui.ContainerSolver;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package de.hysky.skyblocker.skyblock;

import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.skyblock.item.PriceInfoTooltip;
import de.hysky.skyblocker.skyblock.item.tooltip.ItemTooltip;
import de.hysky.skyblocker.utils.ItemUtils;
import de.hysky.skyblocker.utils.Utils;
import de.hysky.skyblocker.utils.render.RenderHelper;
Expand All @@ -26,7 +26,7 @@ public static void init() {
private static void render(WorldRenderContext wrc) {
if (Utils.isOnSkyblock() && SkyblockerConfigManager.get().general.teleportOverlay.enableTeleportOverlays && client.player != null && client.world != null) {
ItemStack heldItem = client.player.getMainHandStack();
String itemId = PriceInfoTooltip.getInternalNameFromNBT(heldItem, true);
String itemId = ItemTooltip.getInternalNameFromNBT(heldItem, true);
NbtCompound extraAttributes = ItemUtils.getExtraAttributes(heldItem);

if (itemId != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import de.hysky.skyblocker.config.SkyblockerConfig;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.mixin.accessor.ScreenAccessor;
import de.hysky.skyblocker.skyblock.item.PriceInfoTooltip;
import de.hysky.skyblocker.skyblock.item.tooltip.ItemTooltip;
import de.hysky.skyblocker.skyblock.item.tooltip.TooltipInfoType;
import de.hysky.skyblocker.utils.Utils;
import it.unimi.dsi.fastutil.ints.IntBooleanPair;
import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents;
Expand Down Expand Up @@ -54,7 +55,7 @@ public static Text getChestProfit(GenericContainerScreenHandler handler, Text ti

if (!stack.isEmpty()) {
String name = stack.getName().getString();
String id = PriceInfoTooltip.getInternalNameFromNBT(stack, false);
String id = ItemTooltip.getInternalNameFromNBT(stack, false);

//Regular item price
if (id != null) {
Expand Down Expand Up @@ -128,8 +129,8 @@ public static Text getChestProfit(GenericContainerScreenHandler handler, Text ti
* was based on complete data.
*/
private static IntBooleanPair getItemPrice(String id) {
JsonObject bazaarPrices = PriceInfoTooltip.getBazaarPrices();
JsonObject lbinPrices = PriceInfoTooltip.getLBINPrices();
JsonObject bazaarPrices = TooltipInfoType.BAZAAR.getData();
JsonObject lbinPrices = TooltipInfoType.LOWEST_BINS.getData();

if (bazaarPrices == null || lbinPrices == null) return IntBooleanPair.of(0, false);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package de.hysky.skyblocker.skyblock.item;
package de.hysky.skyblocker.skyblock.item.tooltip;

import com.mojang.blaze3d.systems.RenderSystem;
import de.hysky.skyblocker.SkyblockerMod;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.skyblock.item.ItemRarityBackgrounds;
import de.hysky.skyblocker.utils.Utils;
import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents;
import net.minecraft.client.MinecraftClient;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.hysky.skyblocker.skyblock.item;
package de.hysky.skyblocker.skyblock.item.tooltip;

import de.hysky.skyblocker.mixin.accessor.DrawContextInvoker;
import de.hysky.skyblocker.skyblock.itemlist.ItemRepository;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.hysky.skyblocker.skyblock.item;
package de.hysky.skyblocker.skyblock.item.tooltip;

import de.hysky.skyblocker.SkyblockerMod;
import it.unimi.dsi.fastutil.ints.IntIntPair;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package de.hysky.skyblocker.skyblock.item.tooltip;

import de.hysky.skyblocker.utils.Constants;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.StringIdentifiable;

public class ExoticTooltip {
public static String getExpectedHex(String id) {
String color = TooltipInfoType.COLOR.getData().get(id).getAsString();
if (color != null) {
String[] RGBValues = color.split(",");
return String.format("%02X%02X%02X", Integer.parseInt(RGBValues[0]), Integer.parseInt(RGBValues[1]), Integer.parseInt(RGBValues[2]));
} else {
ItemTooltip.LOGGER.warn("[Skyblocker Exotics] No expected color data found for id {}", id);
return null;
}
}

public static boolean isException(String id, String hex) {
if (id.startsWith("LEATHER") || id.equals("GHOST_BOOTS") || Constants.SEYMOUR_IDS.contains(id)) {
return true;
}
if (id.startsWith("RANCHER")) {
return Constants.RANCHERS.contains(hex);
}
if (id.contains("ADAPTIVE_CHESTPLATE")) {
return Constants.ADAPTIVE_CHEST.contains(hex);
} else if (id.contains("ADAPTIVE")) {
return Constants.ADAPTIVE.contains(hex);
}
if (id.startsWith("REAPER")) {
return Constants.REAPER.contains(hex);
}
if (id.startsWith("FAIRY")) {
return Constants.FAIRY_HEXES.contains(hex);
}
if (id.startsWith("CRYSTAL")) {
return Constants.CRYSTAL_HEXES.contains(hex);
}
if (id.contains("SPOOK")) {
return Constants.SPOOK.contains(hex);
}
return false;
}

public static DyeType checkDyeType(String hex) {
if (Constants.CRYSTAL_HEXES.contains(hex)) {
return DyeType.CRYSTAL;
}
if (Constants.FAIRY_HEXES.contains(hex)) {
return DyeType.FAIRY;
}
if (Constants.OG_FAIRY_HEXES.contains(hex)) {
return DyeType.OG_FAIRY;
}
if (Constants.SPOOK.contains(hex)) {
return DyeType.SPOOK;
}
if (Constants.GLITCHED.contains(hex)) {
return DyeType.GLITCHED;
}
return DyeType.EXOTIC;
}

public static boolean intendedDyed(NbtCompound ItemData) {
return ItemData.getCompound("ExtraAttributes").contains("dye_item");
}

public enum DyeType implements StringIdentifiable {
CRYSTAL("crystal", Formatting.AQUA),
FAIRY("fairy", Formatting.LIGHT_PURPLE),
OG_FAIRY("og_fairy", Formatting.DARK_PURPLE),
SPOOK("spook", Formatting.RED),
GLITCHED("glitched", Formatting.BLUE),
EXOTIC("exotic", Formatting.GOLD);
private final String name;
private final Formatting formatting;

DyeType(String name, Formatting formatting) {
this.name = name;
this.formatting = formatting;
}

@Override
public String asString() {
return name;
}

public MutableText getTranslatedText() {
return Text.translatable("skyblocker.exotic." + name).formatted(formatting);
}
}
}
Loading

0 comments on commit 1389107

Please sign in to comment.