aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PowerStoneStatsDisplay.java
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2023-02-06 15:36:26 +0100
committerGitHub <noreply@github.com>2023-02-06 15:36:26 +0100
commit40887624fe1f1d843741ae1cbefb72ec7d4802f3 (patch)
treee313f9eb420abf9e7c854bf5926ce6137f4abb83 /src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PowerStoneStatsDisplay.java
parent5b702e9d1551b5cd2ef09fda16f98e676d38f381 (diff)
downloadnotenoughupdates-40887624fe1f1d843741ae1cbefb72ec7d4802f3.tar.gz
notenoughupdates-40887624fe1f1d843741ae1cbefb72ec7d4802f3.tar.bz2
notenoughupdates-40887624fe1f1d843741ae1cbefb72ec7d4802f3.zip
Fixed Lags: Magical power in SkyBlock Menu (#587)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PowerStoneStatsDisplay.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PowerStoneStatsDisplay.java30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PowerStoneStatsDisplay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PowerStoneStatsDisplay.java
index 31dd71eb..907f0f0d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PowerStoneStatsDisplay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PowerStoneStatsDisplay.java
@@ -19,10 +19,13 @@
package io.github.moulberry.notenoughupdates.miscfeatures;
+import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe;
import io.github.moulberry.notenoughupdates.core.util.StringUtils;
+import io.github.moulberry.notenoughupdates.events.ProfileDataLoadedEvent;
import io.github.moulberry.notenoughupdates.options.NEUConfig;
+import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewerUtils;
import io.github.moulberry.notenoughupdates.util.ItemUtils;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
@@ -54,13 +57,25 @@ public class PowerStoneStatsDisplay {
}
@SubscribeEvent
+ public void onProfileDataLoaded(ProfileDataLoadedEvent event) {
+ JsonObject profileInfo = event.getProfileInfo();
+
+ if (profileInfo == null) return;
+
+ JsonObject inventoryInfo = ProfileViewerUtils.readInventoryInfo(profileInfo, "talisman_bag");
+ if (inventoryInfo == null) return;
+
+ NEUConfig.HiddenProfileSpecific configProfileSpecific = NotEnoughUpdates.INSTANCE.config.getProfileSpecific();
+ if (configProfileSpecific == null) return;
+ int powerAmount = ProfileViewerUtils.getMagicalPower(inventoryInfo, profileInfo);
+ configProfileSpecific.magicalPower = powerAmount;
+ }
+
+ @SubscribeEvent
public void onTick(TickEvent event) {
+ if (!NotEnoughUpdates.INSTANCE.config.tooltipTweaks.powerStoneStats) return;
if (!dirty) return;
-
- if (!Utils.getOpenChestName().equals("SkyBlock Menu")) {
- dirty = false;
- return;
- }
+ if (!Utils.getOpenChestName().equals("Your Bags")) return;
EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
Container openContainer = p.openContainer;
@@ -70,14 +85,15 @@ public class PowerStoneStatsDisplay {
String displayName = stack.getDisplayName();
if (!"§aAccessory Bag".equals(displayName)) continue;
+ dirty = false;
for (String line : ItemUtils.getLore(stack)) {
if (line.startsWith("§7Magical Power: ")) {
String rawNumber = line.split("§6")[1].replace(",", "");
NEUConfig.HiddenProfileSpecific configProfileSpecific = NotEnoughUpdates.INSTANCE.config.getProfileSpecific();
if (configProfileSpecific == null) return;
- configProfileSpecific.magicalPower = Integer.parseInt(rawNumber);
- dirty = false;
+ int magicalPower = Integer.parseInt(rawNumber);
+ configProfileSpecific.magicalPower = magicalPower;
}
}
}