From 5e77a5d07faa6bfced80eef06ce34d43661fcba4 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Sun, 5 Feb 2023 23:41:13 +0100 Subject: Fixed NPE in CalendarOverlay (#582) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java | 1 + 1 file changed, 1 insertion(+) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java index 48d37f2f..87691631 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java @@ -298,6 +298,7 @@ public class CalendarOverlay { boolean changed = false; for (int i = 0; i < 31; i++) { ItemStack item = cc.getLowerChestInventory().getStackInSlot(1 + (i % 7) + (i / 7) * 9); + if (item == null) continue; JsonArray array = new JsonArray(); if (item.getTagCompound() != null) { -- cgit From fc576576b8aa18476766e166718d98a6c0fb4575 Mon Sep 17 00:00:00 2001 From: efefury <69400149+efefury@users.noreply.github.com> Date: Mon, 6 Feb 2023 13:54:31 +0000 Subject: Align level in Basic PV page to center (#586) Fixes https://github.com/NotEnoughUpdates/NotEnoughUpdates/issues/584 --- .../notenoughupdates/profileviewer/BasicPage.java | 6 +++--- .../profileviewer/level/task/DungeonTaskLevel.java | 2 +- .../io/github/moulberry/notenoughupdates/util/Utils.java | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java index 8a48dd2c..7be94f86 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java @@ -572,7 +572,7 @@ public class BasicPage extends GuiProfileViewerPage { ); } - // sb lvlL + // sb lvl int sbLevelX = guiLeft + 162; int sbLevelY = guiTop + 90; @@ -585,8 +585,8 @@ public class BasicPage extends GuiProfileViewerPage { GlStateManager.scale(1.5f, 1.5f, 1); Utils.drawItemStack(skull, 0, 0); GlStateManager.popMatrix(); - Utils.drawStringScaled(skyblockLevelColour.toString() + (int) skyblockLevel, fr, - sbLevelX - 2, sbLevelY - 15, true, 0, 1.5f + Utils.drawStringCenteredScaled(skyblockLevelColour.toString() + (int) skyblockLevel, fr, + sbLevelX + 9, sbLevelY - 12, true, 1.5f ); float progress = (float) (skyblockLevel - (long) skyblockLevel); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/DungeonTaskLevel.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/DungeonTaskLevel.java index 157c8362..6f0a029f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/DungeonTaskLevel.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/DungeonTaskLevel.java @@ -106,7 +106,7 @@ public class DungeonTaskLevel { lore.add(levelPage.buildLore("Complete Dungeons", sbLevelGainedFloor, completeDungeon, false)); levelPage.renderLevelBar( - "Dungeon", + "Dungeon Task", NotEnoughUpdates.INSTANCE.manager .createItemResolutionQuery() .withKnownInternalName("WITHER_RELIC") diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index 952eb50f..0424e311 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -1229,6 +1229,22 @@ public class Utils { drawStringScaled(str, fr, x - len / 2, y - fontHeight / 2, shadow, colour, factor); } + public static void drawStringCenteredScaled( + String str, + FontRenderer fr, + float x, + float y, + boolean shadow, + float factor + ) { + int strLen = fr.getStringWidth(str); + + float x2 = x - strLen / 2f; + float y2 = y - fr.FONT_HEIGHT / 2f; + + drawStringScaled(str, fr, x2, y2, shadow, 0, factor); + } + public static void drawStringCenteredYScaled( String str, FontRenderer fr, -- cgit From 2451485b81a2d3c4a4e65a2647a1a698144abe17 Mon Sep 17 00:00:00 2001 From: efefury <69400149+efefury@users.noreply.github.com> Date: Mon, 6 Feb 2023 14:02:26 +0000 Subject: Fix click in PV & Replace Texture (#589) --- .../moulberry/notenoughupdates/profileviewer/BasicPage.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java index 7be94f86..265177fc 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java @@ -596,6 +596,12 @@ public class BasicPage extends GuiProfileViewerPage { sbLevelX - 30, sbLevelY + 20, true, 0, 0.9f ); + if (mouseX >= guiLeft + 128 && mouseX <= guiLeft + 216) { + if (mouseY >= guiTop + 69 && mouseY <= guiTop + 131) { + if (Mouse.isButtonDown(0)) onSecondPage = true; + } + } + if (skyblockInfo != null) { int position = 0; for (Map.Entry entry : ProfileViewer.getSkillToSkillDisplayMap().entrySet()) { @@ -623,12 +629,6 @@ public class BasicPage extends GuiProfileViewerPage { getInstance().renderBar(x, y + 6, 80, level.level % 1); } - if (mouseX >= guiLeft + 128 && mouseX <= guiLeft + 216) { - if (mouseY >= guiTop + 69 && mouseY <= guiTop + 131) { - if (Mouse.isButtonDown(0)) onSecondPage = true; - } - } - if (mouseX > x && mouseX < x + 80) { if (mouseY > y - 4 && mouseY < y + 13) { getInstance().tooltipToDisplay = new ArrayList<>(); -- cgit From 5b702e9d1551b5cd2ef09fda16f98e676d38f381 Mon Sep 17 00:00:00 2001 From: NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> Date: Mon, 6 Feb 2023 14:33:16 +0000 Subject: Fixed pickaxe cooldown not working on mining overlay when you have the durability bar disabled (#595) --- .../moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java index 5651a6ed..2253ca4a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java @@ -182,8 +182,7 @@ public class ItemCooldowns { @SubscribeEvent public void onChatMessage(ClientChatReceivedEvent event) { - if (PICKAXE_ABILITY_ACTIVATION.matcher(event.message.getFormattedText()).matches() && - NotEnoughUpdates.INSTANCE.config.itemOverlays.pickaxeAbility && pickaxeCooldown != 0) { + if (PICKAXE_ABILITY_ACTIVATION.matcher(event.message.getFormattedText()).matches() && pickaxeCooldown != 0) { findCooldownInTooltip(Item.PICKAXES); pickaxeUseCooldownMillisRemaining = pickaxeCooldown * 1000; } @@ -260,10 +259,12 @@ public class ItemCooldowns { } // Pickaxes - if (isPickaxe(internalname) && NotEnoughUpdates.INSTANCE.config.itemOverlays.pickaxeAbility) { + if (isPickaxe(internalname)) { findCooldownInTooltip(Item.PICKAXES); - return durabilityOverride(pickaxeUseCooldownMillisRemaining, pickaxeCooldown, stack); + if (NotEnoughUpdates.INSTANCE.config.itemOverlays.pickaxeAbility) { + return durabilityOverride(pickaxeUseCooldownMillisRemaining, pickaxeCooldown, stack); + } else return -1; } // Treecapitator / Jungle Axe if (internalname.equals("TREECAPITATOR_AXE") || internalname.equals("JUNGLE_AXE")) { -- cgit From 40887624fe1f1d843741ae1cbefb72ec7d4802f3 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Mon, 6 Feb 2023 15:36:26 +0100 Subject: Fixed Lags: Magical power in SkyBlock Menu (#587) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../events/ProfileDataLoadedEvent.java | 40 ------ .../miscfeatures/PowerStoneStatsDisplay.java | 30 +++- .../profileviewer/ProfileViewer.java | 100 +------------ .../profileviewer/ProfileViewerUtils.java | 156 +++++++++++++++++++++ .../moulberry/notenoughupdates/util/ApiUtil.java | 5 +- 5 files changed, 183 insertions(+), 148 deletions(-) delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/events/ProfileDataLoadedEvent.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewerUtils.java (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/events/ProfileDataLoadedEvent.java b/src/main/java/io/github/moulberry/notenoughupdates/events/ProfileDataLoadedEvent.java deleted file mode 100644 index 956acfe0..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/events/ProfileDataLoadedEvent.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see . - */ - -package io.github.moulberry.notenoughupdates.events; - -import com.google.gson.JsonObject; - -import javax.annotation.Nullable; - -//TODO extend the usage of this event (accessory bag and storage data) -public class ProfileDataLoadedEvent extends NEUEvent { - - @Nullable - private final JsonObject data; - - public ProfileDataLoadedEvent(@Nullable JsonObject entireApiResponse) { - this.data = entireApiResponse; - } - - @Nullable - public JsonObject getData() { - return data; - } -} 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; @@ -53,14 +56,26 @@ public class PowerStoneStatsDisplay { return instance; } + @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; } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java index 610e4090..17a14d1f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java @@ -28,7 +28,6 @@ import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.profileviewer.bestiary.BestiaryData; import io.github.moulberry.notenoughupdates.profileviewer.weight.senither.SenitherWeight; import io.github.moulberry.notenoughupdates.util.Constants; -import io.github.moulberry.notenoughupdates.util.JsonUtils; import io.github.moulberry.notenoughupdates.util.Utils; import io.github.moulberry.notenoughupdates.util.hypixelapi.ProfileCollectionInfo; import net.minecraft.init.Blocks; @@ -36,7 +35,6 @@ import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompressedStreamTools; -import net.minecraft.nbt.JsonToNBT; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.EnumChatFormatting; @@ -44,25 +42,20 @@ import net.minecraft.util.EnumChatFormatting; import javax.annotation.Nullable; import java.io.ByteArrayInputStream; import java.io.IOException; -import java.util.AbstractMap; import java.util.ArrayList; import java.util.Arrays; import java.util.Base64; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; -import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.Objects; -import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; import java.util.regex.Pattern; -import java.util.stream.Collectors; public class ProfileViewer { @@ -703,98 +696,7 @@ public class ProfileViewer { return -1; } - Map accessories = JsonUtils.getJsonArrayAsStream(inventoryInfo - .get("talisman_bag") - .getAsJsonArray()).map(o -> { - try { - return JsonToNBT.getTagFromJson(o - .getAsJsonObject() - .get("nbttag") - .getAsString()); - } catch (Exception ignored) { - return null; - } - }).filter(Objects::nonNull).map(tag -> { - NBTTagList loreTagList = tag.getCompoundTag("display").getTagList("Lore", 8); - String lastElement = loreTagList.getStringTagAt(loreTagList.tagCount() - 1); - if (lastElement.contains(EnumChatFormatting.OBFUSCATED.toString())) { - lastElement = lastElement.substring(lastElement.indexOf(' ')).trim().substring(4); - } - JsonArray lastElementJsonArray = new JsonArray(); - lastElementJsonArray.add(new JsonPrimitive(lastElement)); - return new AbstractMap.SimpleEntry<>( - tag.getCompoundTag("ExtraAttributes").getString("id"), - Utils.getRarityFromLore(lastElementJsonArray) - ); - }).sorted(Comparator.comparingInt(e -> -e.getValue())).collect(Collectors.toMap( - Map.Entry::getKey, - Map.Entry::getValue, - (v1, v2) -> v1, - LinkedHashMap::new - )); - - Set ignoredTalismans = new HashSet<>(); - int powerAmount = 0; - for (Map.Entry entry : accessories.entrySet()) { - if (ignoredTalismans.contains(entry.getKey())) { - continue; - } - - JsonArray children = Utils - .getElementOrDefault(Constants.PARENTS, entry.getKey(), new JsonArray()) - .getAsJsonArray(); - for (JsonElement child : children) { - ignoredTalismans.add(child.getAsString()); - } - - if (entry.getKey().equals("HEGEMONY_ARTIFACT")) { - switch (entry.getValue()) { - case 4: - powerAmount += 16; - break; - case 5: - powerAmount += 22; - break; - } - } - if (entry.getKey().equals("ABICASE")) { - if (profileInfo != null && profileInfo.has("nether_island_player_data") && - profileInfo.get("nether_island_player_data").getAsJsonObject().has("abiphone") && profileInfo - .get( - "nether_island_player_data") - .getAsJsonObject() - .get("abiphone") - .getAsJsonObject() - .has("active_contacts")) { // BatChest - int contact = - profileInfo.get("nether_island_player_data").getAsJsonObject().get("abiphone").getAsJsonObject().get( - "active_contacts").getAsJsonArray().size(); - powerAmount += Math.floor(contact / 2); - } - } - switch (entry.getValue()) { - case 0: - case 6: - powerAmount += 3; - break; - case 1: - case 7: - powerAmount += 5; - break; - case 2: - powerAmount += 8; - break; - case 3: - powerAmount += 12; - break; - case 4: - powerAmount += 16; - break; - case 5: - powerAmount += 22; - break; - } - } + int powerAmount = ProfileViewerUtils.getMagicalPower(inventoryInfo, profileInfo); magicalPower.put(profileId, powerAmount); return powerAmount; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewerUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewerUtils.java new file mode 100644 index 00000000..66164688 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewerUtils.java @@ -0,0 +1,156 @@ +/* + * Copyright (C) 2023 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see . + */ + +package io.github.moulberry.notenoughupdates.profileviewer; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; +import io.github.moulberry.notenoughupdates.NEUManager; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.util.Constants; +import io.github.moulberry.notenoughupdates.util.JsonUtils; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.JsonToNBT; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.EnumChatFormatting; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.AbstractMap; +import java.util.Base64; +import java.util.Comparator; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; + +public class ProfileViewerUtils { + + public static JsonObject readInventoryInfo(JsonObject profileInfo, String bagName) { + JsonObject inventoryInfo = new JsonObject(); + JsonElement element = Utils.getElement(profileInfo, bagName + ".data"); + + String bytes = Utils.getElementAsString(element, "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA="); + NBTTagCompound inv_contents_nbt; + try { + inv_contents_nbt = CompressedStreamTools.readCompressed( + new ByteArrayInputStream(Base64.getDecoder().decode(bytes)) + ); + } catch (IOException e) { + e.printStackTrace(); + return null; + } + NBTTagList items = inv_contents_nbt.getTagList("i", 10); + JsonArray contents = new JsonArray(); + NEUManager manager = NotEnoughUpdates.INSTANCE.manager; + for (int j = 0; j < items.tagCount(); j++) { + JsonObject item = manager.getJsonFromNBTEntry(items.getCompoundTagAt(j)); + contents.add(item); + } + + inventoryInfo.add(bagName, contents); + return inventoryInfo; + } + + public static int getMagicalPower(JsonObject inventoryInfo, JsonObject profileInfo) { + JsonArray talismanBag = inventoryInfo.get("talisman_bag").getAsJsonArray(); + Map accessories = JsonUtils.getJsonArrayAsStream(talismanBag).map(o -> { + try { + return JsonToNBT.getTagFromJson(o.getAsJsonObject().get("nbttag").getAsString()); + } catch (Exception ignored) { + return null; + } + }).filter(Objects::nonNull).map(tag -> { + NBTTagList loreTagList = tag.getCompoundTag("display").getTagList("Lore", 8); + String lastElement = loreTagList.getStringTagAt(loreTagList.tagCount() - 1); + if (lastElement.contains(EnumChatFormatting.OBFUSCATED.toString())) { + lastElement = lastElement.substring(lastElement.indexOf(' ')).trim().substring(4); + } + JsonArray lastElementJsonArray = new JsonArray(); + lastElementJsonArray.add(new JsonPrimitive(lastElement)); + return new AbstractMap.SimpleEntry<>(tag.getCompoundTag("ExtraAttributes").getString("id"), + Utils.getRarityFromLore(lastElementJsonArray) + ); + }).sorted(Comparator.comparingInt(e -> -e.getValue())).collect(Collectors.toMap( + Map.Entry::getKey, Map.Entry::getValue, (v1, v2) -> v1, LinkedHashMap::new + )); + + Set ignoredTalismans = new HashSet<>(); + int powerAmount = 0; + for (Map.Entry entry : accessories.entrySet()) { + if (ignoredTalismans.contains(entry.getKey())) continue; + + JsonArray children = Utils + .getElementOrDefault(Constants.PARENTS, entry.getKey(), new JsonArray()) + .getAsJsonArray(); + for (JsonElement child : children) { + ignoredTalismans.add(child.getAsString()); + } + + if (entry.getKey().equals("HEGEMONY_ARTIFACT")) { + switch (entry.getValue()) { + case 4: + powerAmount += 16; + break; + case 5: + powerAmount += 22; + break; + } + } + if (entry.getKey().equals("ABICASE")) { + if (profileInfo != null && profileInfo.has("nether_island_player_data")) { + JsonObject data = profileInfo.get("nether_island_player_data").getAsJsonObject(); + if (data.has("abiphone") && data.get("abiphone").getAsJsonObject().has("active_contacts")) { // BatChest + int contact = data.get("abiphone").getAsJsonObject().get("active_contacts").getAsJsonArray().size(); + powerAmount += Math.floor(contact / 2); + } + } + } + switch (entry.getValue()) { + case 0: + case 6: + powerAmount += 3; + break; + case 1: + case 7: + powerAmount += 5; + break; + case 2: + powerAmount += 8; + break; + case 3: + powerAmount += 12; + break; + case 4: + powerAmount += 16; + break; + case 5: + powerAmount += 22; + break; + } + } + return powerAmount; + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java b/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java index c86ac84f..0c590bab 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java @@ -89,11 +89,12 @@ public class ApiUtil { public void updateProfileData(String playerUuid) { if (!updateTasks.getOrDefault(playerUuid, CompletableFuture.completedFuture(null)).isDone()) return; + String uuid = Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""); updateTasks.put(playerUuid, newHypixelApiRequest("skyblock/profiles") - .queryArgument("uuid", Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", "")) + .queryArgument("uuid", uuid) .requestJson() .handle((jsonObject, throwable) -> { - new ProfileDataLoadedEvent(jsonObject).post(); + new ProfileDataLoadedEvent(uuid, jsonObject).post(); return null; })); -- cgit From 405b8b4804af7dfc1f4f53d947944980e203a88d Mon Sep 17 00:00:00 2001 From: NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> Date: Mon, 6 Feb 2023 14:42:50 +0000 Subject: Fixed Major issue of sound playing when clicking on an invisible arrow (#593) --- .../io/github/moulberry/notenoughupdates/core/util/ArrowPagesUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/util/ArrowPagesUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/core/util/ArrowPagesUtils.java index 86430804..1e70db7f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/util/ArrowPagesUtils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/util/ArrowPagesUtils.java @@ -173,7 +173,7 @@ public class ArrowPagesUtils { BUTTON_WIDTH, BUTTON_HEIGHT ) && - currentPage < totalPages) { + currentPage < totalPages - 1) { int newPage = currentPage + 1; pageChange.accept(MathHelper.clamp_int(newPage, 0, totalPages - 1)); Utils.playPressSound(); -- cgit From 0294a87dc03f4d9b13022079b808e234b9a7545b Mon Sep 17 00:00:00 2001 From: NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> Date: Mon, 6 Feb 2023 14:43:27 +0000 Subject: Fix Gui scale setting freaking out when your gui scale is set to 5x or higher (#596) --- src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index 0424e311..d5abcb77 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -186,7 +186,7 @@ public class Utils { } int newScale = guiScales.size() > 0 - ? Math.max(0, Math.min(4, guiScales.peek())) + ? Math.max(0, guiScales.peek()) : Minecraft.getMinecraft().gameSettings.guiScale; if (newScale == 0) newScale = Minecraft.getMinecraft().gameSettings.guiScale; -- cgit From b9f9917306b3b522ef83f22faef30977ac73fd52 Mon Sep 17 00:00:00 2001 From: efefury <69400149+efefury@users.noreply.github.com> Date: Mon, 6 Feb 2023 23:40:17 +0000 Subject: Fix NPE in Level Page (v1) (#597) --- .../profileviewer/level/task/EssenceTaskLevel.java | 4 +++- .../profileviewer/level/task/MiscTaskLevel.java | 23 +++++++++++----------- 2 files changed, 15 insertions(+), 12 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/EssenceTaskLevel.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/EssenceTaskLevel.java index d64f54c1..11e291b0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/EssenceTaskLevel.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/EssenceTaskLevel.java @@ -94,7 +94,9 @@ public class EssenceTaskLevel { .resolveToItemListJson() .get("displayname") .getAsString(); - value.max = essenceShopTask.get(key.toLowerCase() + "_shop").getAsInt(); + String name = key.toLowerCase() + "_shop"; + if (!essenceShopTask.has(name)) continue; + value.max = essenceShopTask.get(name).getAsInt(); lore.add(levelPage.buildLore( EnumChatFormatting.getTextWithoutFormattingCodes(value.name), value.current, diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/MiscTaskLevel.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/MiscTaskLevel.java index a717664d..e0ea89b3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/MiscTaskLevel.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/MiscTaskLevel.java @@ -116,17 +116,18 @@ public class MiscTaskLevel { JsonObject communityShopUpgradesMax = miscellaneousTask.getAsJsonObject("community_shop_upgrades_max"); int communityShopUpgradesXp = miscellaneousTask.get("community_shop_upgrades_xp").getAsInt(); - - for ( - JsonElement upgradeState : upgradeStates) { - if (!upgradeState.isJsonObject()) continue; - JsonObject value = upgradeState.getAsJsonObject(); - String upgrade = value.get("upgrade").getAsString(); - int tier = value.get("tier").getAsInt(); - if (communityShopUpgradesMax.has(upgrade)) { - int max = communityShopUpgradesMax.get(upgrade).getAsInt(); - if (max >= tier) { - sbXpCommunityUpgrade += communityShopUpgradesXp; + if (upgradeStates != null) { + for ( + JsonElement upgradeState : upgradeStates) { + if (!upgradeState.isJsonObject()) continue; + JsonObject value = upgradeState.getAsJsonObject(); + String upgrade = value.get("upgrade").getAsString(); + int tier = value.get("tier").getAsInt(); + if (communityShopUpgradesMax.has(upgrade)) { + int max = communityShopUpgradesMax.get(upgrade).getAsInt(); + if (max >= tier) { + sbXpCommunityUpgrade += communityShopUpgradesXp; + } } } } -- cgit From 9ac80842dd3e280bd1468c7261d30c21968b0da1 Mon Sep 17 00:00:00 2001 From: Roman / Linnea Gräf Date: Tue, 7 Feb 2023 06:25:16 +0100 Subject: ApiUtil: Add developer only user agent override (#590) Co-authored-by: NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> --- .../moulberry/notenoughupdates/commands/dev/DevTestCommand.java | 5 +++++ .../io/github/moulberry/notenoughupdates/options/NEUConfig.java | 2 ++ .../java/io/github/moulberry/notenoughupdates/util/ApiUtil.java | 9 +++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java index 0d882358..35474ff3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java @@ -254,5 +254,10 @@ public class DevTestCommand extends ClientCommandBase { MiscUtils.copyToClipboard(builder.toString()); Utils.addChatMessage("§e[NEU] Copied tablist to clipboard!"); } + if (args.length >= 1 && args[0].equalsIgnoreCase("useragent")) { + String newUserAgent = args.length == 1 ? null : String.join(" ", Arrays.copyOfRange(args, 1, args.length)); + Utils.addChatMessage("§e[NEU] Changed user agent override to: " + newUserAgent); + NotEnoughUpdates.INSTANCE.config.hidden.customUserAgent = newUserAgent; + } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java index 371d657e..a289ca51 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java @@ -438,6 +438,8 @@ public class NEUConfig extends Config { @Expose public int compareMode = 0; @Expose + public String customUserAgent = null; + @Expose public int sortMode = 0; @Expose public ArrayList compareAscending = Lists.newArrayList(true, true, true); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java b/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java index 0c590bab..023be060 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java @@ -61,7 +61,12 @@ import java.util.zip.GZIPInputStream; public class ApiUtil { private static final Gson gson = new Gson(); private static final ExecutorService executorService = Executors.newFixedThreadPool(3); - private static final String USER_AGENT = "NotEnoughUpdates/" + NotEnoughUpdates.VERSION; + private static String getUserAgent() { + if (NotEnoughUpdates.INSTANCE.config.hidden.customUserAgent != null) { + return NotEnoughUpdates.INSTANCE.config.hidden.customUserAgent; + } + return "NotEnoughUpdates/" + NotEnoughUpdates.VERSION; + } private static SSLContext ctx; private final Map> updateTasks = new HashMap<>(); @@ -170,7 +175,7 @@ public class ApiUtil { } conn.setConnectTimeout(10000); conn.setReadTimeout(10000); - conn.setRequestProperty("User-Agent", USER_AGENT); + conn.setRequestProperty("User-Agent", getUserAgent()); if (this.postContentType != null) { conn.setRequestProperty("Content-Type", this.postContentType); } -- cgit From 7cdf7b41bfe5f2631827e0512fffe079972af586 Mon Sep 17 00:00:00 2001 From: jani270 <69345714+jani270@users.noreply.github.com> Date: Wed, 8 Feb 2023 11:35:14 +0100 Subject: Fixed prerelease update notification and changed version (#600) Co-authored-by: NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> --- .../java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java | 2 +- .../moulberry/notenoughupdates/miscfeatures/updater/AutoUpdater.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index a4643eb5..25d1002a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -97,7 +97,7 @@ import java.util.Set; guiFactory = "io.github.moulberry.notenoughupdates.core.config.MoulConfigGuiForgeInterop") public class NotEnoughUpdates { public static final String MODID = "notenoughupdates"; - public static final String VERSION = "2.1.0-REL"; + public static final String VERSION = "2.1.1-PRE"; public static final int VERSION_ID = 20101; //2.1.1 only so update notif works public static final int PRE_VERSION_ID = 0; public static final int HOTFIX_VERSION_ID = 0; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/updater/AutoUpdater.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/updater/AutoUpdater.java index 54fcc204..f41654e7 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/updater/AutoUpdater.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/updater/AutoUpdater.java @@ -186,7 +186,7 @@ public class AutoUpdater { int fullReleaseVersion = o.has("version_id") && o.get("version_id").isJsonPrimitive() ? o.get("version_id").getAsInt() : -1; int preReleaseVersion = - o.has("version_id") && o.get("version_id").isJsonPrimitive() ? o.get("version_id").getAsInt() : -1; + o.has("pre_version_id") && o.get("pre_version_id").isJsonPrimitive() ? o.get("pre_version_id").getAsInt() : -1; int hotfixVersion = o.has("hotfix_id") && o.get("hotfix_id").isJsonPrimitive() ? o.get("hotfix_id").getAsInt() : -1; -- cgit From 1d1017c55492175b8a2c2329d8c050c71c45ccfe Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Sat, 11 Feb 2023 12:37:43 +0100 Subject: Merge pull request #583 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Bingo has already enough to do. * Typo. * Realization: Century Cakes exist. * I added back cakes, so I removed them back from the list of features … * Default enabled. --- .../options/seperateSections/MiscOverlays.java | 10 +++++++++- .../notenoughupdates/overlays/TimersOverlay.java | 16 +++++++++++++++- .../github/moulberry/notenoughupdates/util/SBInfo.java | 4 ++++ 3 files changed, 28 insertions(+), 2 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java index 714dd7b7..5634a4b7 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java @@ -24,7 +24,6 @@ import io.github.moulberry.notenoughupdates.core.config.Position; import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigAccordionId; import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorAccordion; import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorButton; import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDraggableList; import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown; import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; @@ -59,6 +58,15 @@ public class MiscOverlays { @ConfigAccordionId(id = 0) public boolean todoOverlayOnlyShowTab = false; + @Expose + @ConfigOption( + name = "Todo Overlay Hide Bingo", + desc = "Hide some tasks from the todo overlay while on a bingo profile: Cookie Buff, Godpot, Heavy Pearls, Crimson Isle Quests" + ) + @ConfigEditorBoolean + @ConfigAccordionId(id = 0) + public boolean todoOverlayHideAtBingo = true; + @Expose @ConfigOption( name = "Todo Text", diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java index 419c9785..90aa2984 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java @@ -898,12 +898,26 @@ public class TimersOverlay extends TextTabOverlay { overlayStrings = new ArrayList<>(); for (int index : NotEnoughUpdates.INSTANCE.config.miscOverlays.todoText2) { if (map.containsKey(index)) { - overlayStrings.add(map.get(index)); + String text = map.get(index); + if (hideBecauseOfBingo(text)) continue; + overlayStrings.add(text); } } if (overlayStrings.isEmpty()) overlayStrings = null; } + private boolean hideBecauseOfBingo(String text) { + if (!SBInfo.getInstance().bingo) return false; + if (!NotEnoughUpdates.INSTANCE.config.miscOverlays.todoOverlayHideAtBingo) return false; + + if (text.contains("Cookie Buff")) return true; + if (text.contains("Godpot")) return true; + if (text.contains("Heavy Pearls")) return true; + if (text.contains("Crimson Isle Quests")) return true; + + return false; + } + public static int beforePearls = -1; public static int afterPearls = -1; public static int availablePearls = -1; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java index 8ce765aa..d0af9091 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java @@ -86,6 +86,7 @@ public class SBInfo { public String objective = ""; public String slayer = ""; public boolean stranded = false; + public boolean bingo = false; public String mode = null; @@ -388,6 +389,7 @@ public class SBInfo { isInDungeon = tempIsInDungeon; boolean containsStranded = false; + boolean containsBingo = false; for (String line : lines) { //Slayer stuff if (line.contains("Tarantula Broodfather")) { slayer = "Tarantula"; @@ -422,8 +424,10 @@ public class SBInfo { } } if (line.contains("☀ Stranded")) containsStranded = true; + if (line.contains("Ⓑ Bingo")) containsBingo = true; } stranded = containsStranded; + bingo = containsBingo; if (lines.size() >= 5) { date = Utils.cleanColour(lines.get(1)).trim(); -- cgit From e87331858675faed39a090cfdd6f6c7ce3b3f0d0 Mon Sep 17 00:00:00 2001 From: Vixid <52578495+VixidDev@users.noreply.github.com> Date: Sat, 11 Feb 2023 11:42:16 +0000 Subject: Frozen treasure pet conflict fix (#571) * Added Highest Wave completed to Kuudra stats in pv * Revert "Added Highest Wave completed to Kuudra stats in pv" This reverts commit 83f78a9815f9d9c682dd5e452e001d853fd78922. * Resolves Frozen Treasure Highlighter thinking pets are treasures. (I hope) * Fixes bug with empty tag compounds --------- Co-authored-by: Vixid <52578495+vixid1@users.noreply.github.com> --- .../world/FrozenTreasuresHighlighter.java | 56 ++++++++++++++++++++-- 1 file changed, 52 insertions(+), 4 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/FrozenTreasuresHighlighter.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/FrozenTreasuresHighlighter.java index 2f8071a0..1a541433 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/FrozenTreasuresHighlighter.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/FrozenTreasuresHighlighter.java @@ -28,11 +28,14 @@ import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityArmorStand; import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; +import java.util.ArrayList; +import java.util.Base64; import java.util.List; @NEUAutoSubscribe @@ -40,6 +43,15 @@ public class FrozenTreasuresHighlighter extends GenericBlockHighlighter { private static final FrozenTreasuresHighlighter INSTANCE = new FrozenTreasuresHighlighter(); + private static final List rideablePetTextureUrls = new ArrayList() {{ + // Armadillo + add("http://textures.minecraft.net/texture/c1eb6df4736ae24dd12a3d00f91e6e3aa7ade6bbefb0978afef2f0f92461018f"); + // Rock + add("http://textures.minecraft.net/texture/cb2b5d48e57577563aca31735519cb622219bc058b1f34648b67b8e71bc0fa"); + // Rat + add("http://textures.minecraft.net/texture/a8abb471db0ab78703011979dc8b40798a941f3a4dec3ec61cbeec2af8cffe8"); + }}; + public static FrozenTreasuresHighlighter getInstance() {return INSTANCE;} @Override @@ -62,10 +74,46 @@ public class FrozenTreasuresHighlighter extends GenericBlockHighlighter { World w = Minecraft.getMinecraft().theWorld; if (w == null) return; List entities = w.getLoadedEntityList(); - for (Entity e : entities) { - if ((e instanceof EntityArmorStand) && ((EntityArmorStand) e).getCurrentArmor(3) != null) highlightedBlocks.add(e - .getPosition() - .add(0, 1, 0)); + for (Entity entity : entities) { + if ((entity instanceof EntityArmorStand) && + ((EntityArmorStand) entity).getCurrentArmor(3) != null) { + + // If an armor stand has a 'hat' with a NBTTagCompound check if it has a pet texture url + if (((EntityArmorStand) entity).getCurrentArmor(3).hasTagCompound()) { + NBTTagCompound nbtTagCompound = ((EntityArmorStand) entity).getCurrentArmor(3).getTagCompound(); + + // Get Base64 texture value from the tag compound + String textureValue = nbtTagCompound + .getCompoundTag("SkullOwner") + .getCompoundTag("Properties") + .getTagList("textures", 10) + .getCompoundTagAt(0) + .getString("Value"); + + // Decode and find texture url from the texture value + String trimmedJson = new String(Base64.getDecoder().decode(textureValue)).replace(" ", ""); + + + String textureUrl = ""; + if (trimmedJson.contains("url")) { + textureUrl = trimmedJson.substring( + trimmedJson.indexOf("url")+6, // Start of url + trimmedJson.substring( // Get the substring from the start of the url to the end of string + trimmedJson.indexOf("url")+6).indexOf("\"") // Get index of first " after start of url + + trimmedJson.indexOf("url")+6); // Add on the length of numbers up until the start of url to get correct index from overall string + } + + + // If the list of rideable pet texture urls doesn't include the found texture then it is a frozen treasure + if (!rideablePetTextureUrls.contains(textureUrl)) { + highlightedBlocks.add(entity.getPosition().add(0, 1, 0)); + } + } else { + // This is for frozen treasures which are just blocks i.e. Packed Ice, Enchanted Packed Ice etc. + // (Since I don't believe the blocks have NBTTagCompound data) + highlightedBlocks.add(entity.getPosition().add(0, 1, 0)); + } + } } } -- cgit From 3d9a03ff4f1e542339950be6a77cb4c59a46ab77 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Mon, 13 Feb 2023 14:03:22 +0100 Subject: Fix Muscle Memory (#581) * Added old SkyBlock Menu. * Execution! * Add cache. * Bingo has already enough to do. * Typo. * Revert "Typo." This reverts commit b4a1c385e0c410b1e111797b8d39e7ff64b09ef5. * Revert "Bingo has already enough to do." This reverts commit 6e004d2d65dff47ea3bee5c5789cb725724df6ed. * I am lazy. * The map is lazy too. * Hypixel moving features behind paywall. * Add red text to the setting too. * SEALED * Fixed Booster Cookie checks. Reworked CookieWarning, kept same logic but accidentally added profile switch support. * /trades does not require booster cookie. * Allowing middle clicks (and any other mouse click combination) --------- Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../miscfeatures/CookieWarning.java | 211 +++++++++++++-------- .../options/seperateSections/Misc.java | 9 + .../moulberry/notenoughupdates/util/SBInfo.java | 3 +- .../moulberry/notenoughupdates/util/Utils.java | 41 ++-- 4 files changed, 164 insertions(+), 100 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CookieWarning.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CookieWarning.java index 80751371..f130a993 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CookieWarning.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CookieWarning.java @@ -31,9 +31,13 @@ public class CookieWarning { private static boolean hasNotified; private static boolean hasErrorMessage; + private static long cookieEndTime = 0; + private static boolean hasCookie = true; + private static long lastChecked = 0; public static void resetNotification() { hasNotified = false; + hasCookie = true; NotificationHandler.cancelNotification(); } @@ -41,96 +45,135 @@ public class CookieWarning { * Checks the tab list for a cookie timer, and sends a notification if the timer is within the tolerance */ public static void checkCookie() { - if (NotEnoughUpdates.INSTANCE.config.notifications.doBoosterNotif && - NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) { - String[] lines; - try { - lines = ((AccessorGuiPlayerTabOverlay) Minecraft.getMinecraft().ingameGUI.getTabList()) - .getFooter() - .getUnformattedText() - .split("\n"); - } catch (NullPointerException e) { - return; // if the footer is null or somehow doesn't exist, stop + if (!NotEnoughUpdates.INSTANCE.config.notifications.doBoosterNotif || + !NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) { + return; + } + String timeLine = getTimeLine(); + if (!hasCookie) { + if (!hasNotified) { + NotificationHandler.displayNotification(Lists.newArrayList( + "§cBooster Cookie Ran Out!", + "§7Your Booster Cookie expired!", + "§7", + "§7Press X on your keyboard to close this notification" + ), true, true); + hasNotified = true; } - boolean hasCookie = true; - String timeLine = null; // the line that contains the cookie timer - for (int i = 0; i < lines.length; i++) { - if (lines[i].startsWith("Cookie Buff")) { - timeLine = lines[i + 1]; // the line after the "Cookie Buff" line - } - if (lines[i].startsWith("Not active! Obtain booster cookies from the")) { - hasCookie = false; - } + return; + } + if (timeLine == null) return; + + int minutes = getMinutesRemaining(timeLine); + if (minutes < NotEnoughUpdates.INSTANCE.config.notifications.boosterCookieWarningMins && !hasNotified) { + NotificationHandler.displayNotification(Lists.newArrayList( + "§cBooster Cookie Running Low!", + "§7Your Booster Cookie will expire in " + timeLine, + "§7", + "§7Press X on your keyboard to close this notification" + ), true, true); + hasNotified = true; + } + } + + private static int getMinutesRemaining(String timeLine) { + String clean = timeLine.replaceAll("(§.)", ""); + clean = clean.replaceAll("(\\d)([smhdy])", "$1 $2"); + String[] digits = clean.split(" "); + int minutes = 0; + try { + for (int i = 0; i < digits.length; i++) { + if (i % 2 == 1) continue; + + String number = digits[i]; + String unit = digits[i + 1]; + long val = Integer.parseInt(number); + switch (unit) { + case "Years": + case "Year": + minutes += val * 525600; + break; + case "Months": + case "Month": + minutes += val * 43200; + break; + case "Days": + case "Day": + minutes += val * 1440; + break; + case "Hours": + case "Hour": + case "h": + minutes += val * 60; + break; + case "Minutes": + case "Minute": + case "m": + minutes += val; + break; + } // ignore seconds } - if (!hasCookie) { - if (!hasNotified) { - NotificationHandler.displayNotification(Lists.newArrayList( - "\u00a7cBooster Cookie Ran Out!", - "\u00a77Your Booster Cookie expired!", - "\u00a77", - "\u00a77Press X on your keyboard to close this notification" - ), true, true); - hasNotified = true; - } - return; + } catch (NumberFormatException e) { + if (!hasErrorMessage) { + e.printStackTrace(); + Utils.addChatMessage(EnumChatFormatting.RED + + "NEU ran into an issue when retrieving the Booster Cookie Timer. Check the logs for details."); + hasErrorMessage = true; } - if (timeLine != null) { - String clean = timeLine.replaceAll("(\u00a7.)", ""); - clean = clean.replaceAll("(\\d)([smhdy])", "$1 $2"); - String[] digits = clean.split(" "); - int minutes = 0; - try { - for (int i = 0; i < digits.length; i++) { - if (i % 2 == 1) continue; + hasNotified = true; + } + return minutes; + } - String number = digits[i]; - String unit = digits[i + 1]; - long val = Integer.parseInt(number); - switch (unit) { - case "Years": - case "Year": - minutes += val * 525600; - break; - case "Months": - case "Month": - minutes += val * 43200; - break; - case "Days": - case "Day": - minutes += val * 1440; - break; - case "Hours": - case "Hour": - case "h": - minutes += val * 60; - break; - case "Minutes": - case "Minute": - case "m": - minutes += val; - break; - } // ignore seconds - } - } catch (NumberFormatException e) { - if (!hasErrorMessage) { - e.printStackTrace(); - Utils.addChatMessage(EnumChatFormatting.RED + - "NEU ran into an issue when retrieving the Booster Cookie Timer. Check the logs for details."); - hasErrorMessage = true; - } - hasNotified = true; - } - if (minutes < NotEnoughUpdates.INSTANCE.config.notifications.boosterCookieWarningMins && !hasNotified) { - NotificationHandler.displayNotification(Lists.newArrayList( - "\u00a7cBooster Cookie Running Low!", - "\u00a77Your Booster Cookie will expire in " + timeLine, - "\u00a77", - "\u00a77Press X on your keyboard to close this notification" - ), true, true); - hasNotified = true; - } + private static String getTimeLine() { + String[] lines; + try { + lines = ((AccessorGuiPlayerTabOverlay) Minecraft.getMinecraft().ingameGUI.getTabList()) + .getFooter() + .getUnformattedText() + .split("\n"); + } catch (NullPointerException ignored) { + return null; + } + String timeLine = null; // the line that contains the cookie timer + for (int i = 0; i < lines.length; i++) { + if (lines[i].startsWith("Cookie Buff")) { + timeLine = lines[i + 1]; // the line after the "Cookie Buff" line + } + if (lines[i].startsWith("Not active! Obtain booster cookies from the")) { + hasCookie = false; } } + return timeLine; + } + + public static boolean hasActiveBoosterCookie() { + long cookieEndTime = getCookieEndTime(); + return cookieEndTime > System.currentTimeMillis(); + } + + private static long getCookieEndTime() { + // Only updating every 10 seconds +// if (System.currentTimeMillis() > lastChecked + 10_000) return cookieEndTime; + if (lastChecked + 3_000 > System.currentTimeMillis()) return cookieEndTime; + + String timeLine = getTimeLine(); + if (hasCookie && timeLine != null) { + int minutes = getMinutesRemaining(timeLine); + cookieEndTime = System.currentTimeMillis() + (long) minutes * 60 * 1000; + } else { + cookieEndTime = 0; + } + + lastChecked = System.currentTimeMillis(); + return cookieEndTime; + } + public static void onProfileSwitch() { + resetNotification(); + hasErrorMessage = false; + cookieEndTime = 0; + hasCookie = true; + lastChecked = 0; } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java index 47e51eec..affaa68a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java @@ -311,4 +311,13 @@ public class Misc { @ConfigEditorBoolean public boolean dungeonGroupsPV = true; + @Expose + @ConfigOption( + name = "Old SkyBlock Menu", + desc = "Show old buttons in the SkyBlock Menu: Trade, Accessories, Potions, Quiver, Fishing and Sacks. " + + "§cOnly works with the booster cookie effect active." + ) + @ConfigEditorBoolean + public boolean oldSkyBlockMenu = false; + } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java index d0af9091..a89b281d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java @@ -24,6 +24,7 @@ import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe; import io.github.moulberry.notenoughupdates.listener.ScoreboardLocationChangeListener; +import io.github.moulberry.notenoughupdates.miscfeatures.CookieWarning; import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.LocationChangeEvent; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.MinionHelperManager; import io.github.moulberry.notenoughupdates.overlays.OverlayManager; @@ -477,7 +478,6 @@ public class SBInfo { .thenAccept(newJson -> mayorJson = newJson); } - public JsonObject getMayorJson() { return mayorJson; } @@ -486,6 +486,7 @@ public class SBInfo { if (!newProfile.equals(currentProfile)) { currentProfile = newProfile; MinionHelperManager.getInstance().onProfileSwitch(); + CookieWarning.onProfileSwitch(); } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index d5abcb77..38debbbc 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -925,6 +925,10 @@ public class Utils { return createItemStack(item, displayName, 0, lore); } + public static ItemStack createItemStackArray(Item item, String displayName, String[] lore) { + return createItemStack(item, displayName, 0, lore); + } + public static ItemStack createItemStack(Block item, String displayName, String... lore) { return createItemStack(Item.getItemFromBlock(item), displayName, lore); } @@ -932,17 +936,7 @@ public class Utils { public static ItemStack createItemStack(Item item, String displayName, int damage, String... lore) { ItemStack stack = new ItemStack(item, 1, damage); NBTTagCompound tag = new NBTTagCompound(); - NBTTagCompound display = new NBTTagCompound(); - NBTTagList Lore = new NBTTagList(); - - for (String line : lore) { - Lore.appendTag(new NBTTagString(line)); - } - - display.setString("Name", displayName); - display.setTag("Lore", Lore); - - tag.setTag("display", display); + addNameAndLore(tag, displayName, lore); tag.setInteger("HideFlags", 254); stack.setTagCompound(tag); @@ -950,6 +944,22 @@ public class Utils { return stack; } + private static void addNameAndLore(NBTTagCompound tag, String displayName, String[] lore) { + NBTTagCompound display = new NBTTagCompound(); + + display.setString("Name", displayName); + + if (lore != null) { + NBTTagList tagLore = new NBTTagList(); + for (String line : lore) { + tagLore.appendTag(new NBTTagString(line)); + } + display.setTag("Lore", tagLore); + } + + tag.setTag("display", display); + } + public static ItemStack editItemStackInfo( ItemStack itemStack, String displayName, @@ -979,15 +989,17 @@ public class Utils { return itemStack; } - public static ItemStack createSkull(String displayName, String uuid, String value) { + return createSkull(displayName, uuid, value, null); + } + + public static ItemStack createSkull(String displayName, String uuid, String value, String[] lore) { ItemStack render = new ItemStack(Items.skull, 1, 3); NBTTagCompound tag = new NBTTagCompound(); NBTTagCompound skullOwner = new NBTTagCompound(); NBTTagCompound properties = new NBTTagCompound(); NBTTagList textures = new NBTTagList(); NBTTagCompound textures_0 = new NBTTagCompound(); - NBTTagCompound display = new NBTTagCompound(); skullOwner.setString("Id", uuid); skullOwner.setString("Name", uuid); @@ -995,8 +1007,7 @@ public class Utils { textures_0.setString("Value", value); textures.appendTag(textures_0); - display.setString("Name", displayName); - tag.setTag("display", display); + addNameAndLore(tag, displayName, lore); properties.setTag("textures", textures); skullOwner.setTag("Properties", properties); -- cgit From b6d88d2cbb5985c56a28e9b3cadf1e111af14564 Mon Sep 17 00:00:00 2001 From: efefury <69400149+efefury@users.noreply.github.com> Date: Tue, 14 Feb 2023 06:07:21 +0000 Subject: Add event task & other things in Level Page (#607) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../profileviewer/level/LevelPage.java | 15 +-- .../profileviewer/level/task/CoreTaskLevel.java | 48 +++++++--- .../profileviewer/level/task/DungeonTaskLevel.java | 14 +-- .../profileviewer/level/task/EssenceTaskLevel.java | 16 ++-- .../profileviewer/level/task/EventTaskLevel.java | 106 +++++++++++++++++++++ .../profileviewer/level/task/MiscTaskLevel.java | 46 +++++---- .../level/task/SkillRelatedTaskLevel.java | 90 ++++++++--------- .../profileviewer/level/task/SlayingTaskLevel.java | 13 +-- .../profileviewer/level/task/StoryTaskLevel.java | 6 +- 9 files changed, 243 insertions(+), 111 deletions(-) create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/EventTaskLevel.java (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/LevelPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/LevelPage.java index 16abf251..770b295a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/LevelPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/LevelPage.java @@ -26,6 +26,7 @@ import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer; import io.github.moulberry.notenoughupdates.profileviewer.level.task.CoreTaskLevel; import io.github.moulberry.notenoughupdates.profileviewer.level.task.DungeonTaskLevel; import io.github.moulberry.notenoughupdates.profileviewer.level.task.EssenceTaskLevel; +import io.github.moulberry.notenoughupdates.profileviewer.level.task.EventTaskLevel; import io.github.moulberry.notenoughupdates.profileviewer.level.task.MiscTaskLevel; import io.github.moulberry.notenoughupdates.profileviewer.level.task.SkillRelatedTaskLevel; import io.github.moulberry.notenoughupdates.profileviewer.level.task.SlayingTaskLevel; @@ -61,6 +62,8 @@ public class LevelPage { private final SlayingTaskLevel slayingTaskLevel; private final StoryTaskLevel storyTaskLevel; + private final EventTaskLevel eventTaskLevel; + private static final ResourceLocation pv_levels = new ResourceLocation("notenoughupdates:pv_levels.png"); public LevelPage(GuiProfileViewer instance, BasicPage basicPage) { @@ -75,6 +78,7 @@ public class LevelPage { skillRelatedTaskLevel = new SkillRelatedTaskLevel(this); slayingTaskLevel = new SlayingTaskLevel(this); storyTaskLevel = new StoryTaskLevel(this); + eventTaskLevel = new EventTaskLevel(this); } public void drawPage(int mouseX, int mouseY) { @@ -97,13 +101,14 @@ public class LevelPage { JsonObject profileInfo = profile.getProfileInformation(profileId); drawMainBar(skyblockLevel, mouseX, mouseY, guiLeft, guiTop); - coreTaskLevel.drawTask(profileInfo, mouseX, mouseY, guiLeft, guiTop); dungeonTaskLevel.drawTask(profileInfo, mouseX, mouseY, guiLeft, guiTop); essenceTaskLevel.drawTask(profileInfo, mouseX, mouseY, guiLeft, guiTop); miscTaskLevel.drawTask(profileInfo, mouseX, mouseY, guiLeft, guiTop); skillRelatedTaskLevel.drawTask(profileInfo, mouseX, mouseY, guiLeft, guiTop); slayingTaskLevel.drawTask(profileInfo, mouseX, mouseY, guiLeft, guiTop); storyTaskLevel.drawTask(profileInfo, mouseX, mouseY, guiLeft, guiTop); + eventTaskLevel.drawTask(profileInfo, mouseX, mouseY, guiLeft, guiTop); + coreTaskLevel.drawTask(profileInfo, mouseX, mouseY, guiLeft, guiTop); } public void renderLevelBar( @@ -175,14 +180,12 @@ public class LevelPage { re