aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures
diff options
context:
space:
mode:
authorkr45732 <52721908+kr45732@users.noreply.github.com>2023-06-08 10:00:04 -0400
committerGitHub <noreply@github.com>2023-06-08 16:00:04 +0200
commit8115922b37e375285c2a72dbdbb5d83fd942e27c (patch)
treee0d6cb5228493e8bb032465cbb2dfd95b4946e43 /src/main/java/io/github/moulberry/notenoughupdates/miscfeatures
parenta6fb7bfb97d313b665085a52a660150f1da26065 (diff)
downloadnotenoughupdates-8115922b37e375285c2a72dbdbb5d83fd942e27c.tar.gz
notenoughupdates-8115922b37e375285c2a72dbdbb5d83fd942e27c.tar.bz2
notenoughupdates-8115922b37e375285c2a72dbdbb5d83fd942e27c.zip
PV Overhaul (#708)
Co-authored-by: Lulonaut <lulonaut@tutanota.de>
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscfeatures')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java29
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PowerStoneStatsDisplay.java17
3 files changed, 23 insertions, 27 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java
index 55dedadf..72431697 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java
@@ -715,7 +715,9 @@ public class CustomItemEffects {
NBTTagCompound buildersItem = items.getCompoundTagAt(j);
if (buildersItem.getKeySet().size() > 0) {
String internalname =
- NotEnoughUpdates.INSTANCE.manager.getInternalnameFromNBT(buildersItem.getCompoundTag("tag"));
+ NotEnoughUpdates.INSTANCE.manager.createItemResolutionQuery()
+ .withItemNBT(buildersItem.getCompoundTag("tag"))
+ .resolveInternalName();
if (internalname != null && internalname.equals("INFINIDIRT_WAND")) {
return true;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java
index 693bb3e3..fadf8b1b 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java
@@ -22,6 +22,7 @@ package io.github.moulberry.notenoughupdates.miscfeatures;
import com.google.common.collect.Lists;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
@@ -36,6 +37,7 @@ import io.github.moulberry.notenoughupdates.options.NEUConfig;
import io.github.moulberry.notenoughupdates.overlays.TextOverlay;
import io.github.moulberry.notenoughupdates.overlays.TextOverlayStyle;
import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer;
+import io.github.moulberry.notenoughupdates.profileviewer.SkyblockProfiles;
import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.PetLeveling;
import io.github.moulberry.notenoughupdates.util.ProfileApiSyncer;
@@ -66,15 +68,11 @@ import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
-import java.text.DecimalFormat;
-import java.text.DecimalFormatSymbols;
-import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
-import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
@@ -283,15 +281,15 @@ public class PetInfoOverlay extends TextOverlay {
}
}
- private static void getAndSetPet(ProfileViewer.Profile profile) {
- Map<String, ProfileViewer.Level> skyblockInfo = profile.getSkyblockInfo(profile.getLatestProfile());
- JsonObject invInfo = profile.getInventoryInfo(profile.getLatestProfile());
- JsonObject profileInfo = profile.getProfileInformation(profile.getLatestProfile());
+ private static void getAndSetPet(SkyblockProfiles profile) {
+ Map<String, ProfileViewer.Level> skyblockInfo = profile.getLatestProfile().getLevelingInfo();
+ Map<String, JsonArray> invInfo = profile.getLatestProfile().getInventoryInfo();
+ JsonObject profileInfo = profile.getLatestProfile().getProfileJson();
if (invInfo != null && profileInfo != null) {
JsonObject stats = profileInfo.get("stats").getAsJsonObject();
boolean hasBeastmasterCrest = false;
Rarity currentBeastRarity = Rarity.COMMON;
- for (JsonElement talisman : invInfo.get("talisman_bag").getAsJsonArray()) {
+ for (JsonElement talisman : invInfo.get("talisman_bag")) {
if (talisman.isJsonNull()) continue;
String internalName = talisman.getAsJsonObject().get("internalname").getAsString();
if (internalName.startsWith("BEASTMASTER_CREST")) {
@@ -323,7 +321,9 @@ public class PetInfoOverlay extends TextOverlay {
}
}
}
- if (skyblockInfo != null) config.tamingLevel = (int) skyblockInfo.get("taming").level;
+ if (skyblockInfo != null && profile.getLatestProfile().skillsApiEnabled()) {
+ config.tamingLevel = (int) skyblockInfo.get("taming").level;
+ }
//JsonObject petObject = profile.getPetsInfo(profile.getLatestProfile());
/*JsonObject petsJson = Constants.PETS;
@@ -515,10 +515,9 @@ public class PetInfoOverlay extends TextOverlay {
}
public float getLevelPercent(Pet pet) {
- DecimalFormat df = new DecimalFormat("#.#", DecimalFormatSymbols.getInstance(Locale.ENGLISH));
if (pet == null) return 0;
try {
- return Float.parseFloat(df.format(Math.min(pet.petLevel.getPercentageToNextLevel() * 100f, 100f)));
+ return Float.parseFloat(StringUtils.formatToTenths(Math.min(pet.petLevel.getPercentageToNextLevel() * 100f, 100f)));
} catch (Exception ignored) {
return 0;
}
@@ -1085,13 +1084,13 @@ public class PetInfoOverlay extends TextOverlay {
public String roundFloat(float f) {
if (f % 1 < 0.05f) {
- return NumberFormat.getNumberInstance().format((int) f);
+ return StringUtils.formatNumber((int) f);
} else {
String s = Utils.floatToString(f, 1);
if (s.contains(".")) {
- return NumberFormat.getNumberInstance().format((int) f) + '.' + s.split("\\.")[1];
+ return StringUtils.formatNumber((int) f) + '.' + s.split("\\.")[1];
} else if (s.contains(",")) {
- return NumberFormat.getNumberInstance().format((int) f) + ',' + s.split(",")[1];
+ return StringUtils.formatNumber((int) f) + ',' + s.split(",")[1];
} else {
return s;
}
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 907f0f0d..fd9b2938 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PowerStoneStatsDisplay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PowerStoneStatsDisplay.java
@@ -19,6 +19,7 @@
package io.github.moulberry.notenoughupdates.miscfeatures;
+import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe;
@@ -38,15 +39,12 @@ import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
-import java.text.NumberFormat;
import java.util.LinkedList;
import java.util.List;
-import java.util.Locale;
@NEUAutoSubscribe
public class PowerStoneStatsDisplay {
private static PowerStoneStatsDisplay instance = null;
- private final NumberFormat format = NumberFormat.getInstance(Locale.US);
private boolean dirty = true;
public static PowerStoneStatsDisplay getInstance() {
@@ -59,16 +57,14 @@ public class PowerStoneStatsDisplay {
@SubscribeEvent
public void onProfileDataLoaded(ProfileDataLoadedEvent event) {
JsonObject profileInfo = event.getProfileInfo();
-
if (profileInfo == null) return;
- JsonObject inventoryInfo = ProfileViewerUtils.readInventoryInfo(profileInfo, "talisman_bag");
+ JsonArray 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;
+ configProfileSpecific.magicalPower = ProfileViewerUtils.getMagicalPower(inventoryInfo, profileInfo);
}
@SubscribeEvent
@@ -92,8 +88,7 @@ public class PowerStoneStatsDisplay {
String rawNumber = line.split("§6")[1].replace(",", "");
NEUConfig.HiddenProfileSpecific configProfileSpecific = NotEnoughUpdates.INSTANCE.config.getProfileSpecific();
if (configProfileSpecific == null) return;
- int magicalPower = Integer.parseInt(rawNumber);
- configProfileSpecific.magicalPower = magicalPower;
+ configProfileSpecific.magicalPower = Integer.parseInt(rawNumber);
}
}
}
@@ -153,7 +148,7 @@ public class PowerStoneStatsDisplay {
return;
}
- event.toolTip.set(index, "§7At §6" + format.format((double) magicalPower) + " Magical Power§7:");
+ event.toolTip.set(index, "§7At §6" + StringUtils.formatNumber((double) magicalPower) + " Magical Power§7:");
foundMagicalPower = true;
continue;
}
@@ -177,7 +172,7 @@ public class PowerStoneStatsDisplay {
}
double realStat = (currentStat / scaledCurrentPower) * scaledMagicalPower;
- String format = this.format.format((double) Math.round(realStat));
+ String format = StringUtils.formatNumber((double) Math.round(realStat));
format += rawStat.substring(rawStat.length() - 1);
event.toolTip.set(index, line.replace(rawStat, format));