From 80cde86d9d1f357b964f5cdad3b8b71bc2ba6d33 Mon Sep 17 00:00:00 2001 From: Lulonaut <67191924+Lulonaut@users.noreply.github.com> Date: Thu, 21 Apr 2022 12:49:42 +0200 Subject: fix expand pet exp (#114) --- .../notenoughupdates/listener/ItemTooltipListener.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/main/java/io') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipListener.java index cc2b11e8..501ed8a3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipListener.java @@ -81,9 +81,9 @@ public class ItemTooltipListener { String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(event.itemStack); if (internalname == null) { - onItemToolTipInternalNameNull(event); return; } + petToolTipXPExtendPetMenu(event); boolean hasEnchantments = event.itemStack.getTagCompound().getCompoundTag("ExtraAttributes").hasKey( "enchantments", @@ -741,10 +741,6 @@ public class ItemTooltipListener { } } - private void onItemToolTipInternalNameNull(ItemTooltipEvent event) { - petToolTipXPExtendPetMenu(event); - } - private List petToolTipXPExtend(ItemTooltipEvent event) { List tooltipText = new ArrayList<>(); if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.petExtendExp) { @@ -929,7 +925,9 @@ public class ItemTooltipListener { } else if (NotEnoughUpdates.INSTANCE.packDevEnabled) { event.toolTip.add(""); event.toolTip.add(EnumChatFormatting.AQUA + "NEU Pack Dev Info:"); - event.toolTip.add(EnumChatFormatting.GRAY + "Press " + EnumChatFormatting.GOLD + "[KEY]" + EnumChatFormatting.GRAY + " to copy line"); + event.toolTip.add( + EnumChatFormatting.GRAY + "Press " + EnumChatFormatting.GOLD + "[KEY]" + EnumChatFormatting.GRAY + + " to copy line"); String internal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(event.itemStack); -- cgit From 15c0c229b51eebeab59031fbda541a8c85047312 Mon Sep 17 00:00:00 2001 From: NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> Date: Thu, 21 Apr 2022 15:52:41 +0000 Subject: fix wardrobe + blaze slayer and mining stats in pv (#115) --- .../moulberry/notenoughupdates/NEUOverlay.java | 102 +++------------------ .../miscfeatures/PetInfoOverlay.java | 2 +- .../options/seperateSections/CustomArmour.java | 4 +- .../profileviewer/GuiProfileViewer.java | 29 +++++- .../profileviewer/PlayerStats.java | 31 ++++++- .../profileviewer/ProfileViewer.java | 19 +++- 6 files changed, 89 insertions(+), 98 deletions(-) (limited to 'src/main/java/io') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index 8d0955bb..f473a56f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -1871,9 +1871,7 @@ public class NEUOverlay extends Gui { ContainerChest container = (ContainerChest) chest.inventorySlots; IInventory lower = container.getLowerChestInventory(); String containerName = lower.getDisplayName().getUnformattedText(); - if (containerName.contains(guiName)) { - wardrobeOpen = true; - } else wardrobeOpen = false; + wardrobeOpen = containerName.contains(guiName); } if (guiScreen instanceof GuiInventory) { wardrobeOpen = false; @@ -1881,27 +1879,6 @@ public class NEUOverlay extends Gui { return wardrobeOpen; } - private int wardrobePage = -1; - - private int getWardrobePage() { - GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen; - if (guiScreen instanceof GuiChest) { - if (isInNamedGui("Wardrobe")) { - GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; - ContainerChest container = (ContainerChest) chest.inventorySlots; - IInventory lower = container.getLowerChestInventory(); - String containerName = lower.getDisplayName().getUnformattedText(); - try { - wardrobePage = Integer.parseInt(containerName.substring(10, 11)); - } catch (NumberFormatException e) { - System.out.println(containerName.charAt(10)); - System.out.println("Did hypixel change the wardrobe string?"); - wardrobePage = -1; - } - } else wardrobePage = -1; - } - return wardrobePage; - } private ItemStack getChestSlotsAsItemStack(int slot) { GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen; @@ -1913,61 +1890,13 @@ public class NEUOverlay extends Gui { } } - private int selectedArmor = 9; - - private int getEquippedArmor() { - if (isInNamedGui("Wardrobe")) { - ItemStack nullTest1 = getChestSlotsAsItemStack(8); - ItemStack nullTest2 = getChestSlotsAsItemStack(17); - ItemStack nullTest3 = getChestSlotsAsItemStack(26); - ItemStack nullTest4 = getChestSlotsAsItemStack(35); - ItemStack nullTest5 = getChestSlotsAsItemStack(44); - if (nullTest1 != null || nullTest2 != null || nullTest3 != null || nullTest4 != null || nullTest5 != null) { - selectedArmor = 9; - } - for (int ii = 1; ii < 5; ii++) { - if (ii == 1 || selectedArmor == 9) { - if (getWardrobePage() == ii) { - for (int i = 8; i < 54; i += 9) { - ItemStack stack1 = getChestSlotsAsItemStack(i); - if (stack1 != null) { - String[] lore1 = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack1.getTagCompound()); - for (String line : lore1) { - //System.out.println(line); - if (line.contains("to unequip this armor")) { - selectedArmor = i; - break; - } - } - } - } - } - } - } - } - return selectedArmor; - } private ItemStack getWardrobeSlot(int armourSlot) { - if (isInNamedGui("Wardrobe")) { - if (getChestSlotsAsItemStack(getEquippedArmor() - armourSlot) != null && getEquippedArmor() != 9) { - return getChestSlotsAsItemStack(getEquippedArmor() - armourSlot); - } else return null; + if (isInNamedGui("Your Equipment")) { + return getChestSlotsAsItemStack(armourSlot); } else return null; } - public boolean isWardrobeSystemOnMainServer() { - JsonElement alphaWardrobeElement = Utils.getElement(Constants.DISABLE, "wardrobeFeature"); - if (alphaWardrobeElement == null || !alphaWardrobeElement.isJsonObject()) { - return true; - } - JsonObject isWardrobe = alphaWardrobeElement.getAsJsonObject(); - if (isWardrobe.has("enableNewWardrob")) { - return isWardrobe.get("enableNewWardrob").getAsBoolean(); - } else { - return true; - } - } public ItemStack slot1 = null; public ItemStack slot2 = null; @@ -2019,16 +1948,15 @@ public class NEUOverlay extends Gui { if (NotEnoughUpdates.INSTANCE.config.customArmour.enableArmourHud && NotEnoughUpdates.INSTANCE.config.misc.hidePotionEffect - && NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && isWardrobeSystemOnMainServer()) { - if (getWardrobeSlot(1) != null) { - slot1 = getWardrobeSlot(4); - slot2 = getWardrobeSlot(3); - slot3 = getWardrobeSlot(2); - slot4 = getWardrobeSlot(1); + && NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) { + if (getWardrobeSlot(10) != null) { + slot1 = getWardrobeSlot(10); + slot2 = getWardrobeSlot(19); + slot3 = getWardrobeSlot(28); + slot4 = getWardrobeSlot(37); } if (guiScreen instanceof GuiInventory) { renderingArmorHud = true; - selectedArmor = 9; List tooltipToDisplay = null; if (NotEnoughUpdates.INSTANCE.config.customArmour.colourStyle == 0) { @@ -2070,7 +1998,7 @@ public class NEUOverlay extends Gui { tooltipToDisplay = Lists.newArrayList( EnumChatFormatting.RED + "Warning", - EnumChatFormatting.GREEN + "You need to open /wardrobe", + EnumChatFormatting.GREEN + "You need to open /equipment", EnumChatFormatting.GREEN + "To cache your armour" ); if (mouseX >= ((width - 208) / 2f) && mouseX < ((width - 208) / 2f) + 16) { @@ -2078,9 +2006,9 @@ public class NEUOverlay extends Gui { NotEnoughUpdates.INSTANCE.config.customArmour.sendWardrobeCommand) { if (Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null) { if (Mouse.getEventButtonState()) { - if (ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/wardrobe") == + if (ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/equipment") == 0) { - NotEnoughUpdates.INSTANCE.sendChatMessage("/wardrobe"); + NotEnoughUpdates.INSTANCE.sendChatMessage("/equipment"); } } } @@ -2098,9 +2026,9 @@ public class NEUOverlay extends Gui { NotEnoughUpdates.INSTANCE.config.customArmour.sendWardrobeCommand) { if (Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null) { if (Mouse.getEventButtonState()) { - if (ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/wardrobe") == + if (ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/equipment") == 0) { - NotEnoughUpdates.INSTANCE.sendChatMessage("/wardrobe"); + NotEnoughUpdates.INSTANCE.sendChatMessage("/equipment"); } } } @@ -2172,7 +2100,7 @@ public class NEUOverlay extends Gui { if (guiScreen instanceof GuiInventory) { GL11.glTranslatef(0, 0, 401); - if (!NotEnoughUpdates.INSTANCE.config.customArmour.enableArmourHud || !isWardrobeSystemOnMainServer()) { + if (!NotEnoughUpdates.INSTANCE.config.customArmour.enableArmourHud) { if (NotEnoughUpdates.INSTANCE.config.petOverlay.colourStyle == 0) { Minecraft.getMinecraft().getTextureManager().bindTexture(PET_DISPLAY); } 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 281830c3..6203a36d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java @@ -812,7 +812,7 @@ public class PetInfoOverlay extends TextOverlay { if (currentTime - lastPetSelect > 500) { boolean foundDespawn = false; for (String line : lore) { - if (line.equals("\u00a77\u00a7cClick to despawn.")) { + if (line.startsWith("\u00a77\u00a7cClick to despawn")) { config.selectedPet = petIndex; foundDespawn = true; break; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/CustomArmour.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/CustomArmour.java index f1b2338f..edfd2276 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/CustomArmour.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/CustomArmour.java @@ -17,8 +17,8 @@ public class CustomArmour { @Expose @ConfigOption( - name = "Click To Open Wardrobe", - desc = "Click on the hud to open /wardrobe" + name = "Click To Open equipment menu", + desc = "Click on the hud to open /equipment" ) @ConfigEditorBoolean public boolean sendWardrobeCommand = true; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java index 691ccaae..597b6b4d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java @@ -7,6 +7,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; import com.mojang.authlib.GameProfile; +import io.github.moulberry.notenoughupdates.NEUOverlay; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.cosmetics.ShaderManager; import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField; @@ -3325,6 +3326,10 @@ public class GuiProfileViewer extends GuiScreen { Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.enderman.boss_kills_tier_2"), 0); float enderman_boss_kills_tier_3 = Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.enderman.boss_kills_tier_3"), 0); + float blaze_boss_kills_tier_2 = + Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.blaze.boss_kills_tier_2"), 0); + float blaze_boss_kills_tier_3 = + Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.blaze.boss_kills_tier_3"), 0); Utils.renderAlignedString( EnumChatFormatting.DARK_AQUA + "Revenant T3", @@ -3390,6 +3395,20 @@ public class GuiProfileViewer extends GuiScreen { guiTop + yStartBottom + yOffset * 3, 76 ); + Utils.renderAlignedString( + EnumChatFormatting.DARK_AQUA + "Inferno T3", + EnumChatFormatting.WHITE.toString() + (int) blaze_boss_kills_tier_2, + guiLeft + xStart + xOffset * 2, + guiTop + yStartBottom + yOffset * 4, + 76 + ); + Utils.renderAlignedString( + EnumChatFormatting.DARK_AQUA + "Inferno T4", + EnumChatFormatting.WHITE.toString() + (int) blaze_boss_kills_tier_3, + guiLeft + xStart + xOffset * 2, + guiTop + yStartBottom + yOffset * 5, + 76 + ); float pet_milestone_ores_mined = Utils.getElementAsFloat(Utils.getElement(profileInfo, "stats.pet_milestone_ores_mined"), 0); @@ -4972,7 +4991,7 @@ public class GuiProfileViewer extends GuiScreen { Splitter splitter = Splitter.on(" ").omitEmptyStrings().limit(2); for (int i = 0; i < PlayerStats.defaultStatNames.length; i++) { String statName = PlayerStats.defaultStatNames[i]; - if (statName.equals("mining_fortune") || statName.equals("mining_speed")) continue; + //if (statName.equals("mining_fortune") || statName.equals("mining_speed")) continue; String statNamePretty = PlayerStats.defaultStatNamesPretty[i]; int val = Math.round(stats.get(statName)); @@ -4989,7 +5008,7 @@ public class GuiProfileViewer extends GuiScreen { statNamePretty, EnumChatFormatting.WHITE.toString() + val, guiLeft + 132, - guiTop + 27 + 11f * i, + guiTop + 21 + 11f * i, 80 ); @@ -5038,8 +5057,8 @@ public class GuiProfileViewer extends GuiScreen { continue; } - int yPosition = position % 7; - int xPosition = position / 7; + int yPosition = position % 8; + int xPosition = position / 8; String skillName = entry.getValue().getDisplayName(); @@ -5047,7 +5066,7 @@ public class GuiProfileViewer extends GuiScreen { int levelFloored = (int) Math.floor(level); int x = guiLeft + 237 + 86 * xPosition; - int y = guiTop + 31 + 21 * yPosition; + int y = guiTop + 24 + 21 * yPosition; Utils.renderAlignedString(skillName, EnumChatFormatting.WHITE.toString() + levelFloored, x + 14, y - 4, 60); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java index 4a915111..6535a99a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java @@ -33,6 +33,8 @@ public class PlayerStats { public static final String SEA_CREATURE_CHANCE = "sea_creature_chance"; public static final String MAGIC_FIND = "magic_find"; public static final String PET_LUCK = "pet_luck"; + public static final String MINING_FORTUNE = "mining_fortune"; + public static final String MINING_SPEED = "mining_speed"; public static final String[] defaultStatNames = new String[]{ "health", @@ -245,6 +247,23 @@ public class PlayerStats { return 0; } } + private static float hotmFortune(JsonObject profile, JsonObject skillInfo) { + int miningLevelFortune = + (int) (4 * (float) Math.floor(Utils.getElementAsFloat(Utils.getElement(skillInfo, "level_skill_mining"), 0))); + int miningFortuneStat = + ((Utils.getElementAsInt(Utils.getElement(profile, "mining_core.nodes.mining_fortune"), 0)) * 5); + int miningFortune2Stat = + ((Utils.getElementAsInt(Utils.getElement(profile, "mining_core.nodes.mining_fortune_2"), 0)) * 5); + return miningFortuneStat + miningFortune2Stat + miningLevelFortune; + } + + private static float hotmSpeed(JsonObject profile) { + int miningSpeedStat = + ((Utils.getElementAsInt(Utils.getElement(profile, "mining_core.nodes.mining_speed"), 0)) * 20); + int miningSpeed2Stat = + ((Utils.getElementAsInt(Utils.getElement(profile, "mining_core.nodes.mining_speed_2"), 0)) * 40); + return miningSpeedStat + miningSpeed2Stat; + } public static Stats getPassiveBonuses(JsonObject skillInfo, JsonObject profile) { Stats passiveBonuses = new Stats(); @@ -265,6 +284,15 @@ public class PlayerStats { return passiveBonuses; } + public static Stats getHOTMBonuses(JsonObject skillInfo, JsonObject profile) { + Stats hotmBonuses = new Stats(); + + hotmBonuses.addStat(MINING_FORTUNE, hotmFortune(profile, skillInfo)); + hotmBonuses.addStat(MINING_SPEED, hotmSpeed(profile)); + + return hotmBonuses; + } + private static String getFullset(JsonArray armor, int ignore) { String fullset = null; for (int i = 0; i < armor.size(); i++) { @@ -637,6 +665,7 @@ public class PlayerStats { JsonArray talisman_bag = Utils.getElement(inventoryInfo, "talisman_bag").getAsJsonArray(); Stats passiveBonuses = getPassiveBonuses(skillInfo, profile); + Stats hotmBonuses = getHOTMBonuses(skillInfo, profile); Stats armorBonuses = getItemBonuses(false, armor); Stats talismanBonuses = getItemBonuses(true, inventory, talisman_bag); @@ -651,7 +680,7 @@ public class PlayerStats { Stats petBonus = getPetStatBonuses(petsInfo); - stats = stats.add(passiveBonuses).add(armorBonuses).add(talismanBonuses).add(petBonus); + stats = stats.add(passiveBonuses).add(armorBonuses).add(talismanBonuses).add(petBonus).add(hotmBonuses); stats.add(getSetBonuses(stats, inventoryInfo, collectionInfo, skillInfo, profile)); 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 22656b1a..28cdf721 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java @@ -70,6 +70,7 @@ public class ProfileViewer { put("slayer_spider", Utils.createItemStack(Items.spider_eye, EnumChatFormatting.GOLD + "Tara Slayer")); put("slayer_wolf", Utils.createItemStack(Items.bone, EnumChatFormatting.GOLD + "Sven Slayer")); put("slayer_enderman", Utils.createItemStack(Items.ender_pearl, EnumChatFormatting.GOLD + "Ender Slayer")); + put("slayer_blaze", Utils.createItemStack(Items.blaze_rod, EnumChatFormatting.GOLD + "Blaze Slayer")); }}; private static final ItemStack CAT_FARMING = Utils.createItemStack(Items.golden_hoe, EnumChatFormatting.YELLOW + "Farming"); @@ -96,7 +97,7 @@ public class ProfileViewer { )); put(CAT_FORAGING, Utils.createList("LOG", "LOG:1", "LOG:2", "LOG_2:1", "LOG_2", "LOG:3", null)); put(CAT_FISHING, Utils.createList("RAW_FISH", "RAW_FISH:1", "RAW_FISH:2", "RAW_FISH:3", "PRISMARINE_SHARD", - "PRISMARINE_CRYSTALS", "CLAY_BALL", "WATER_LILY", "INK_SACK", "SPONGE" + "PRISMARINE_CRYSTALS", "CLAY_BALL", "WATER_LILY", "INK_SACK", "SPONGE", "MAGMA_FISH" )); }}; @@ -110,7 +111,7 @@ public class ProfileViewer { "MITHRIL", "HARD_STONE", null )); put(CAT_COMBAT, Utils.createList("ZOMBIE", "SKELETON", "SPIDER", "CAVESPIDER", "CREEPER", "ENDERMAN", - "GHAST", "SLIME", "BLAZE", "MAGMA_CUBE", "REVENANT", "TARANTULA", "VOIDLING" + "GHAST", "SLIME", "BLAZE", "MAGMA_CUBE", "REVENANT", "TARANTULA", "VOIDLING", "INFERNO" )); put(CAT_FORAGING, Utils.createList("OAK", "SPRUCE", "BIRCH", "DARK_OAK", "ACACIA", "JUNGLE", "FLOWER")); put(CAT_FISHING, Utils.createList("FISHING", null, null, null, null, null, "CLAY", null, null, null)); @@ -238,6 +239,11 @@ public class ProfileViewer { ); put("INK_SACK", Utils.createItemStack(Items.dye, EnumChatFormatting.AQUA + "Ink Sack")); put("SPONGE", Utils.createItemStack(Item.getItemFromBlock(Blocks.sponge), EnumChatFormatting.AQUA + "Sponge")); + put("MAGMA_FISH", + Utils.createSkull(EnumChatFormatting.AQUA + "Magmafish", + "5c53195c-5b98-3476-9731-c32647b22723", + "ewogICJ0aW1lc3RhbXAiIDogMTY0MjQ4ODA3MDY2NiwKICAicHJvZmlsZUlkIiA6ICIzNDkxZjJiOTdjMDE0MWE2OTM2YjFjMjJhMmEwMGZiNyIsCiAgInByb2ZpbGVOYW1lIiA6ICJKZXNzc3N1aGgiLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjU2YjU5NTViMjk1NTIyYzk2ODk0ODE5NjBjMDFhOTkyY2ExYzc3NTRjZjRlZTMxM2M4ZGQwYzM1NmQzMzVmIgogICAgfQogIH0KfQ") + ); }}; private static final AtomicBoolean updatingResourceCollection = new AtomicBoolean(false); private static JsonObject resourceCollection = null; @@ -867,6 +873,8 @@ public class ProfileViewer { float experience_slayer_wolf = Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.wolf.xp"), 0); float experience_slayer_enderman = Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.enderman.xp"), 0); + float experience_slayer_blaze = + Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.blaze.xp"), 0); float totalSkillXP = experience_skill_taming + experience_skill_mining + experience_skill_foraging + experience_skill_enchanting + experience_skill_carpentry + experience_skill_farming @@ -897,6 +905,7 @@ public class ProfileViewer { skillInfo.addProperty("experience_slayer_spider", experience_slayer_spider); skillInfo.addProperty("experience_slayer_wolf", experience_slayer_wolf); skillInfo.addProperty("experience_slayer_enderman", experience_slayer_enderman); + skillInfo.addProperty("experience_slayer_blaze", experience_slayer_blaze); JsonArray levelingArray = Utils.getElement(leveling, "leveling_xp").getAsJsonArray(); int farmingCap = getCap(leveling, "farming") + (int) Utils.getElementAsFloat( @@ -933,6 +942,9 @@ public class ProfileViewer { Level level_slayer_enderman = getLevel(Utils.getElement(leveling, "slayer_xp.enderman").getAsJsonArray(), experience_slayer_enderman, 9, true ); + Level level_slayer_blaze = getLevel(Utils.getElement(leveling, "slayer_xp.blaze").getAsJsonArray(), + experience_slayer_blaze, 9, true + ); skillInfo.addProperty("level_skill_taming", level_skill_taming.level); skillInfo.addProperty("level_skill_mining", level_skill_mining.level); @@ -951,6 +963,7 @@ public class ProfileViewer { skillInfo.addProperty("level_slayer_spider", level_slayer_spider.level); skillInfo.addProperty("level_slayer_wolf", level_slayer_wolf.level); skillInfo.addProperty("level_slayer_enderman", level_slayer_enderman.level); + skillInfo.addProperty("level_slayer_blaze", level_slayer_blaze.level); skillInfo.addProperty("maxed_skill_taming", level_skill_taming.maxed); skillInfo.addProperty("maxed_skill_mining", level_skill_mining.maxed); @@ -969,6 +982,7 @@ public class ProfileViewer { skillInfo.addProperty("maxed_slayer_spider", level_slayer_spider.maxed); skillInfo.addProperty("maxed_slayer_wolf", level_slayer_wolf.maxed); skillInfo.addProperty("maxed_slayer_enderman", level_slayer_enderman.maxed); + skillInfo.addProperty("maxed_slayer_blaze", level_slayer_blaze.maxed); skillInfo.addProperty("maxxp_skill_taming", level_skill_taming.maxXpForLevel); skillInfo.addProperty("maxxp_skill_mining", level_skill_mining.maxXpForLevel); @@ -987,6 +1001,7 @@ public class ProfileViewer { skillInfo.addProperty("maxxp_slayer_spider", level_slayer_spider.maxXpForLevel); skillInfo.addProperty("maxxp_slayer_wolf", level_slayer_wolf.maxXpForLevel); skillInfo.addProperty("maxxp_slayer_enderman", level_slayer_enderman.maxXpForLevel); + skillInfo.addProperty("maxxp_slayer_blaze", level_slayer_blaze.maxXpForLevel); return skillInfo; } -- cgit From 68b565d762c549bf5c1fe6bb2b57b14c37618a1e Mon Sep 17 00:00:00 2001 From: CraftyOldMiner <85420839+CraftyOldMiner@users.noreply.github.com> Date: Sat, 23 Apr 2022 06:33:40 -0500 Subject: Fix Skytils wishing compass waypoint creation that Skytils update broke (#116) --- .../notenoughupdates/miscfeatures/CrystalWishingCompassSolver.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/io') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalWishingCompassSolver.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalWishingCompassSolver.java index 977ef818..9686e97a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalWishingCompassSolver.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalWishingCompassSolver.java @@ -757,7 +757,7 @@ public class CrystalWishingCompassSolver { String targetNameForSkytils = solutionPossibleTargets.size() == 1 ? getNameForCompassTarget(solutionPossibleTargets.iterator().next()) : "WishingTarget"; - String skytilsCommand = String.format("/sthw add %s %s", targetNameForSkytils, getSolutionCoordsText()); + String skytilsCommand = String.format("/sthw add %s %s", getSolutionCoordsText(), targetNameForSkytils); if (NotEnoughUpdates.INSTANCE.config.mining.wishingCompassAutocreateKnownWaypoints && solutionPossibleTargets.size() == 1) { mc.thePlayer.addChatMessage(new ChatComponentText(destinationMessage)); -- cgit From 79bc28639e966415a97b1f21dd11617c6a4e0215 Mon Sep 17 00:00:00 2001 From: Cobble8 <41165207+Cobble8@users.noreply.github.com> Date: Wed, 27 Apr 2022 14:56:23 -0400 Subject: HEAVY PEARL TODO TIMER THING (#120) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * HEAVY PEARL TODO TIMER THING yay hopefully this works idk don't wanna wait 21 hours to test it again but Im pretty confident it works * fix bad change thing hopefully idk maybe * fix formatting + 2.1.md 🙂 * fix formatting * fixed heavy pearls overriding gemstone powder Co-authored-by: NopoTheGamer --- .../notenoughupdates/listener/ChatListener.java | 2 + .../listener/ScoreboardLocationChangeListener.java | 30 ++++++++ .../notenoughupdates/options/NEUConfig.java | 2 + .../options/seperateSections/MiscOverlays.java | 16 +++- .../notenoughupdates/overlays/TimersOverlay.java | 86 +++++++++++++++++++++- .../moulberry/notenoughupdates/util/SBInfo.java | 5 +- 6 files changed, 137 insertions(+), 4 deletions(-) create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/listener/ScoreboardLocationChangeListener.java (limited to 'src/main/java/io') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java index d40a39f1..060dcb80 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java @@ -6,6 +6,7 @@ import io.github.moulberry.notenoughupdates.miscfeatures.CrystalMetalDetectorSol import io.github.moulberry.notenoughupdates.miscfeatures.StreamerMode; import io.github.moulberry.notenoughupdates.overlays.OverlayManager; import io.github.moulberry.notenoughupdates.overlays.SlayerOverlay; +import io.github.moulberry.notenoughupdates.overlays.TimersOverlay; import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; @@ -122,6 +123,7 @@ public class ChatListener { public void onGuiChat(ClientChatReceivedEvent e) { if (e.type == 2) { CrystalMetalDetectorSolver.process(e.message); + TimersOverlay.processActionBar(e.message.getUnformattedText()); e.message = processChatComponent(e.message); return; } else if (e.type == 0) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/ScoreboardLocationChangeListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/ScoreboardLocationChangeListener.java new file mode 100644 index 00000000..2f4ec33c --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/ScoreboardLocationChangeListener.java @@ -0,0 +1,30 @@ +package io.github.moulberry.notenoughupdates.listener; + +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.overlays.TimersOverlay; + +public class ScoreboardLocationChangeListener { + + public ScoreboardLocationChangeListener(String oldLocation, String newLocation) { + if (oldLocation.equals("Belly of the Beast") && newLocation.equals("Matriarchs Lair")) { + //Check inventory pearl count for AFTER they complete to see if it is the same as before + (amount available on actionbar) + Thread thread = new Thread(() -> { + try { + Thread.sleep(3000); + TimersOverlay.afterPearls = TimersOverlay.heavyPearlCount(); + //Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW+"You exited the beast with ["+EnumChatFormatting.AQUA+(TimersOverlay.afterPearls-TimersOverlay.beforePearls)+EnumChatFormatting.YELLOW+"/"+EnumChatFormatting.AQUA+TimersOverlay.availablePearls+EnumChatFormatting.YELLOW+"] Heavy Pearls!")); + if (TimersOverlay.afterPearls - TimersOverlay.beforePearls == TimersOverlay.availablePearls) { + NotEnoughUpdates.INSTANCE.config.getProfileSpecific().dailyHeavyPearlCompleted = System.currentTimeMillis(); + //Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN+"Daily "+EnumChatFormatting.DARK_AQUA+"Heavy Pearls"+EnumChatFormatting.GREEN+" Complete!")); + } + } catch (InterruptedException e) { + e.printStackTrace(); + } + }); + thread.start(); + } else if (oldLocation.equals("Matriarchs Lair") && newLocation.equals("Belly of the Beast")) { + //Check inventory pearl count BEFORE they complete so we can later check if it is complete. + TimersOverlay.beforePearls = TimersOverlay.heavyPearlCount(); + } + } +} 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 68449ba8..5c766254 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java @@ -510,6 +510,8 @@ public class NEUConfig extends Config { public long dailyGemstonePowderCompleted = 0L; @Expose public long dailyMithrilPowerCompleted = 0L; + @Expose + public long dailyHeavyPearlCompleted = 0L; } public HiddenLocationSpecific getLocationSpecific() { 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 849f5823..616e8188 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 @@ -42,10 +42,11 @@ public class MiscOverlays { "\u00a73Experiments: \u00a7e3h38m", "\u00a73Daily Mithril Powder: \u00a7e3h38m", "\u00a73Daily Gemstone Powder: \u00a7e3h38m", + "\u00a73Daily Heavy Pearls: \u00a7e3h38m", } ) @ConfigAccordionId(id = 0) - public List todoText2 = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8)); + public List todoText2 = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)); @ConfigOption( name = "Show Only If Soon", @@ -163,6 +164,19 @@ public class MiscOverlays { ) public int dailyGemstonePowderDisplay = 0; + @Expose + @ConfigOption( + name = "Daily Heavy Pearl Display", + desc = "Change the way the daily heavy pearl displays\n" + + "Only when ready, When very Soon, When soon, When kinda soon or always." + ) + @ConfigAccordionId(id = 1) + @ConfigEditorDropdown( + values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"} + ) + + public int dailyHeavyPearlDisplay = 0; + @ConfigOption( name = "Colours", desc = "" 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 ede30448..59a77ea3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java @@ -13,6 +13,7 @@ import net.minecraft.init.Items; import net.minecraft.inventory.ContainerChest; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.fml.common.eventhandler.EventPriority; @@ -186,6 +187,11 @@ public class TimersOverlay extends TextOverlay { .getItemInformation() .get("PERFECT_AMETHYST_GEM")); break; + case "Daily Heavy Pearls": + icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager + .getItemInformation() + .get("HEAVY_PEARL")); + break; } if (icon != null) { @@ -529,6 +535,7 @@ public class TimersOverlay extends TextOverlay { } long midnightReset = (currentTime - 18000000) / 86400000 * 86400000 + 18000000; // 12am est + long pearlsReset = midnightReset - 14400000 + 86400000; //8pm est long catacombsReset = currentTime / 86400000 * 86400000; // 7pm est long timeDiffMidnightNow = midnightReset + 86400000 - currentTime; long catacombsDiffNow = catacombsReset + 86400000 - currentTime; @@ -743,6 +750,49 @@ public class TimersOverlay extends TextOverlay { ); } + //Daily Heavy Pearl Display + if (hidden.dailyHeavyPearlCompleted < pearlsReset) { + map.put( + 9, + DARK_AQUA + "Daily Heavy Pearls: " + + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.readyColour] + "Ready!" + ); + } else if ( + NotEnoughUpdates.INSTANCE.config.miscOverlays.dailyHeavyPearlDisplay >= DISPLAYTYPE.VERYSOON.ordinal() && + (hidden.dailyHeavyPearlCompleted < (pearlsReset - TimeEnums.HALFANHOUR.time))) { + map.put( + 9, + DARK_AQUA + "Daily Heavy Pearls: " + + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.verySoonColour] + + Utils.prettyTime(pearlsReset + 86400000 - currentTime) + ); + } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.dailyHeavyPearlDisplay >= DISPLAYTYPE.SOON.ordinal() && + (hidden.dailyHeavyPearlCompleted < (pearlsReset - TimeEnums.HOUR.time))) { + map.put( + 9, + DARK_AQUA + "Daily Heavy Pearls: " + + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.soonColour] + + Utils.prettyTime(pearlsReset + 86400000 - currentTime) + ); + } else if ( + NotEnoughUpdates.INSTANCE.config.miscOverlays.dailyHeavyPearlDisplay >= DISPLAYTYPE.KINDASOON.ordinal() && + (hidden.dailyHeavyPearlCompleted < (pearlsReset - (TimeEnums.HOUR.time * 3)))) { + map.put( + 9, + DARK_AQUA + "Daily Heavy Pearls: " + + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.kindaSoonColour] + + Utils.prettyTime(pearlsReset + 86400000 - currentTime) + ); + } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.dailyHeavyPearlDisplay >= + DISPLAYTYPE.ALWAYS.ordinal()) { + map.put( + 9, + DARK_AQUA + "Daily Heavy Pearls: " + + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.defaultColour] + + Utils.prettyTime(pearlsReset + 86400000 - currentTime) + ); + } + overlayStrings = new ArrayList<>(); for (int index : NotEnoughUpdates.INSTANCE.config.miscOverlays.todoText2) { if (map.containsKey(index)) { @@ -752,8 +802,40 @@ public class TimersOverlay extends TextOverlay { if (overlayStrings.isEmpty()) overlayStrings = null; } - public String compactRemaining(int amount) { - return (5 - amount) + " remaining"; + public static int beforePearls = -1; + public static int afterPearls = -1; + public static int availablePearls = -1; + public static int heavyPearlCount() { + int heavyPearls = 0; + + List inventory = Minecraft.getMinecraft().thePlayer.inventoryContainer.getInventory(); + for (ItemStack item : inventory) { + if (item == null) { + continue; + } else if (!item.hasTagCompound()) { + continue; + } + NBTTagCompound itemData = item.getSubCompound("ExtraAttributes", false); + if (itemData == null) { + continue; + } + if (itemData.getString("id").equals("HEAVY_PEARL")) { + heavyPearls += item.stackSize; + } + } + return heavyPearls; + } + + public static void processActionBar(String msg) { + if(SBInfo.getInstance().location.equals("Belly of the Beast")) { + try { + msg = Utils.cleanColour(msg); + msg = msg.substring(msg.indexOf("Pearls Collected: ")+18); + availablePearls = Integer.parseInt(msg.substring(msg.indexOf("/")+1)); + } catch(Exception e) { + e.printStackTrace(); + } + } } private enum TimeEnums { 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 f1e40671..6519d547 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java @@ -3,6 +3,7 @@ package io.github.moulberry.notenoughupdates.util; import com.google.common.reflect.TypeToken; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.listener.ScoreboardLocationChangeListener; import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.LocationChangeEvent; import io.github.moulberry.notenoughupdates.overlays.SlayerOverlay; import net.minecraft.client.Minecraft; @@ -367,7 +368,9 @@ public class SBInfo { //Replaced with for loop because in crystal hollows with events the line it's on can shift. for (String line : lines) { if (line.contains("⏣")) { - location = Utils.cleanColour(line).replaceAll("[^A-Za-z0-9() ]", "").trim(); + String l = Utils.cleanColour(line).replaceAll("[^A-Za-z0-9() ]", "").trim(); + if(!l.equals(location)) { new ScoreboardLocationChangeListener(location, l); } + location = l; break; } } -- cgit From 0418460b5ff12af5bc0b4078ec43210489d6ae99 Mon Sep 17 00:00:00 2001 From: CraftyOldMiner <85420839+CraftyOldMiner@users.noreply.github.com> Date: Sat, 30 Apr 2022 09:17:14 -0500 Subject: Crash & perf fixes (#121) - Fix crash in profile viewer when name not found - Parse numbers using exception-free methods in hot code paths - Update price graph to handle items transitioning from the bz to ah --- .../notenoughupdates/auction/APIManager.java | 2 +- .../listener/ItemTooltipListener.java | 74 +-------- .../notenoughupdates/miscgui/GuiPriceGraph.java | 175 ++++++++++++--------- .../profileviewer/GuiProfileViewer.java | 2 +- .../moulberry/notenoughupdates/util/Utils.java | 35 +++++ 5 files changed, 144 insertions(+), 144 deletions(-) (limited to 'src/main/java/io') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java index f46c8334..cb2f06d6 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java @@ -249,7 +249,7 @@ public class APIManager { if (lowestBins != null && lowestBins.has(internalname)) { JsonElement e = lowestBins.get(internalname); if (e.isJsonPrimitive() && e.getAsJsonPrimitive().isNumber()) { - return e.getAsInt(); + return e.getAsBigDecimal().intValue(); } } return -1; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipListener.java index 501ed8a3..a00e7e8a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipListener.java @@ -40,6 +40,7 @@ import java.util.List; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.regex.PatternSyntaxException; public class ItemTooltipListener { private static final String petToolTipRegex = @@ -389,9 +390,9 @@ public class ItemTooltipListener { try { pattern = Pattern.compile("(\\u00A79|\\u00A7(9|l)\\u00A7d\\u00A7l)(?" + enchantName + ") " + "(?[0-9]+|(I|II|III|IV|V|VI|VII|VIII|IX|X|XI|XII|XIII|XIV|XV|XVI|XVII|XVIII|XIX|XX))((\\u00A79)?,|( \\u00A78(?:,?[0-9]+)*)?$)"); - } catch (Exception e) { + } catch (PatternSyntaxException e) { continue; - } //malformed regex + } Matcher matcher = pattern.matcher(line); int matchCount = 0; while (matcher.find() && matchCount < 5) { @@ -400,73 +401,8 @@ public class ItemTooltipListener { matchCount++; int level = -1; String levelStr = matcher.group("level"); - if (levelStr == null) continue; - try { - level = Integer.parseInt(levelStr); - } catch (Exception e) { - switch (levelStr) { - case "I": - level = 1; - break; - case "II": - level = 2; - break; - case "III": - level = 3; - break; - case "IV": - level = 4; - break; - case "V": - level = 5; - break; - case "VI": - level = 6; - break; - case "VII": - level = 7; - break; - case "VIII": - level = 8; - break; - case "IX": - level = 9; - break; - case "X": - level = 10; - break; - case "XI": - level = 11; - break; - case "XII": - level = 12; - break; - case "XIII": - level = 13; - break; - case "XIV": - level = 14; - break; - case "XV": - level = 15; - break; - case "XVI": - level = 16; - break; - case "XVII": - level = 17; - break; - case "XVIII": - level = 18; - break; - case "XIX": - level = 19; - break; - case "XX": - level = 20; - break; - } - } + if (levelStr == null || levelStr.isEmpty()) continue; + level = Utils.parseIntOrRomanNumeral(levelStr); boolean matches = false; if (level > 0) { switch (comparator) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiPriceGraph.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiPriceGraph.java index 66014b1f..e2381503 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiPriceGraph.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiPriceGraph.java @@ -36,7 +36,7 @@ public class GuiPriceGraph extends GuiScreen { private final ResourceLocation TEXTURE; private static final int X_SIZE = 364; private static final int Y_SIZE = 215; - private Data dataPoints; + private ItemData itemData; private float highestValue; private long firstTime; private long lastTime; @@ -117,7 +117,8 @@ public class GuiPriceGraph extends GuiScreen { Utils.drawStringCentered("Loading...", Minecraft.getMinecraft().fontRendererObj, guiLeft + 166, guiTop + 116, false, 0xffffff00 ); - else if (dataPoints == null || dataPoints.get() == null || dataPoints.get().size() <= 1 || lowestValue == null) + else if ( + itemData == null || itemData.get() == null || itemData.get().size() <= 1 || lowestValue == null) Utils.drawStringCentered("No data found.", Minecraft.getMinecraft().fontRendererObj, guiLeft + 166, guiTop + 116, false, 0xffff0000 ); @@ -127,16 +128,16 @@ public class GuiPriceGraph extends GuiScreen { Integer lowestDist = null; Long lowestDistTime = null; HashMap secondLineData = new HashMap<>(); - for (int i = (dataPoints.isBz() ? 1 : 0); i >= 0; i--) { + for (int i = (itemData.isBz() ? 1 : 0); i >= 0; i--) { Utils.drawGradientRect(0, guiLeft + 17, guiTop + 35, guiLeft + 315, guiTop + 198, changeAlpha(i == 0 ? graphColor : graphColor2, 120), changeAlpha(i == 0 ? graphColor : graphColor2, 10) ); Integer prevX = null; Integer prevY = null; - for (Long time : dataPoints.get().keySet()) { - float price = dataPoints.isBz() - ? i == 0 ? dataPoints.bz.get(time).b : dataPoints.bz.get(time).s - : dataPoints.ah.get(time); + for (Long time : itemData.get().keySet()) { + float price = itemData.isBz() + ? i == 0 ? itemData.bz.get(time).b : itemData.bz.get(time).s + : itemData.ah.get(time); int xPos = (int) map(time, firstTime, lastTime, guiLeft + 17, guiLeft + 315); int yPos = (int) map(price, highestValue + 10d, lowestValue - 10d, guiTop + 35, guiTop + 198); if (prevX != null) { @@ -159,7 +160,7 @@ public class GuiPriceGraph extends GuiScreen { ); if (i == 0) { Utils.drawLine(prevX, prevY + 0.5f, xPos, yPos + 0.5f, 2, graphColor); - if (dataPoints.isBz()) + if (itemData.isBz()) Utils.drawLine( prevX, secondLineData.get(prevX) + 0.5f, @@ -218,8 +219,8 @@ public class GuiPriceGraph extends GuiScreen { Utils.drawDottedLine(customStart, guiTop + 197, customEnd, guiTop + 197, 2, 10, 0xFFc6c6c6); } if (lowestDist != null && !customSelecting) { - float price = dataPoints.isBz() ? dataPoints.bz.get(lowestDistTime).b : dataPoints.ah.get(lowestDistTime); - Float price2 = dataPoints.isBz() ? dataPoints.bz.get(lowestDistTime).s : null; + float price = itemData.isBz() ? itemData.bz.get(lowestDistTime).b : itemData.ah.get(lowestDistTime); + Float price2 = itemData.isBz() ? itemData.bz.get(lowestDistTime).s : null; int xPos = (int) map(lowestDistTime, firstTime, lastTime, guiLeft + 17, guiLeft + 315); int yPos = (int) map(price, highestValue + 10d, lowestValue - 10d, guiTop + 35, guiTop + 198); int yPos2 = price2 != null @@ -243,7 +244,7 @@ public class GuiPriceGraph extends GuiScreen { NumberFormat nf = NumberFormat.getInstance(); ArrayList text = new ArrayList<>(); text.add(displayFormat.format(date)); - if (dataPoints.isBz()) { + if (itemData.isBz()) { text.add(EnumChatFormatting.YELLOW + "" + EnumChatFormatting.BOLD + "Bazaar Insta-Buy: " + EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + nf.format(price)); text.add(EnumChatFormatting.YELLOW + "" + EnumChatFormatting.BOLD + "Bazaar Insta-Sell: " + @@ -320,7 +321,7 @@ public class GuiPriceGraph extends GuiScreen { } private void loadData() { - dataPoints = null; + itemData = null; loaded = false; new Thread(() -> { File dir = new File("config/notenoughupdates/prices"); @@ -329,46 +330,46 @@ public class GuiPriceGraph extends GuiScreen { return; } File[] files = dir.listFiles(); - Data data = new Data(); + ItemData itemData = new ItemData(); if (files == null) return; for (File file : files) { if (!file.getName().endsWith(".gz")) continue; - HashMap data2 = load(file); + HashMap data2 = load(file); if (data2 == null || !data2.containsKey(itemId)) continue; if (data2.get(itemId).isBz()) { - if (data.bz == null) data.bz = data2.get(itemId).bz; - else data.bz.putAll(data2.get(itemId).bz); - } else if (data.ah == null) data.ah = data2.get(itemId).ah; - else data.ah.putAll(data2.get(itemId).ah); + if (itemData.bz == null) itemData.bz = data2.get(itemId).bz; + else itemData.bz.putAll(data2.get(itemId).bz); + } else if (itemData.ah == null) itemData.ah = data2.get(itemId).ah; + else itemData.ah.putAll(data2.get(itemId).ah); } - if (data.get() != null && !data.get().isEmpty()) { + if (itemData.get() != null && !itemData.get().isEmpty()) { if (mode < 3) - data = new Data( - new TreeMap<>(data.get().entrySet().stream() - .filter(e -> e.getKey() > System.currentTimeMillis() / 1000 - + itemData = new ItemData( + new TreeMap<>(itemData.get().entrySet().stream() + .filter(e -> e.getKey() > System.currentTimeMillis() / 1000 - (mode == 0 ? 3600 : mode == 1 ? 86400 : 604800)) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))), - data.isBz() + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))), + itemData.isBz() ); else if (mode == 4) - data = new Data( - new TreeMap<>(data.get().entrySet().stream() - .filter(e -> e.getKey() >= customStart && e.getKey() <= customEnd) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))), - data.isBz() + itemData = new ItemData( + new TreeMap<>(itemData.get().entrySet().stream() + .filter(e -> e.getKey() >= customStart && e.getKey() <= customEnd) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))), + itemData.isBz() ); - if (data.get() == null || data.get().isEmpty()) { + if (itemData.get() == null || itemData.get().isEmpty()) { loaded = true; return; } - dataPoints = trimData(data); - firstTime = dataPoints.get().firstKey(); - lastTime = dataPoints.get().lastKey(); + this.itemData = trimData(itemData); + firstTime = this.itemData.get().firstKey(); + lastTime = this.itemData.get().lastKey(); highestValue = 0; lowestValue = null; - for (long key : dataPoints.get().keySet()) { - float value1 = dataPoints.isBz() ? dataPoints.bz.get(key).b : dataPoints.ah.get(key); - Float value2 = dataPoints.isBz() ? dataPoints.bz.get(key).s : null; + for (long key : this.itemData.get().keySet()) { + float value1 = this.itemData.isBz() ? this.itemData.bz.get(key).b : this.itemData.ah.get(key); + Float value2 = this.itemData.isBz() ? this.itemData.bz.get(key).s : null; if (value1 > highestValue) { highestValue = value1; } @@ -404,33 +405,13 @@ public class GuiPriceGraph extends GuiScreen { Date date = new Date(); Long epochSecond = date.toInstant().getEpochSecond(); File file = new File(dir, "prices_" + format.format(date) + ".gz"); - HashMap prices = new HashMap<>(); + HashMap prices = new HashMap<>(); if (file.exists()) { - HashMap tempPrices = load(file); + HashMap tempPrices = load(file); if (tempPrices != null) prices = tempPrices; } for (Map.Entry item : items.entrySet()) { - if (prices.containsKey(item.getKey())) { - if (bazaar && item.getValue().getAsJsonObject().has("curr_buy") && item.getValue().getAsJsonObject().has( - "curr_sell")) - prices.get(item.getKey()).bz.put(epochSecond, new BzData( - item.getValue().getAsJsonObject().get("curr_buy").getAsFloat(), - item.getValue().getAsJsonObject().get("curr_sell").getAsFloat() - )); - else if (!bazaar) - prices.get(item.getKey()).ah.put(epochSecond, item.getValue().getAsBigDecimal().intValue()); - } else { - TreeMap mapData = new TreeMap<>(); - if (bazaar && item.getValue().getAsJsonObject().has("curr_buy") && item.getValue().getAsJsonObject().has( - "curr_sell")) - mapData.put(epochSecond, new BzData( - item.getValue().getAsJsonObject().get("curr_buy").getAsFloat(), - item.getValue().getAsJsonObject().get("curr_sell").getAsFloat() - )); - else if (!bazaar) - mapData.put(epochSecond, item.getValue().getAsLong()); - prices.put(item.getKey(), new Data(mapData, bazaar)); - } + addOrUpdateItemPriceInfo(item, prices, epochSecond, bazaar); } //noinspection ResultOfMethodCallIgnored file.createNewFile(); @@ -447,16 +428,64 @@ public class GuiPriceGraph extends GuiScreen { } } - private Data trimData(Data data) { - long first = data.get().firstKey(); - long last = data.get().lastKey(); - Data trimmed = new Data(); - if (data.isBz()) + private static void addOrUpdateItemPriceInfo(Map.Entry item, HashMap prices, long timestamp, boolean bazaar) { + String itemName = item.getKey(); + ItemData existingItemData = null; + if (prices.containsKey(itemName)) { + existingItemData = prices.get(itemName); + } + + // Handle transitions from ah to bz (the other direction typically doesn't happen) + if (existingItemData != null) { + if (existingItemData.isBz() && !bazaar) { + return; + } + + if (!existingItemData.isBz() && bazaar) { + prices.remove(itemName); + existingItemData = null; + } + } + + if (bazaar) { + if (!item.getValue().getAsJsonObject().has("curr_buy") || + !item.getValue().getAsJsonObject().has("curr_sell") + ) { + return; + } + + BzData bzData = new BzData( + item.getValue().getAsJsonObject().get("curr_buy").getAsFloat(), + item.getValue().getAsJsonObject().get("curr_sell").getAsFloat()); + + if (existingItemData != null) { + existingItemData.bz.put(timestamp, bzData); + } else { + TreeMap mapData = new TreeMap<>(); + mapData.put(timestamp, bzData); + prices.put(item.getKey(), new ItemData(mapData, true)); + } + } else { + if (existingItemData != null) { + prices.get(item.getKey()).ah.put(timestamp, item.getValue().getAsBigDecimal().intValue()); + } else { + TreeMap mapData = new TreeMap<>(); + mapData.put(timestamp, item.getValue().getAsLong()); + prices.put(item.getKey(), new ItemData(mapData, false)); + } + } + } + + private ItemData trimData(ItemData itemData) { + long first = itemData.get().firstKey(); + long last = itemData.get().lastKey(); + ItemData trimmed = new ItemData(); + if (itemData.isBz()) trimmed.bz = new TreeMap<>(); else trimmed.ah = new TreeMap<>(); int zones = NotEnoughUpdates.INSTANCE.config.ahGraph.graphZones; - Long[] dataArray = !data.isBz() ? data.ah.keySet().toArray(new Long[0]) : data.bz.keySet().toArray(new Long[0]); + Long[] dataArray = !itemData.isBz() ? itemData.ah.keySet().toArray(new Long[0]) : itemData.bz.keySet().toArray(new Long[0]); int prev = 0; for (int i = 0; i < zones; i++) { long lowest = (long) map(i, 0, zones, first, last); @@ -467,14 +496,14 @@ public class GuiPriceGraph extends GuiScreen { for (int l = prev; l < dataArray.length; l++) { if (dataArray[l] >= lowest && dataArray[l] <= highest) { amount++; - sumBuy += data.isBz() ? data.bz.get(dataArray[l]).b : data.ah.get(dataArray[l]); - if (data.isBz()) sumSell += data.bz.get(dataArray[l]).s; + sumBuy += itemData.isBz() ? itemData.bz.get(dataArray[l]).b : itemData.ah.get(dataArray[l]); + if (itemData.isBz()) sumSell += itemData.bz.get(dataArray[l]).s; prev = l + 1; } else if (dataArray[l] > highest) break; } if (amount > 0) { - if (data.isBz()) + if (itemData.isBz()) trimmed.bz.put(lowest, new BzData((float) (sumBuy / amount), (float) (sumSell / amount))); else trimmed.ah.put(lowest, (int) (sumBuy / amount)); @@ -483,8 +512,8 @@ public class GuiPriceGraph extends GuiScreen { return trimmed; } - private static HashMap load(File file) { - Type type = new TypeToken>() { + private static HashMap load(File file) { + Type type = new TypeToken>() { }.getType(); if (file.exists()) { try ( @@ -525,14 +554,14 @@ public class GuiPriceGraph extends GuiScreen { } } -class Data { +class ItemData { public TreeMap ah = null; public TreeMap bz = null; - public Data() { + public ItemData() { } - public Data(TreeMap map, boolean bz) { + public ItemData(TreeMap map, boolean bz) { if (bz) this.bz = (TreeMap) map; else diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java index 597b6b4d..06ba32ad 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java @@ -478,7 +478,7 @@ public class GuiProfileViewer extends GuiScreen { this.guiTop = (this.height - this.sizeY) / 2; boolean bingo = false; - JsonObject currProfileInfo = profile.getProfileInformation(profileId); + JsonObject currProfileInfo = profile != null ? profile.getProfileInformation(profileId) : null; if (NotEnoughUpdates.INSTANCE.config.profileViewer.alwaysShowBingoTab) { showBingoPage = true; } else { 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 5fac9208..7b714cd0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -653,6 +653,41 @@ public class Utils { return (float) Math.round(value * scale) / scale; } + // Parses Roman numerals, allowing for single character irregular subtractive notation (e.g. IL is 49, IIL is invalid) + public static int parseRomanNumeral(String input) { + int prevVal = 0; + int total = 0; + for (int i = input.length()-1; i >= 0; i--) { + int val; + char ch = input.charAt(i); + switch (ch) { + case 'I' : val = 1; break; + case 'V' : val = 5; break; + case 'X' : val = 10; break; + case 'L' : val = 50; break; + case 'C' : val = 100; break; + case 'D' : val = 500; break; + case 'M' : val = 1000; break; + default: throw new IllegalArgumentException("Invalid Roman Numeral Character: " + ch); + } + if (val < prevVal) val = -val; + total += val; + prevVal = val; + } + + return total; + } + + public static int parseIntOrRomanNumeral(String input) { + // 0 through 9, '-', and '+' come before 'A' in ANSI, UTF8, and UTF16 character sets + // + if (input.charAt(0) < 'A') { + return Integer.parseInt(input); + } + + return parseRomanNumeral(input); + } + public static void playPressSound() { playSound(new ResourceLocation("gui.button.press"), true); } -- cgit From e6d58c7281375e8ca67b0e217e9c0eea2626ee19 Mon Sep 17 00:00:00 2001 From: Roman / Nea Date: Sat, 30 Apr 2022 16:17:39 +0200 Subject: Increase lava fishing tolerance in flowing blocks. (#122) * Increase lava fishing tolerance in flowing blocks. * stupid dojo fuck up --- .../miscfeatures/FishingHelper.java | 23 ++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src/main/java/io') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java index 34e849d0..b88eca99 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java @@ -3,6 +3,7 @@ package io.github.moulberry.notenoughupdates.miscfeatures; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.util.SpecialColour; import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.ISound; import net.minecraft.client.audio.PositionedSound; @@ -11,8 +12,10 @@ import net.minecraft.client.particle.EntityFX; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.Entity; import net.minecraft.entity.projectile.EntityFishHook; +import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; +import net.minecraft.util.BlockPos; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.ResourceLocation; import net.minecraftforge.event.entity.player.PlayerInteractEvent; @@ -21,7 +24,13 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import org.lwjgl.opengl.GL11; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; public class FishingHelper { private static final FishingHelper INSTANCE = new FishingHelper(); @@ -257,7 +266,17 @@ public class FishingHelper { double angle2 ) { double dY = particleY - hook.posY; - if (Math.abs(dY) > 0.5f) { + double tolerance = 0.5F; + if (hook.worldObj != null) { + for (int i = -2; i < 2; i++) { + IBlockState state = hook.worldObj.getBlockState(new BlockPos(particleX, particleY + i, particleZ)); + if (state != null && (state.getBlock() == Blocks.flowing_lava + || state.getBlock() == Blocks.flowing_water + || state.getBlock() == Blocks.lava)) + tolerance = 2.0F; + } + } + if (Math.abs(dY) > tolerance) { return HookPossibleRet.NOT_POSSIBLE; } -- cgit From 7243827ec602efa0d2386ab53a61472465e8555a Mon Sep 17 00:00:00 2001 From: NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> Date: Sat, 30 Apr 2022 14:24:52 +0000 Subject: made it so "pane gui scale" doesnt effect armour/pet huds (#117) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * made it so "pane gui scale" doesnt effect armour/pet huds ( i did not know that was a feature) this did NOT take me 20 minutes to make this commit on the right branch * = Updated the syntax for the /sthw command, putting name after the coordinates (@My-Name-Is-Jeff) * deez nuts * move equipment tooltips to the left * move tooltip when rendering fixes some opengl shenanigans when using GlTranslate * import static * i think the number 27 is cooler than 21 but its needed here * fix pet tooltip when equipment is not cached * added master star support to the search overlay (no texture rn cos lazy) * Added 6-10 stars to the auction search overlay i am not using the web editor * texture - jani * ➓/➓ pr adding numbers to /neurename * ➓/➓ pr adding numbers 2.1.md * neuec support to attributes (THIS DID NOT TAKE OVER AN HOUR) * 2.1.md 🙂 * Added flares to tools itemtab / fixed todo move option not showing / some fixes for my heart * fix normal keybinds not working in CalendarOverlay * 2.1.md 🙂 * cobble pro time keeper * added MAXED_ATTRIBUTE_SHARD * Update 2.1.md Co-authored-by: Lulonaut Co-authored-by: jani270 --- .../moulberry/notenoughupdates/NEUOverlay.java | 598 ++++++++++----------- .../notenoughupdates/core/GuiElementTextField.java | 50 ++ .../listener/ItemTooltipListener.java | 38 +- .../notenoughupdates/miscgui/CalendarOverlay.java | 2 + .../notenoughupdates/miscgui/GuiEnchantColour.java | 28 +- .../notenoughupdates/miscgui/GuiItemCustomize.java | 1 + .../options/seperateSections/DungeonMapConfig.java | 2 +- .../options/seperateSections/ItemOverlays.java | 2 +- .../options/seperateSections/LocationEdit.java | 11 +- .../options/seperateSections/Mining.java | 2 +- .../options/seperateSect