diff options
| author | Peyton Brown <81496880+PeytonBrown@users.noreply.github.com> | 2025-06-22 15:01:35 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-22 15:01:35 -0400 |
| commit | b273bbad4b1f5c91f2973f294964c2f979071b98 (patch) | |
| tree | 029984faae16921e0dd0562465692145b7f8d474 /src/main/java | |
| parent | 8d4ce852ecd89ad47afaf4eaa7ead383e081047f (diff) | |
| download | Skyblocker-b273bbad4b1f5c91f2973f294964c2f979071b98.tar.gz Skyblocker-b273bbad4b1f5c91f2973f294964c2f979071b98.tar.bz2 Skyblocker-b273bbad4b1f5c91f2973f294964c2f979071b98.zip | |
Highlights items with attributes (#1369)
* Initial Implementation
* renamed to Legacy Attribute Background
* Change everything to Legacy Attribute Background
Diffstat (limited to 'src/main/java')
4 files changed, 49 insertions, 1 deletions
diff --git a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java index 48784d18..f1ab7eb8 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java @@ -319,6 +319,14 @@ public class GeneralCategory { newValue -> config.general.itemInfoDisplay.jacobMedalBackgrounds = newValue) .controller(ConfigUtils::createBooleanController) .build()) + .option(Option.<Boolean>createBuilder() + .name(Text.translatable("skyblocker.config.general.itemInfoDisplay.legacyAttributeBackgrounds")) + .description(OptionDescription.of(Text.translatable("skyblocker.config.general.itemInfoDisplay.legacyAttributeBackgrounds.@Tooltip"))) + .binding(defaults.general.itemInfoDisplay.legacyAttributeBackgrounds, + () -> config.general.itemInfoDisplay.legacyAttributeBackgrounds, + newValue -> config.general.itemInfoDisplay.legacyAttributeBackgrounds = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) .build()) //Item Protection diff --git a/src/main/java/de/hysky/skyblocker/config/configs/GeneralConfig.java b/src/main/java/de/hysky/skyblocker/config/configs/GeneralConfig.java index b36a2c3f..a4dcbf8c 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/GeneralConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/GeneralConfig.java @@ -206,6 +206,9 @@ public class GeneralConfig { @SerialEntry public boolean jacobMedalBackgrounds = true; + + @SerialEntry + public boolean legacyAttributeBackgrounds = true; } public enum ItemBackgroundStyle { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/background/ItemBackgroundManager.java b/src/main/java/de/hysky/skyblocker/skyblock/item/background/ItemBackgroundManager.java index aa23ef79..88764b5a 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/background/ItemBackgroundManager.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/background/ItemBackgroundManager.java @@ -3,6 +3,7 @@ package de.hysky.skyblocker.skyblock.item.background; import de.hysky.skyblocker.annotations.Init; import de.hysky.skyblocker.skyblock.item.background.adders.ItemRarityBackground; import de.hysky.skyblocker.skyblock.item.background.adders.JacobMedalBackground; +import de.hysky.skyblocker.skyblock.item.background.adders.LegacyAttributeBackground; import de.hysky.skyblocker.utils.scheduler.Scheduler; import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents; import net.minecraft.client.gui.DrawContext; @@ -14,7 +15,8 @@ public class ItemBackgroundManager { private static final List<ColoredItemBackground<?>> BACKGROUNDS = List.of( new ItemRarityBackground(), - new JacobMedalBackground() + new JacobMedalBackground(), + new LegacyAttributeBackground() ); @Init diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/background/adders/LegacyAttributeBackground.java b/src/main/java/de/hysky/skyblocker/skyblock/item/background/adders/LegacyAttributeBackground.java new file mode 100644 index 00000000..1c909a65 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/background/adders/LegacyAttributeBackground.java @@ -0,0 +1,35 @@ +package de.hysky.skyblocker.skyblock.item.background.adders; + +import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.skyblock.item.background.ColoredItemBackground; +import de.hysky.skyblocker.utils.ItemUtils; +import it.unimi.dsi.fastutil.ints.Int2ReferenceOpenHashMap; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.render.RenderLayer; +import net.minecraft.item.ItemStack; + +public class LegacyAttributeBackground extends ColoredItemBackground<Integer> { + private static final int COLOR = 0xFFFF0000; // red + + @Override + public boolean isEnabled() { + return SkyblockerConfigManager.get().general.itemInfoDisplay.legacyAttributeBackgrounds; + } + + @Override + protected Integer getColorKey(ItemStack stack, Int2ReferenceOpenHashMap<Integer> cache) { + if (stack == null || stack.isEmpty() || ItemUtils.getItemId(stack).equals("ATTRIBUTE_SHARD")) return null; + + int hashCode = System.identityHashCode(stack); + if (cache.containsKey(hashCode)) return cache.get(hashCode); + + boolean hasAttributes = ItemUtils.getCustomData(stack).contains("attributes"); + cache.put(hashCode, hasAttributes ? COLOR : null); + return hasAttributes ? COLOR : null; + } + + @Override + protected void draw(DrawContext context, int x, int y, Integer color) { + context.drawSpriteStretched(RenderLayer::getGuiTextured, getSprite(), x, y, 16, 16, color); + } +} |
