diff options
| author | NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> | 2022-07-08 02:07:38 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-07 18:07:38 +0200 |
| commit | 6e40cd5d2426eee681b091acc6e0822d4d7c45b5 (patch) | |
| tree | 5aea970325eaadfc17ad7660a53bc0e33fc18c84 /src/main/java | |
| parent | a2ad09ee13cee2ef70268336b9df41368574f45a (diff) | |
| download | NotEnoughUpdates-6e40cd5d2426eee681b091acc6e0822d4d7c45b5.tar.gz NotEnoughUpdates-6e40cd5d2426eee681b091acc6e0822d4d7c45b5.tar.bz2 NotEnoughUpdates-6e40cd5d2426eee681b091acc6e0822d4d7c45b5.zip | |
Added bestiary tab to pv (#177)
* some progress - missing be mobs from crimson and dungeons
* fix id's
* works :tm:
* working mobs levels (for hub and island because lazy
* idk seems right
* Added bestiary texture, fixed name bug, added changelog
i hope i didnt mess up anything.
* i did smth
* use 2.1.md from master because yes
* L europe
* Finished be tab
* hi im just putting it here because too lazy to open a pr for this
k, thanks bye
* unbelievable
* fix crash
* fix crash with old repo
* stfu infer
* europe wins
* l o n g
Co-authored-by: jani270 <jani270@gmx.de>
Diffstat (limited to 'src/main/java')
9 files changed, 1758 insertions, 283 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java b/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java index e1a3b3ee..4b5630bc 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java @@ -145,7 +145,7 @@ public class ItemPriceInformation { tooltip.add(EnumChatFormatting.DARK_GRAY + "[SHIFT show x" + shiftStackMultiplier + "]"); added = true; } - int bazaarBuyPrice = (int) bazaarInfo.get("avg_buy").getAsFloat() * stackMultiplier; + long bazaarBuyPrice = (long) bazaarInfo.get("avg_buy").getAsFloat() * stackMultiplier; tooltip.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Bazaar Buy: " + EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + (shortNumber && bazaarBuyPrice > 1000 ? Utils.shortNumberFormat(bazaarBuyPrice, 0) @@ -160,7 +160,7 @@ public class ItemPriceInformation { tooltip.add(EnumChatFormatting.DARK_GRAY + "[SHIFT show x" + shiftStackMultiplier + "]"); added = true; } - int bazaarSellPrice = (int) bazaarInfo.get("avg_sell").getAsFloat() * stackMultiplier; + long bazaarSellPrice = (long) bazaarInfo.get("avg_sell").getAsFloat() * stackMultiplier; tooltip.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Bazaar Sell: " + EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + (shortNumber && bazaarSellPrice > 1000 ? Utils.shortNumberFormat(bazaarSellPrice, 0) @@ -175,7 +175,7 @@ public class ItemPriceInformation { tooltip.add(EnumChatFormatting.DARK_GRAY + "[SHIFT show x" + shiftStackMultiplier + "]"); added = true; } - int bazaarInstantBuyPrice = (int) bazaarInfo.get("curr_buy").getAsFloat() * stackMultiplier; + long bazaarInstantBuyPrice = (long) bazaarInfo.get("curr_buy").getAsFloat() * stackMultiplier; tooltip.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Bazaar Insta-Buy: " + EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + (shortNumber && bazaarInstantBuyPrice > 1000 ? Utils.shortNumberFormat(bazaarInstantBuyPrice, 0) @@ -191,7 +191,7 @@ public class ItemPriceInformation { tooltip.add(EnumChatFormatting.DARK_GRAY + "[SHIFT show x" + shiftStackMultiplier + "]"); added = true; } - int bazaarInstantSellPrice = (int) bazaarInfo.get("curr_sell").getAsFloat() * stackMultiplier; + long bazaarInstantSellPrice = (long) bazaarInfo.get("curr_sell").getAsFloat() * stackMultiplier; tooltip.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Bazaar Insta-Sell: " + EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + (shortNumber && bazaarInstantSellPrice > 1000 ? Utils.shortNumberFormat( diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java index 18d756d8..cd0d08b5 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java @@ -662,6 +662,22 @@ public class NEUManager { return uuid; } + public String getSkullValueFromNBT(NBTTagCompound tag) { + if (tag != null && tag.hasKey("SkullOwner", 10)) { + NBTTagCompound ea = tag.getCompoundTag("SkullOwner"); + NBTTagCompound ea3 = tag.getCompoundTag("display"); + + if (ea.hasKey("Properties", 10)) { + NBTTagCompound ea2 = ea; + ea = ea.getCompoundTag("Properties"); + ea = ea.getTagList("textures", 10).getCompoundTagAt(0); + String name = ea3.getString("Name").replaceAll(" M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$", ""); + return "put(\"ID\", Utils.createSkull(EnumChatFormatting.AQUA + \"" + name + "\" ,\"" + ea2.getString("Id") + "\", \"" + ea.getString("Value") +"\"));"; + } + } + return null; + } + public String getInternalnameFromNBT(NBTTagCompound tag) { String internalname = null; if (tag != null && tag.hasKey("ExtraAttributes", 10)) { @@ -891,6 +907,11 @@ public class NEUManager { return json; } + public String getSkullValueForItem(ItemStack stack) { + if (stack == null) return null; + NBTTagCompound tag = stack.getTagCompound(); + return getSkullValueFromNBT(tag); + } public String getInternalNameForItem(ItemStack stack) { if (stack == null) return null; NBTTagCompound tag = stack.getTagCompound(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index d372602e..59e7c392 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -243,6 +243,9 @@ public class NotEnoughUpdates { if (config.profileViewer.pageLayout.size() == 8) { config.profileViewer.pageLayout.add(8); } + if (config.profileViewer.pageLayout.size() == 9) { + config.profileViewer.pageLayout.add(9); + } saveConfig(); } 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 e7da8628..1dc45cf8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipListener.java @@ -26,6 +26,7 @@ import com.google.gson.JsonPrimitive; import com.mojang.authlib.GameProfile; import com.mojang.authlib.minecraft.MinecraftProfileTexture; import io.github.moulberry.notenoughupdates.ItemPriceInformation; +import io.github.moulberry.notenoughupdates.NEUManager; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.util.MiscUtils; import io.github.moulberry.notenoughupdates.miscfeatures.PetInfoOverlay; @@ -900,6 +901,11 @@ public class ItemTooltipListener { boolean k = Keyboard.isKeyDown(Keyboard.KEY_K); boolean m = Keyboard.isKeyDown(Keyboard.KEY_M); boolean n = Keyboard.isKeyDown(Keyboard.KEY_N); + boolean f = Keyboard.isKeyDown(Keyboard.KEY_F); + + if (!copied && f && NotEnoughUpdates.INSTANCE.config.hidden.dev) { + MiscUtils.copyToClipboard(NotEnoughUpdates.INSTANCE.manager.getSkullValueForItem(event.itemStack)); + } event.toolTip.add( EnumChatFormatting.AQUA + "Internal Name: " + EnumChatFormatting.GRAY + internal + EnumChatFormatting.GOLD + @@ -938,7 +944,7 @@ public class ItemTooltipListener { } } - copied = k || m || n; + copied = k || m || n || f; } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ProfileViewer.java index 49385d02..ee1abf46 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ProfileViewer.java @@ -68,10 +68,11 @@ public class ProfileViewer { "\u00a7eMining", "\u00a7eBingo", "\u00a7eTrophy Fish", + "\u00a7eBestiary", }, allowDeleting = false ) - public List<Integer> pageLayout = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8)); + public List<Integer> pageLayout = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)); @Expose @ConfigOption( diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CollectionPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CollectionPage.java new file mode 100644 index 00000000..c15190a1 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CollectionPage.java @@ -0,0 +1,338 @@ +/* + * 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 <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.profileviewer; + +import com.google.gson.JsonObject; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.util.Constants; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.io.IOException; +import java.text.NumberFormat; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; + +public class CollectionPage { + + private static int guiLeft; + private static int guiTop; + private static int sizeX = 413; + private static int sizeY = 202; + public static final ResourceLocation pv_cols = new ResourceLocation("notenoughupdates:pv_cols.png"); + public static final ResourceLocation pv_elements = new ResourceLocation("notenoughupdates:pv_elements.png"); + private static final int COLLS_XCOUNT = 5; + private static final int COLLS_YCOUNT = 4; + private static final float COLLS_XPADDING = (190 - COLLS_XCOUNT * 20) / (float) (COLLS_XCOUNT + 1); + private static final float COLLS_YPADDING = (202 - COLLS_YCOUNT * 20) / (float) (COLLS_YCOUNT + 1); + private static final String[] romans = new String[]{ + "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", + "XII", "XIII", "XIV", "XV", "XVI", "XVII", "XIX", "XX" + }; + private static List<String> tooltipToDisplay = null; + private static final NumberFormat numberFormat = NumberFormat.getInstance(Locale.US); + private static ItemStack selectedCollectionCategory = null; + public static void drawColsPage(int mouseX, int mouseY, int width, int height) { + guiLeft = GuiProfileViewer.getGuiLeft(); + guiTop = GuiProfileViewer.getGuiTop(); + Minecraft.getMinecraft().getTextureManager().bindTexture(pv_cols); + Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST); + + JsonObject collectionInfo = GuiProfileViewer.getProfile().getCollectionInfo(GuiProfileViewer.getProfileId()); + if (collectionInfo == null) { + Utils.drawStringCentered( + EnumChatFormatting.RED + "Collection API not enabled!", + Minecraft.getMinecraft().fontRendererObj, + guiLeft + 134, + guiTop + 101, + true, + 0 + ); + return; + } + JsonObject resourceCollectionInfo = ProfileViewer.getResourceCollectionInformation(); + if (resourceCollectionInfo == null) return; + + int collectionCatSize = ProfileViewer.getCollectionCatToCollectionMap().size(); + int collectionCatYSize = (int) (162f / (collectionCatSize - 1 + 0.0000001f)); + { + int yIndex = 0; + for (ItemStack stack : ProfileViewer.getCollectionCatToCollectionMap().keySet()) { + if (selectedCollectionCategory == null) selectedCollectionCategory = stack; + Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements); + if (stack == selectedCollectionCategory) { + Utils.drawTexturedRect(guiLeft + 7, guiTop + 10 + collectionCatYSize * yIndex, 20, 20, + 20 / 256f, 0, 20 / 256f, 0, GL11.GL_NEAREST + ); + Utils.drawItemStackWithText( + stack, + guiLeft + 10, + guiTop + 13 + collectionCatYSize * yIndex, + "" + (yIndex + 1) + ); + } else { + Utils.drawTexturedRect(guiLeft + 7, guiTop + 10 + collectionCatYSize * yIndex, 20, 20, + 0, 20 / 256f, 0, 20 / 256f, GL11.GL_NEAREST + ); + Utils.drawItemStackWithText(stack, guiLeft + 9, guiTop + 12 + collectionCatYSize * yIndex, "" + (yIndex + 1)); + } + yIndex++; + } + } + + Utils.drawStringCentered( + selectedCollectionCategory.getDisplayName() + " Collections", + Minecraft.getMinecraft().fontRendererObj, + guiLeft + 134, + guiTop + 14, + true, + 4210752 + ); + + JsonObject minionTiers = collectionInfo.get("minion_tiers").getAsJsonObject(); + JsonObject collectionTiers = collectionInfo.get("collection_tiers").getAsJsonObject(); + JsonObject maxAmounts = collectionInfo.get("max_amounts").getAsJsonObject(); + JsonObject totalAmounts = collectionInfo.get("total_amounts").getAsJsonObject(); + JsonObject personalAmounts = collectionInfo.get("personal_amounts").getAsJsonObject(); + + List<String> collections = ProfileViewer.getCollectionCatToCollectionMap().get(selectedCollectionCategory); + if (collections != null) { + for (int i = 0; i < collections.size(); i++) { + String collection = collections.get(i); + if (collection != null) { + ItemStack collectionItem = ProfileViewer.getCollectionToCollectionDisplayMap().get(collection); + if (collectionItem != null) { + int xIndex = i % COLLS_XCOUNT; + int yIndex = i / COLLS_XCOUNT; + + float x = 39 + COLLS_XPADDING + (COLLS_XPADDING + 20) * xIndex; + float y = 7 + COLLS_YPADDING + (COLLS_YPADDING + 20) * yIndex; + + String tierString; + int tier = (int) Utils.getElementAsFloat(collectionTiers.get(collection), 0); + if (tier > 20 || tier < 0) { + tierString = String.valueOf(tier); + } else { + tierString = romans[tier]; + } + float amount = Utils.getElementAsFloat(totalAmounts.get(collection), 0); + float maxAmount = Utils.getElementAsFloat(maxAmounts.get(collection), 0); + Color color = new Color(128, 128, 128, 255); + int tierStringColour = color.getRGB(); + float completedness = 0; + if (maxAmount > 0) { + completedness = amount / maxAmount; + } + completedness = Math.min(1, completedness); + if (maxAmounts.has(collection) && completedness >= 1) { + tierStringColour = new Color(255, 215, 0).getRGB(); + } + + GlStateManager.color(1, 1, 1, 1); + Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements); + Utils.drawTexturedRect(guiLeft + x, guiTop + y, 20, 20 * (1 - completedness), + 0, 20 / 256f, 0, 20 * (1 - completedness) / 256f, GL11.GL_NEAREST + ); + GlStateManager.color(1, 185 / 255f, 0, 1); + Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements); + Utils.drawTexturedRect(guiLeft + x, guiTop + y + 20 * (1 - completedness), 20, 20 * (completedness), + 0, 20 / 256f, 20 * (1 - completedness) / 256f, 20 / 256f, GL11.GL_NEAREST + ); + Utils.drawItemStack(collectionItem, guiLeft + (int) x + 2, guiTop + (int) y + 2); + + if (mouseX > guiLeft + (int) x + 2 && mouseX < guiLeft + (int) x + 18) { + if (mouseY > guiTop + (int) y + 2 && mouseY < guiTop + (int) y + 18) { + tooltipToDisplay = new ArrayList<>(); + tooltipToDisplay.add(collectionItem.getDisplayName() + " " + + (completedness >= 1 ? EnumChatFormatting.GOLD : EnumChatFormatting.GRAY) + tierString); + tooltipToDisplay.add( + "Collected: " + numberFormat.format(Utils.getElementAsFloat(personalAmounts.get(collection), 0))); + tooltipToDisplay.add("Total Collected: " + numberFormat.format(amount)); + } + } + + GlStateManager.color(1, 1, 1, 1); + if (tier >= 0) { + Utils.drawStringCentered(tierString, Minecraft.getMinecraft().fontRendererObj, + guiLeft + x + 10, guiTop + y - 4, true, + tierStringColour + ); + } + + Utils.drawStringCentered(GuiProfileViewer.shortNumberFormat(amount, 0) + "", Minecraft.getMinecraft().fontRendererObj, + guiLeft + x + 10, guiTop + y + 26, true, + color.getRGB() + ); + } + } + } + } + + Utils.drawStringCentered( + selectedCollectionCategory.getDisplayName() + " Minions", + Minecraft.getMinecraft().fontRendererObj, + guiLeft + 326, + guiTop + 14, + true, + 4210752 + ); + + List<String> minions = ProfileViewer.getCollectionCatToMinionMap().get(selectedCollectionCategory); + if (minions != null) { + for (int i = 0; i < minions.size(); i++) { + String minion = minions.get(i); + if (minion != null) { + JsonObject misc = Constants.MISC; + float MAX_MINION_TIER = + Utils.getElementAsFloat(Utils.getElement(misc, "minions." + minion + "_GENERATOR"), 11); + + int tier = (int) Utils.getElementAsFloat(minionTiers.get(minion), 0); + JsonObject minionJson; + if (tier == 0) { + minionJson = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(minion + "_GENERATOR_1"); + } else { + minionJson = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(minion + "_GENERATOR_" + tier); + } + + if (minionJson != null) { + int xIndex = i % COLLS_XCOUNT; + int yIndex = i / COLLS_XCOUNT; + + float x = 231 + COLLS_XPADDING + (COLLS_XPADDING + 20) * xIndex; + float y = 7 + COLLS_YPADDING + (COLLS_YPADDING + 20) * yIndex; + + String tierString; + + if (tier - 1 >= romans.length || tier - 1 < 0) { + tierString = String.valueOf(tier); + } else { + tierString = romans[tier - 1]; + } + + Color color = new Color(128, 128, 128, 255); + int tierStringColour = color.getRGB(); + float completedness = tier / MAX_MINION_TIER; + + completedness = Math.min(1, completedness); + if (completedness >= 1) { + tierStringColour = new Color(255, 215, 0).getRGB(); + } + + GlStateManager.color(1, 1, 1, 1); + Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements); + Utils.drawTexturedRect(guiLeft + x, guiTop + y, 20, 20 * (1 - completedness), + 0, 20 / 256f, 0, 20 * (1 - completedness) / 256f, GL11.GL_NEAREST + ); + GlStateManager.color(1, 185 / 255f, 0, 1); + Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements); + Utils.drawTexturedRect(guiLeft + x, guiTop + y + 20 * (1 - completedness), 20, 20 * (completedness), + 0, 20 / 256f, 20 * (1 - completedness) / 256f, 20 / 256f, GL11.GL_NEAREST + ); + + Utils.drawItemStack( + NotEnoughUpdates.INSTANCE.manager.jsonToStack(minionJson), + guiLeft + (int) x + 2, + guiTop + (int) y + 2 + ); + + if (mouseX > guiLeft + (int) x + 2 && mouseX < guiLeft + (int) x + 18) { + if (mouseY > guiTop + (int) y + 2 && mouseY < guiTop + (int) y + 18) { + tooltipToDisplay = NotEnoughUpdates.INSTANCE.manager.jsonToStack(minionJson) + .getTooltip( + Minecraft.getMinecraft().thePlayer, + false + ); + } + } + + GlStateManager.color(1, 1, 1, 1); + if (tier >= 0) { + Utils.drawStringCentered(tierString, Minecraft.getMinecraft().fontRendererObj, + guiLeft + x + 10, guiTop + y - 4, true, + tierStringColour + ); + } + } + } + } + } + + if (tooltipToDisplay != null) { + List<String> grayTooltip = new ArrayList<>(tooltipToDisplay.size()); + for (String line : tooltipToDisplay) { + grayTooltip.add(EnumChatFormatting.GRAY + line); + } + Utils.drawHoveringText(grayTooltip, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj); + tooltipToDisplay = null; + } + } + + protected static void keyTypedCols(char typedChar, int keyCode) throws IOException { + ItemStack stack = null; + Iterator<ItemStack> items = ProfileViewer.getCollectionCatToCollectionMap().keySet().iterator(); + switch (keyCode) { + case Keyboard.KEY_5: + case Keyboard.KEY_NUMPAD5: + stack = items.next(); + case Keyboard.KEY_4: + case Keyboard.KEY_NUMPAD4: + stack = items.next(); + case Keyboard.KEY_3: + case Keyboard.KEY_NUMPAD3: + stack = items.next(); + case Keyboard.KEY_2: + case Keyboard.KEY_NUMPAD2: + stack = items.next(); + case Keyboard.KEY_1: + case Keyboard.KEY_NUMPAD1: + stack = items.next(); + } + if (stack != null) { + selectedCollectionCategory = stack; + } + Utils.playPressSound(); + } + + public static void mouseReleasedCols(int mouseX, int mouseY, int mouseButton) { + int collectionCatSize = ProfileViewer.getCollectionCatToCollectionMap().size(); + int collectionCatYSize = (int) (162f / (collectionCatSize - 1 + 0.0000001f)); + int yIndex = 0; + for (ItemStack stack : ProfileViewer.getCollectionCatToCollectionMap().keySet()) { + if (mouseX > guiLeft + 7 && mouseX < guiLeft + 7 + 20) { + if (mouseY > guiTop + 10 + collectionCatYSize * yIndex && + mouseY < guiTop + 10 + collectionCatYSize * yIndex + 20) { + selectedCollectionCategory = stack; + Utils.playPressSound(); + return; + } + } + yIndex++; + } + } +} 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 90ad36c0..457f7c34 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java @@ -29,6 +29,7 @@ import com.mojang.authlib.GameProfile; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.cosmetics.ShaderManager; import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField; +import io.github.moulberry.notenoughupdates.profileviewer.bestiary.BestiaryPage; import io.github.moulberry.notenoughupdates.profileviewer.trophy.TrophyFishingPage; import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.SBInfo; @@ -81,7 +82,6 @@ import java.util.Arrays; import java.util.Base64; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; @@ -105,7 +105,7 @@ public class GuiProfileViewer extends GuiScreen { public static final ResourceLocation pv_extra = new ResourceLocation("notenoughupdates:pv_extra.png"); public static final ResourceLocation pv_mining = new ResourceLocation("notenoughupdates:pv_mining.png"); public static final ResourceLocation pv_invs = new ResourceLocation("notenoughupdates:pv_invs.png"); - public static final ResourceLocation pv_cols = new ResourceLocation("notenoughupdates:pv_cols.png"); + public static final ResourceLocation pv_pets = new ResourceLocation("notenoughupdates:pv_pets.png"); public static final ResourceLocation pv_dropdown = new ResourceLocation("notenoughupdates:pv_dropdown.png"); public static final ResourceLocation pv_bg = new ResourceLocation("notenoughupdates:pv_bg.png"); @@ -230,10 +230,7 @@ public class GuiProfileViewer extends GuiScreen { private final HashMap<String, ProfileViewer.Level> levelObjhotms = new HashMap<>(); private final HashMap<String, HashMap<String, ProfileViewer.Level>> levelObjClasseses = new HashMap<>(); private final GuiElementTextField dungeonLevelTextField = new GuiElementTextField("", GuiElementTextField.SCALE_TEXT); - private final String[] romans = new String[]{ - "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", - "XII", "XIII", "XIV", "XV", "XVI", "XVII", "XIX", "XX" - }; + private final int COLLS_XCOUNT = 5; private final int COLLS_YCOUNT = 4; private final float COLLS_XPADDING = (190 - COLLS_XCOUNT * 20) / (float) (COLLS_XCOUNT + 1); @@ -254,7 +251,6 @@ public class GuiProfileViewer extends GuiScreen { private List<String> tooltipToDisplay = null; private static String profileId = null; private boolean profileDropdownSelected = false; - private ItemStack selectedCollectionCategory = null; private int floorLevelTo = -1; private long floorLevelToXP = -1; private boolean onMasterMode = false; @@ -704,7 +700,7 @@ public class GuiProfileViewer extends GuiScreen { drawInvsPage(mouseX, mouseY); break; case COLLECTIONS: - drawColsPage(mouseX, mouseY, partialTicks); + CollectionPage.drawColsPage(mouseX, mouseY, width, height); break; case PETS: drawPetsPage(mouseX, mouseY, partialTicks); @@ -718,6 +714,9 @@ public class GuiProfileViewer extends GuiScreen { case TROPHY_FISH: TrophyFishingPage.renderPage(mouseX, mouseY); break; + case BESTIARY: + BestiaryPage.renderPage(mouseX, mouseY); + break; case LOADING: String str = EnumChatFormatting.YELLOW + "Loading player profiles."; long currentTimeMod = System.currentTimeMillis() % 1000; @@ -1093,7 +1092,7 @@ public class GuiProfileViewer extends GuiScreen { inventoryTextField.keyTyped(typedChar, keyCode); break; case COLLECTIONS: - keyTypedCols(typedChar, keyCode); + CollectionPage.keyTypedCols(typedChar, keyCode); break; case DUNGEON: keyTypedDung(typedChar, keyCode); @@ -1120,10 +1119,13 @@ public class GuiProfileViewer extends GuiScreen { mouseReleasedInvs(mouseX, mouseY, mouseButton); break; case COLLECTIONS: - mouseReleasedCols(mouseX, mouseY, mouseButton); + CollectionPage.mouseReleasedCols(mouseX, mouseY, mouseButton); break; case PETS: mouseReleasedPets(mouseX, mouseY, mouseButton); + break; + case BESTIARY: + BestiaryPage.mouseReleased(mouseX, mouseY, mouseButton); } } @@ -1209,31 +1211,7 @@ public class GuiProfileViewer extends GuiScreen { Utils.playPressSound(); } - protected void keyTypedCols(char typedChar, int keyCode) throws IOException { - ItemStack stack = null; - Iterator<ItemStack> items = ProfileViewer.getCollectionCatToCollectionMap().keySet().iterator(); - switch (keyCode) { - case Keyboard.KEY_5: - case Keyboard.KEY_NUMPAD5: - stack = items.next(); - case Keyboard.KEY_4: - case Keyboard.KEY_NUMPAD4: - stack = items.next(); - case Keyboard.KEY_3: - case Keyboard.KEY_NUMPAD3: - stack = items.next(); - case Keyboard.KEY_2: - case Keyboard.KEY_NUMPAD2: - stack = items.next(); - case Keyboard.KEY_1: - case Keyboard.KEY_NUMPAD1: - stack = items.next(); - } - if (stack != null) { - selectedCollectionCategory = stack; - } - Utils.playPressSound(); - } + private void mouseReleasedPets(int mouseX, int mouseY, int mouseButton) { if (mouseY > guiTop + 6 && mouseY < guiTop + 22) { @@ -1300,22 +1278,6 @@ public class GuiProfileViewer extends GuiScreen { } } - private void mouseReleasedCols(int mouseX, int mouseY, int mouseButton) { - int collectionCatSize = ProfileViewer.getCollectionCatToCollectionMap().size(); - int collectionCatYSize = (int) (162f / (collectionCatSize - 1 + 0.0000001f)); - int yIndex = 0; - for (ItemStack stack : ProfileViewer.getCollectionCatToCollectionMap().keySet()) { - if (mouseX > guiLeft + 7 && mouseX < guiLeft + 7 + 20) { - if (mouseY > guiTop + 10 + collectionCatYSize * yIndex && - mouseY < guiTop + 10 + collectionCatYSize * yIndex + 20) { - selectedCollectionCategory = stack; - Utils.playPressSound(); - return; - } - } - yIndex++; - } - } private void calculateFloorLevelXP() { JsonObject leveling = Constants.LEVELING; @@ -2433,232 +2395,7 @@ public class GuiProfileViewer extends GuiScreen { } } - private void drawColsPage(int mouseX, int mouseY, float partialTicks) { - Minecraft.getMinecraft().getTextureManager().bindTexture(pv_cols); - Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST); - JsonObject collectionInfo = profile.getCollectionInfo(profileId); - if (collectionInfo == null) { - Utils.drawStringCentered( - EnumChatFormatting.RED + "Collection API not enabled!", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + 134, - guiTop + 101, - true, - 0 - ); - return; - } - JsonObject resourceCollectionInfo = ProfileViewer.getResourceCollectionInformation(); - if (resourceCollectionInfo == null) return; - - int collectionCatSize = ProfileViewer.getCollectionCatToCollectionMap().size(); - int collectionCatYSize = (int) (162f / (collectionCatSize - 1 + 0.0000001f)); - { - int yIndex = 0; - for (ItemStack stack : ProfileViewer.getCollectionCatToCollectionMap().keySet()) { - if (selectedCollectionCategory == null) selectedCollectionCategory = stack; - Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements); - if (stack == selectedCollectionCategory) { - Utils.drawTexturedRect(guiLeft + 7, guiTop + 10 + collectionCatYSize * yIndex, 20, 20, - 20 / 256f, 0, 20 / 256f, 0, GL11.GL_NEAREST - ); - Utils.drawItemStackWithText( - stack, - guiLeft + 10, - guiTop + 13 + collectionCatYSize * yIndex, - "" + (yIndex + 1) - ); - } else { - Utils.drawTexturedRect(guiLeft + 7, guiTop + 10 + collectionCatYSize * yIndex, 20, 20, - 0, 20 / 256f, 0, 20 / 256f, GL11.GL_NEAREST - ); - Utils.drawItemStackWithText(stack, guiLeft + 9, guiTop + 12 + collectionCatYSize * yIndex, "" + (yIndex + 1)); - } - yIndex++; - } - } - - Utils.drawStringCentered( - selectedCollectionCategory.getDisplayName() + " Collections", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + 134, - guiTop + 14, - true, - 4210752 - ); - - JsonObject minionTiers = collectionInfo.get("minion_tiers").getAsJsonObject(); - JsonObject collectionTiers = collectionInfo.get("collection_tiers").getAsJsonObject(); - JsonObject maxAmounts = collectionInfo.get("max_amounts").getAsJsonObject(); - JsonObject totalAmounts = collectionInfo.get("total_amounts").getAsJsonObject(); - JsonObject personalAmounts = collectionInfo.get("personal_amounts").getAsJsonObject(); |
