diff options
| author | NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> | 2023-08-31 02:44:27 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-30 18:44:27 +0200 |
| commit | ae35ab03ca4dbf7a902106f15f6e537fa86c0480 (patch) | |
| tree | bda802c9fa69e134acc69b7859bf97582852b5ed /src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java | |
| parent | 6f25e8bf8f24bcbf5575888492e0a557e5d01deb (diff) | |
| download | notenoughupdates-ae35ab03ca4dbf7a902106f15f6e537fa86c0480.tar.gz notenoughupdates-ae35ab03ca4dbf7a902106f15f6e537fa86c0480.tar.bz2 notenoughupdates-ae35ab03ca4dbf7a902106f15f6e537fa86c0480.zip | |
move taming, beastmaster, and minion overlay information to be gathered when running /pv (#785)
* use pv to steal taming level and beast master for pet overlay
* update profile data load event to when /pv is ran
* make minion helper say to use /pv if data is null
* make error message show
* make it so you can still pv if error in event
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java')
| -rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java | 127 |
1 files changed, 4 insertions, 123 deletions
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 016c17f0..726856cb 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java @@ -22,8 +22,6 @@ 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; import com.google.gson.JsonParser; @@ -36,11 +34,8 @@ import io.github.moulberry.notenoughupdates.listener.RenderListener; 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; import io.github.moulberry.notenoughupdates.util.Utils; import io.github.moulberry.notenoughupdates.util.XPInformation; import net.minecraft.client.Minecraft; @@ -54,7 +49,6 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.client.event.ClientChatReceivedEvent; -import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; @@ -156,6 +150,10 @@ public class PetInfoOverlay extends TextOverlay { private static long lastPetSelect = -1; private static PetConfig config = new PetConfig(); + public static PetConfig getConfig() { + return config; + } + private static long lastUpdate = 0; private static float levelXpLast = 0; @@ -281,110 +279,6 @@ public class PetInfoOverlay extends TextOverlay { } } - 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")) { - if (talisman.isJsonNull()) continue; - String internalName = talisman.getAsJsonObject().get("internalname").getAsString(); - if (internalName.startsWith("BEASTMASTER_CREST")) { - hasBeastmasterCrest = true; - try { - Rarity talismanRarity = Rarity.valueOf(internalName.replace("BEASTMASTER_CREST_", "")); - if (talismanRarity.beastcreatMultiplyer > currentBeastRarity.beastcreatMultiplyer) - currentBeastRarity = talismanRarity; - } catch (Exception ignored) { - } - } - } - if (hasBeastmasterCrest) { - if (stats.has("mythos_kills")) { - int mk = stats.get("mythos_kills").getAsInt(); - float petXpBoost = mk > 10000 ? 1f : mk > 7500 ? 0.9f : mk > 5000 ? 0.8f : mk > 2500 ? 0.7f : - mk > 1000 - ? 0.6f - : mk > 500 - ? 0.5f - : mk > 250 - ? 0.4f - : mk > 100 - ? 0.3f - : mk > 25 ? 0.2f : 0.1f; - config.beastMultiplier = petXpBoost * currentBeastRarity.beastcreatMultiplyer; - } else { - config.beastMultiplier = 0.1f * currentBeastRarity.beastcreatMultiplyer; - } - } - } - if (skyblockInfo != null && profile.getLatestProfile().skillsApiEnabled()) { - config.tamingLevel = (int) skyblockInfo.get("taming").level; - } - - //JsonObject petObject = profile.getPetsInfo(profile.getLatestProfile()); - /*JsonObject petsJson = Constants.PETS; - if(petsJson != null) { - if(petObject != null) { - boolean forceUpdateLevels = System.currentTimeMillis() - lastXpGain > 30000; - Set<String> foundPets = new HashSet<>(); - Set<Pet> addedPets = new HashSet<>(); - for(int i = 0; i < petObject.getAsJsonArray("pets").size(); i++) { - JsonElement petElement = petObject.getAsJsonArray("pets").get(i); - JsonObject petObj = petElement.getAsJsonObject(); - Pet pet = new Pet(); - pet.petType = petObj.get("type").getAsString(); - Rarity rarity; - try { - rarity = Rarity.valueOf(petObj.get("tier").getAsString()); - } catch(Exception ignored) { - rarity = Rarity.COMMON; - } - pet.rarity = rarity; - pet.petLevel = GuiProfileViewer.getPetLevel(petsJson.get("pet_levels").getAsJsonArray(), rarity.petOffset, petObj.get("exp").getAsFloat()); - JsonElement heldItem = petObj.get("heldItem"); - pet.petItem = heldItem.isJsonNull() ? null : heldItem.getAsString(); - if(rarity != Rarity.MYTHIC && pet.petItem != null && pet.petItem.equals("PET_ITEM_TIER_BOOST")) { - rarity = Rarity.values()[rarity.ordinal()+1]; - } - JsonObject petTypes = petsJson.get("pet_types").getAsJsonObject(); - pet.petXpType = petTypes.has(pet.petType) ? petTypes.get(pet.petType.toUpperCase()).getAsString().toLowerCase() : "unknown"; - - Pet closest = null; - if(petList.containsKey(pet.petType + ";" + pet.rarity.petId)) { - closest = getClosestPet(pet); - if(addedPets.contains(closest)) { - closest = null; - } - - if(closest != null) { - if(!forceUpdateLevels || Math.floor(pet.petLevel.level) < Math.floor(closest.petLevel.level)) { - pet.petLevel = closest.petLevel; - } - petList.get(pet.petType + ";" + pet.rarity.petId).remove(closest); - } - } - foundPets.add(pet.petType + ";" + pet.rarity.petId); - petList.computeIfAbsent(pet.petType + ";" + pet.rarity.petId, k->new HashSet<>()).add(pet); - addedPets.add(pet); - - if(petObj.get("active").getAsBoolean()) { - if(currentPet == null && !setActivePet) { - currentPet = pet; - } else if(closest == currentPet) { - currentPet = pet; - } - } - } - petList.keySet().retainAll(foundPets); - setActivePet = true; - } - }*/ - } - private float interp(float now, float last) { float interp = now; if (last >= 0 && last != now) { @@ -659,12 +553,6 @@ public class PetInfoOverlay extends TextOverlay { return; } - int updateTime = 60000; - - if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) { - ProfileApiSyncer.getInstance().requestResync("petinfo", updateTime, () -> {}, PetInfoOverlay::getAndSetPet); - } - Pet currentPet = getCurrentPet(); if (currentPet == null) { overlayStrings = null; @@ -1097,13 +985,6 @@ public class PetInfoOverlay extends TextOverlay { } } - @SubscribeEvent - public void switchWorld(WorldEvent.Load event) { - if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) { - ProfileApiSyncer.getInstance().requestResync("petinfo_quick", 10000, () -> {}, PetInfoOverlay::getAndSetPet); - } - } - private int lastLevelHovered = 0; private static final Pattern AUTOPET_EQUIP = Pattern.compile( |
