Skip to content

Commit 59bbf91

Browse files
Charzard4261biscuut
authored andcommitted
Add base stat boost percentage display by @Charzard4271
1 parent 50a811a commit 59bbf91

7 files changed

Lines changed: 93 additions & 38 deletions

File tree

src/main/java/codes/biscuit/skyblockaddons/core/Feature.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
import codes.biscuit.skyblockaddons.SkyblockAddons;
44
import codes.biscuit.skyblockaddons.gui.buttons.ButtonLocation;
5-
import codes.biscuit.skyblockaddons.utils.objects.IntPair;
5+
import codes.biscuit.skyblockaddons.utils.ColorCode;
66
import codes.biscuit.skyblockaddons.utils.EnumUtils;
77
import codes.biscuit.skyblockaddons.utils.objects.FloatPair;
8-
import codes.biscuit.skyblockaddons.utils.ColorCode;
8+
import codes.biscuit.skyblockaddons.utils.objects.IntPair;
99
import com.google.common.collect.Sets;
1010
import lombok.Getter;
1111
import net.minecraft.client.Minecraft;
@@ -129,6 +129,8 @@ public enum Feature {
129129
MAP_ZOOM(-1, Message.SETTING_MAP_ZOOM, false),
130130
MAKE_DROPPED_ITEMS_GLOW(102, Message.SETTING_GLOWING_DROPPED_ITEMS, false),
131131
MAKE_DUNGEON_TEAMMATES_GLOW(103, Message.SETTING_GLOWING_DUNGEON_TEAMMATES, false),
132+
SHOW_BASE_STAT_BOOST_PERCENTAGE(104, Message.SETTING_SHOW_BASE_STAT_BOOST_PERCENTAGE, new GuiFeatureData(ColorCode.RED, true), false, EnumUtils.FeatureSetting.COLOUR_BY_RARITY),
133+
SHOW_BASE_STAT_BOOST_PERCENTAGE_COLOUR_BY_RARITY(105, Message.SETTING_COLOR_BY_RARITY, null, true),
132134

133135
WARNING_TIME(-1, Message.SETTING_WARNING_DURATION, false),
134136

@@ -160,7 +162,7 @@ public enum Feature {
160162
MAKE_BACKPACK_INVENTORIES_COLORED, CHANGE_BAR_COLOR_FOR_POTIONS, ENABLE_MESSAGE_WHEN_BREAKING_STEMS,
161163
ENABLE_MESSAGE_WHEN_MINING_DEEP_CAVERNS, ENABLE_MESSAGE_WHEN_MINING_NETHER, HIDE_NIGHT_VISION_EFFECT_TIMER,
162164
CAKE_BAG_PREVIEW, BACKPACK_PREVIEW_AH, REPEAT_FULL_INVENTORY_WARNING, SORT_TAB_EFFECT_TIMERS, DOUBLE_WARP,
163-
REPEAT_SLAYER_BOSS_WARNING, ROTATE_MAP, CENTER_ROTATION_ON_PLAYER, MAP_ZOOM);
165+
REPEAT_SLAYER_BOSS_WARNING, ROTATE_MAP, CENTER_ROTATION_ON_PLAYER, MAP_ZOOM, SHOW_BASE_STAT_BOOST_PERCENTAGE_COLOUR_BY_RARITY);
164166

165167
/**
166168
* Features that are considered gui ones. This is used for examnple when saving the config to ensure that these features'

src/main/java/codes/biscuit/skyblockaddons/core/Message.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ public enum Message {
134134
SETTING_MAP_ZOOM(MessageObject.SETTING, "mapZoom"),
135135
SETTING_GLOWING_DROPPED_ITEMS(MessageObject.SETTING, "glowingDroppedItems"),
136136
SETTING_GLOWING_DUNGEON_TEAMMATES(MessageObject.SETTING, "glowingDungeonTeammates"),
137+
SETTING_SHOW_BASE_STAT_BOOST_PERCENTAGE(MessageObject.SETTING, "baseStatBoostPercentage"),
138+
SETTING_COLOR_BY_RARITY(MessageObject.SETTING, "colorByRarity"),
137139

138140
BACKPACK_STYLE_REGULAR(MessageObject.BACKPACK_STYLE, "regular"),
139141
BACKPACK_STYLE_COMPACT(MessageObject.BACKPACK_STYLE, "compact"),

src/main/java/codes/biscuit/skyblockaddons/gui/SettingsGui.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,15 @@ public void sliderUpdated(float value) {
372372
main.getConfigValues().getMapZoom().setValue(value);
373373
}
374374
}).setPrefix("Map Zoom: "));
375+
} else if (setting == EnumUtils.FeatureSetting.COLOUR_BY_RARITY) {
376+
boxWidth = 31;
377+
x = halfWidth - boxWidth / 2;
378+
y = this.getRowHeightSetting(this.row);
379+
Feature settingFeature = null;
380+
if (this.feature == Feature.SHOW_BASE_STAT_BOOST_PERCENTAGE) {
381+
settingFeature = Feature.SHOW_BASE_STAT_BOOST_PERCENTAGE_COLOUR_BY_RARITY;
382+
}
383+
buttonList.add(new ButtonToggleTitle(x, y, Message.SETTING_COLOR_BY_RARITY.getMessage(), this.main, settingFeature));
375384
} else {
376385
boxWidth = 31; // Default size and stuff.
377386
x = halfWidth-(boxWidth/2);

src/main/java/codes/biscuit/skyblockaddons/listeners/PlayerListener.java

Lines changed: 51 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
package codes.biscuit.skyblockaddons.listeners;
22

33
import codes.biscuit.skyblockaddons.SkyblockAddons;
4-
import codes.biscuit.skyblockaddons.core.Attribute;
5-
import codes.biscuit.skyblockaddons.core.Feature;
6-
import codes.biscuit.skyblockaddons.core.Location;
7-
import codes.biscuit.skyblockaddons.core.Message;
4+
import codes.biscuit.skyblockaddons.core.*;
5+
import codes.biscuit.skyblockaddons.features.BaitManager;
86
import codes.biscuit.skyblockaddons.features.EnchantedItemBlacklist;
97
import codes.biscuit.skyblockaddons.features.EndstoneProtectorManager;
108
import codes.biscuit.skyblockaddons.features.backpacks.Backpack;
119
import codes.biscuit.skyblockaddons.features.backpacks.BackpackManager;
12-
import codes.biscuit.skyblockaddons.features.BaitManager;
1310
import codes.biscuit.skyblockaddons.features.cooldowns.CooldownManager;
1411
import codes.biscuit.skyblockaddons.features.powerorbs.PowerOrbManager;
1512
import codes.biscuit.skyblockaddons.features.tabtimers.TabEffectManager;
@@ -692,28 +689,6 @@ public void onItemTooltip(ItemTooltipEvent e) {
692689
}
693690
}
694691

695-
if (main.getConfigValues().isEnabled(Feature.SHOW_ITEM_ANVIL_USES)) {
696-
// Anvil Uses ~ original done by Dahn#6036
697-
int anvilUses = main.getUtils().getNBTInteger(hoveredItem, "ExtraAttributes", "anvil_uses");
698-
if (anvilUses != -1) {
699-
int insertAt = e.toolTip.size();
700-
insertAt--; // 1 line for the rarity
701-
if (Minecraft.getMinecraft().gameSettings.advancedItemTooltips) {
702-
insertAt -= 2; // 1 line for the item name, and 1 line for the nbt
703-
if (e.itemStack.isItemDamaged()) {
704-
insertAt--; // 1 line for damage
705-
}
706-
}
707-
int hotPotatoCount = main.getUtils().getNBTInteger(hoveredItem, "ExtraAttributes", "hot_potato_count");
708-
if (hotPotatoCount != -1) {
709-
anvilUses -= hotPotatoCount;
710-
}
711-
if (anvilUses > 0) {
712-
e.toolTip.add(insertAt, Message.MESSAGE_ANVIL_USES.getMessage(String.valueOf(anvilUses)));
713-
}
714-
}
715-
}
716-
717692
if (main.getConfigValues().isEnabled(Feature.REPLACE_ROMAN_NUMERALS_WITH_NUMBERS)) {
718693
for (int i = 0; i < e.toolTip.size(); i++) {
719694
e.toolTip.set(i, RomanNumeralParser.replaceNumeralsWithIntegers(e.toolTip.get(i)));
@@ -762,12 +737,26 @@ public void onItemTooltip(ItemTooltipEvent e) {
762737
}
763738
}
764739

765-
// Append Skyblock Item ID to end of tooltip if in developer mode
766-
if (main.isDevMode() && e.showAdvancedItemTooltips) {
767-
String itemId = ItemUtils.getSkyBlockItemID(e.itemStack);
740+
int insertAt = e.toolTip.size();
741+
insertAt--; // 1 line for the rarity
742+
if (Minecraft.getMinecraft().gameSettings.advancedItemTooltips) {
743+
insertAt -= 2; // 1 line for the item name, and 1 line for the nbt
744+
if (e.itemStack.isItemDamaged()) {
745+
insertAt--; // 1 line for damage
746+
}
747+
}
768748

769-
if (itemId != null) {
770-
e.toolTip.add(EnumChatFormatting.DARK_GRAY + "Skyblock ID: " + itemId);
749+
if (main.getConfigValues().isEnabled(Feature.SHOW_ITEM_ANVIL_USES)) {
750+
// Anvil Uses ~ original done by Dahn#6036
751+
int anvilUses = main.getUtils().getNBTInteger(hoveredItem, "ExtraAttributes", "anvil_uses");
752+
if (anvilUses != -1) {
753+
int hotPotatoCount = main.getUtils().getNBTInteger(hoveredItem, "ExtraAttributes", "hot_potato_count");
754+
if (hotPotatoCount != -1) {
755+
anvilUses -= hotPotatoCount;
756+
}
757+
if (anvilUses > 0) {
758+
e.toolTip.add(insertAt++, Message.MESSAGE_ANVIL_USES.getMessage(String.valueOf(anvilUses)));
759+
}
771760
}
772761
}
773762

@@ -778,12 +767,41 @@ public void onItemTooltip(ItemTooltipEvent e) {
778767

779768
if (extraAttributesTag != null) {
780769
if (extraAttributesTag.hasKey("bossId") && extraAttributesTag.hasKey("spawnedFor")) {
781-
e.toolTip.add("§c§lBROKEN FRAGMENT§r");
770+
e.toolTip.add(insertAt++, "§c§lBROKEN FRAGMENT§r");
782771
}
783772
}
784773
}
785774
}
786775
}
776+
777+
if (main.getConfigValues().isEnabled(Feature.SHOW_BASE_STAT_BOOST_PERCENTAGE) && hoveredItem.hasTagCompound()) {
778+
NBTTagCompound extraAttributes = ItemUtils.getExtraAttributes(hoveredItem);
779+
if (extraAttributes != null) {
780+
int baseStatBoost = ItemUtils.getBaseStatBoostPercentage(extraAttributes);
781+
if (baseStatBoost != -1) {
782+
783+
ColorCode colorCode = main.getConfigValues().getRestrictedColor(Feature.SHOW_BASE_STAT_BOOST_PERCENTAGE);
784+
if (main.getConfigValues().isEnabled(Feature.SHOW_BASE_STAT_BOOST_PERCENTAGE_COLOUR_BY_RARITY)) {
785+
786+
int rarityIndex = baseStatBoost/10;
787+
if (rarityIndex < 0) rarityIndex = 0;
788+
if (rarityIndex >= ItemRarity.values().length) rarityIndex = ItemRarity.values().length - 1;
789+
790+
colorCode = ItemRarity.values()[rarityIndex].getColorCode();
791+
}
792+
e.toolTip.add(insertAt, "§7Base Stat Boost: " + colorCode + "+" + baseStatBoost + "%");
793+
}
794+
}
795+
}
796+
797+
// Append Skyblock Item ID to end of tooltip if in developer mode
798+
if (main.isDevMode() && e.showAdvancedItemTooltips) {
799+
String itemId = ItemUtils.getSkyBlockItemID(e.itemStack);
800+
801+
if (itemId != null) {
802+
e.toolTip.add(insertAt++, EnumChatFormatting.DARK_GRAY + "Skyblock ID: " + itemId);
803+
}
804+
}
787805
}
788806
}
789807

src/main/java/codes/biscuit/skyblockaddons/utils/EnumUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ public enum FeatureSetting {
254254
ROTATE_MAP(SETTING_ROTATE_MAP, 100),
255255
CENTER_ROTATION_ON_PLAYER(SETTING_CENTER_ROTATION_ON_PLAYER, 101),
256256
MAP_ZOOM(SETTING_MAP_ZOOM, -1),
257+
COLOUR_BY_RARITY(SETTING_COLOR_BY_RARITY, -1),
257258

258259
DISCORD_RP_STATE(null, 0),
259260
DISCORD_RP_DETAILS(null, 0)
@@ -302,7 +303,7 @@ public enum FeatureCredit {
302303
MYNAMEISJEFF("MyNameIsJeff", "github.com/My-Name-Is-Jeff", Feature.SHOW_BROKEN_FRAGMENTS),
303304
DJTHEREDSTONER("DJtheRedstoner", "github.com/DJtheRedstoner", Feature.LEGENDARY_SEA_CREATURE_WARNING, Feature.HIDE_SVEN_PUP_NAMETAGS),
304305
ANTONIO32A("Antonio32A", "github.com/Antonio32A", Feature.ONLY_BREAK_LOGS_PARK),
305-
CHARZARD("Charzard4261", "github.com/Charzard4261", Feature.DISABLE_TELEPORT_PAD_MESSAGES, Feature.BAIT_LIST);
306+
CHARZARD("Charzard4261", "github.com/Charzard4261", Feature.DISABLE_TELEPORT_PAD_MESSAGES, Feature.BAIT_LIST, Feature.SHOW_BASE_STAT_BOOST_PERCENTAGE);
306307

307308
private Set<Feature> features;
308309
private String author;

src/main/java/codes/biscuit/skyblockaddons/utils/ItemUtils.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,25 @@ else if (!item.hasTagCompound()) {
8383

8484
return null;
8585
}
86+
87+
public static NBTTagCompound getExtraAttributes(ItemStack item) {
88+
if (item == null || !item.hasTagCompound()) {
89+
return null;
90+
}
91+
92+
return item.getSubCompound("ExtraAttributes", false);
93+
}
94+
95+
/**
96+
* Returns the Base Stat Boost Percentage from a given Skyblock Extra Attributes NBT Compound
97+
* @param extraAttributes the NBT to check
98+
* @return the BSPB or {@code -1} if it isn't a Dungeons Item or this isn't a valid Skyblock NBT
99+
*/
100+
public static int getBaseStatBoostPercentage(NBTTagCompound extraAttributes) {
101+
if (extraAttributes == null || !extraAttributes.hasKey("baseStatBoostPercentage")) {
102+
return -1;
103+
}
104+
105+
return extraAttributes.getInteger("baseStatBoostPercentage");
106+
}
86107
}

src/main/resources/lang/en_us.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@
135135
"centerRotationOnYourPlayer": "Center the Rotation Around Your Player",
136136
"mapZoom": "Map Zoom",
137137
"glowingDroppedItems": "Glowing Dropped Items",
138-
"glowingDungeonTeammates": "Glowing Dungeon Teammates"
138+
"glowingDungeonTeammates": "Glowing Dungeon Teammates",
139+
"baseStatBoostPercentage": "Show Base Stat Boost for Dungeon Items",
140+
"colorByRarity": "Color By Rarity"
139141
},
140142
"messages": {
141143
"dropConfirmation": "Drop this item again to confirm!",

0 commit comments

Comments
 (0)