diff options
| author | Moulberry <james.jenour@student.scotch.wa.edu.au> | 2020-07-28 10:35:58 +1000 |
|---|---|---|
| committer | Moulberry <james.jenour@student.scotch.wa.edu.au> | 2020-07-28 10:35:58 +1000 |
| commit | 9716e11a253a370e16dd1f0bdfdd70ac21ee4102 (patch) | |
| tree | 4e89da0f5b6b25a67fdecb828451eec590b8c423 /src/main/java | |
| parent | 1fbc1f60082ea1bfb5e40eff1ca50b7122f5f38d (diff) | |
| download | NotEnoughUpdates-9716e11a253a370e16dd1f0bdfdd70ac21ee4102.tar.gz NotEnoughUpdates-9716e11a253a370e16dd1f0bdfdd70ac21ee4102.tar.bz2 NotEnoughUpdates-9716e11a253a370e16dd1f0bdfdd70ac21ee4102.zip | |
1.11.10
Diffstat (limited to 'src/main/java')
9 files changed, 559 insertions, 103 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java index f78c7e96..ffd57b41 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java @@ -921,8 +921,14 @@ public class NEUManager { if(tag != null && tag.hasKey("ExtraAttributes", 10)) { NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes"); - if (ea.hasKey("new_year_cake_bag_data", 7)) { - byte[] bytes = ea.getByteArray("new_year_cake_bag_data"); + byte[] bytes = null; + for(String key : ea.getKeySet()) { + if(key.endsWith("backpack_data") || key.equals("new_year_cake_bag_data")) { + bytes = ea.getByteArray(key); + break; + } + } + if(bytes != null) { JsonArray bytesArr = new JsonArray(); for(byte b : bytes) { bytesArr.add(new JsonPrimitive(b)); @@ -1384,6 +1390,10 @@ public class NEUManager { JsonObject petInfo = petnums.get(petname).getAsJsonObject(); if(petInfo.has(tier)) { JsonObject petInfoTier = petInfo.get(tier).getAsJsonObject(); + if(petInfoTier == null || !petInfoTier.has("1") || !petInfoTier.has("100")) { + return replacements; + } + JsonObject min = petInfoTier.get("1").getAsJsonObject(); JsonObject max = petInfoTier.get("100").getAsJsonObject(); @@ -1402,7 +1412,23 @@ public class NEUManager { replacements.put(entry.getKey(), statStr); } } else { + float minMix = (100-level)/99f; + float maxMix = (level-1)/99f; + + JsonArray otherNumsMin = min.get("otherNums").getAsJsonArray(); + JsonArray otherNumsMax = max.get("otherNums").getAsJsonArray(); + for(int i=0; i<otherNumsMax.size(); i++) { + float val = otherNumsMin.get(i).getAsFloat()*minMix + otherNumsMax.get(i).getAsFloat()*maxMix; + replacements.put(""+i, removeUnusedDecimal(Math.floor(val*10)/10f)); + } + for(Map.Entry<String, JsonElement> entry : max.get("statNums").getAsJsonObject().entrySet()) { + float statMax = entry.getValue().getAsFloat(); + float statMin = min.get("statNums").getAsJsonObject().get(entry.getKey()).getAsFloat(); + float val = statMin*minMix + statMax*maxMix; + String statStr = "+"+(int)Math.floor(val); + replacements.put(entry.getKey(), statStr); + } } } } @@ -1461,6 +1487,10 @@ public class NEUManager { } public ItemStack jsonToStack(JsonObject json, boolean useCache) { + return jsonToStack(json, useCache, true); + } + + public ItemStack jsonToStack(JsonObject json, boolean useCache, boolean useReplacements) { if(useCache && itemstackCache.containsKey(json.get("internalname").getAsString())) { return itemstackCache.get(json.get("internalname").getAsString()).copy(); } @@ -1487,13 +1517,17 @@ public class NEUManager { } } - HashMap<String, String> replacements = getLoreReplacements(stack.getTagCompound(), -1); + HashMap<String, String> replacements = new HashMap<>(); + + if(useReplacements) { + replacements = getLoreReplacements(stack.getTagCompound(), -1); - String displayname = json.get("displayname").getAsString(); - for(Map.Entry<String, String> entry : replacements.entrySet()) { - displayname = displayname.replace("{"+entry.getKey()+"}", entry.getValue()); + String displayname = json.get("displayname").getAsString(); + for(Map.Entry<String, String> entry : replacements.entrySet()) { + displayname = displayname.replace("{"+entry.getKey()+"}", entry.getValue()); + } + stack.setStackDisplayName(displayname); } - stack.setStackDisplayName(displayname); if(json.has("lore")) { NBTTagCompound display = new NBTTagCompound(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index 169b6b9f..f5475123 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -29,6 +29,7 @@ import net.minecraft.client.settings.KeyBinding; import net.minecraft.client.shader.Framebuffer; import net.minecraft.client.shader.Shader; import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.event.ClickEvent; import net.minecraft.init.Blocks; import net.minecraft.inventory.ContainerChest; @@ -167,13 +168,17 @@ public class NotEnoughUpdates { }, new SimpleCommand.TabCompleteRunnable() { @Override public List<String> tabComplete(ICommandSender sender, String[] args, BlockPos pos) { - /*if(args.length) { - - }*/ - for(String arg : args) { - System.out.println(arg); + if(args.length != 1) return null; + + String lastArg = args[args.length-1]; + List<String> playerMatches = new ArrayList<>(); + for(EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) { + String playerName = player.getName(); + if(playerName.toLowerCase().startsWith(lastArg.toLowerCase())) { + playerMatches.add(playerName); + } } - return null; + return playerMatches; } }); @@ -705,7 +710,8 @@ public class NotEnoughUpdates { missingRecipe.set(true); } //System.out.println(e.message); - if(isOnSkyblock() && manager.config.streamerMode.value && e.message instanceof ChatComponentText) { + if(unformatted.startsWith("Sending to server") && + isOnSkyblock() && manager.config.streamerMode.value && e.message instanceof ChatComponentText) { String m = e.message.getFormattedText(); String m2 = StreamerMode.filterChat(e.message.getFormattedText()); if(!m.equals(m2)) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/SBAIntegration.java b/src/main/java/io/github/moulberry/notenoughupdates/SBAIntegration.java new file mode 100644 index 00000000..502792df --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/SBAIntegration.java @@ -0,0 +1,196 @@ +package io.github.moulberry.notenoughupdates; + +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.settings.KeyBinding; +import net.minecraft.item.ItemStack; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.List; + +public class SBAIntegration { + + private static boolean hasSBA = true; + private static Class<?> skyblockAddonsClass = null; + private static Method skyblockAddons_getInstance = null; + private static Method skyblockAddons_getUtils = null; + private static Class<?> backpackManagerClass = null; + private static Method backpackManager_getFromItem = null; + private static Class<?> backpackClass = null; + private static Method backpackClass_setX= null; + private static Method backpackClass_setY = null; + private static Class<?> utilsClass = null; + private static Method utils_setBackpackToPreview = null; + public static boolean setActiveBackpack(ItemStack stack, int mouseX, int mouseY) { + if(!hasSBA) return false; + try { + if(skyblockAddonsClass == null) { + skyblockAddonsClass = Class.forName("codes.biscuit.skyblockaddons.SkyblockAddons"); + } + if(skyblockAddons_getInstance == null) { + skyblockAddons_getInstance = skyblockAddonsClass.getDeclaredMethod("getInstance"); + } + if(skyblockAddons_getUtils == null) { + skyblockAddons_getUtils = skyblockAddonsClass.getDeclaredMethod("getUtils"); + } + if(backpackManagerClass == null) { + backpackManagerClass = Class.forName("codes.biscuit.skyblockaddons.utils.BackpackManager"); + } + if(backpackManager_getFromItem == null) { + backpackManager_getFromItem = backpackManagerClass.getDeclaredMethod("getFromItem", ItemStack.class); + } + if(backpackClass == null) { + backpackClass = Class.forName("codes.biscuit.skyblockaddons.utils.Backpack"); + } + if(backpackClass_setX == null) { + backpackClass_setX = backpackClass.getDeclaredMethod("setX", int.class); + } + if(backpackClass_setY == null) { + backpackClass_setY = backpackClass.getDeclaredMethod("setY", int.class); + } + if(utilsClass == null) { + utilsClass = Class.forName("codes.biscuit.skyblockaddons.utils.Utils"); + } + if(utils_setBackpackToPreview == null) { + utils_setBackpackToPreview = utilsClass.getDeclaredMethod("setBackpackToPreview", backpackClass); + } + } catch(Exception e) { + e.printStackTrace(); + hasSBA = false; + return false; + } + try { + Object skyblockAddons = skyblockAddons_getInstance.invoke(null); + Object utils = skyblockAddons_getUtils.invoke(skyblockAddons); + if(stack == null) { + utils_setBackpackToPreview.invoke(utils, (Object) null); + } else { + Object backpack = backpackManager_getFromItem.invoke(null, stack); + backpackClass_setX.invoke(backpack, mouseX); + backpackClass_setY.invoke(backpack, mouseY); + utils_setBackpackToPreview.invoke(utils, backpack); + } + } catch(Exception e) { return false; } + return true; + } + + private static Field guiContainerHook_freezeBackpack = null; + public static boolean isFreezeBackpack() { + if(!hasSBA) return false; + try { + if(guiContainerHookClass == null) { + guiContainerHookClass = Class.forName("codes.biscuit.skyblockaddons.asm.hooks.GuiContainerHook"); + } + if(guiContainerHook_freezeBackpack == null) { + guiContainerHook_freezeBackpack = guiContainerHookClass.getDeclaredField("freezeBackpack"); + guiContainerHook_freezeBackpack.setAccessible(true); + } + } catch(Exception e) { + e.printStackTrace(); + hasSBA = false; + return false; + } + try { + return (boolean) guiContainerHook_freezeBackpack.get(null); + } catch(Exception e) { + return false; + } + } + + public static boolean setFreezeBackpack(boolean freezeBackpack) { + if(!hasSBA) return false; + try { + if(guiContainerHookClass == null) { + guiContainerHookClass = Class.forName("codes.biscuit.skyblockaddons.asm.hooks.GuiContainerHook"); + } + if(guiContainerHook_freezeBackpack == null) { + guiContainerHook_freezeBackpack = guiContainerHookClass.getDeclaredField("freezeBackpack"); + guiContainerHook_freezeBackpack.setAccessible(true); + } + } catch(Exception e) { + e.printStackTrace(); + hasSBA = false; + return false; + } + try { + guiContainerHook_freezeBackpack.set(null, freezeBackpack); + return true; + } catch(Exception e) { + return false; + } + } + + private static Method guiContainerHook_keyTyped = null; + private static Method skyblockAddons_getFreezeBackpackKey = null; + public static boolean keyTyped(int keyCode) { + if(!hasSBA) return false; + try { + if(skyblockAddonsClass == null) { + skyblockAddonsClass = Class.forName("codes.biscuit.skyblockaddons.SkyblockAddons"); + } + if(skyblockAddons_getInstance == null) { + skyblockAddons_getInstance = skyblockAddonsClass.getDeclaredMethod("getInstance"); + } + if(skyblockAddons_getFreezeBackpackKey == null) { + skyblockAddons_getFreezeBackpackKey = skyblockAddonsClass.getDeclaredMethod("getFreezeBackpackKey"); + } + if(guiContainerHookClass == null) { + guiContainerHookClass = Class.forName("codes.biscuit.skyblockaddons.asm.hooks.GuiContainerHook"); + } + if(guiContainerHook_keyTyped == null) { + guiContainerHook_keyTyped = guiContainerHookClass.getDeclaredMethod("keyTyped", int.class); + } + } catch(Exception e) { + e.printStackTrace(); + hasSBA = false; + return false; + } + try { + Object skyblockAddons = skyblockAddons_getInstance.invoke(null); + if(!isFreezeBackpack() && ((KeyBinding)skyblockAddons_getFreezeBackpackKey.invoke(skyblockAddons)).getKeyCode() == keyCode) { + setFreezeBackpack(true); + } else { + guiContainerHook_keyTyped.invoke(null, keyCode); + } + } catch(Exception e) { return false; } + return true; + } + + private static Class<?> guiContainerHookClass = null; + private static Method guiContainerHook_drawBackpacks = null; + public static boolean renderActiveBackpack(int mouseX, int mouseY, FontRenderer fontRendererObj) { + if(!hasSBA) return false; + try { + if(guiContainerHookClass == null) { + guiContainerHookClass = Class.forName("codes.biscuit.skyblockaddons.asm.hooks.GuiContainerHook"); + } + if(guiContainerHook_drawBackpacks == null) { + guiContainerHook_drawBackpacks = guiContainerHookClass.getDeclaredMethod("drawBackpacks", + GuiContainer.class, int.class, int.class, FontRenderer.class); + } + } catch(Exception e) { + e.printStackTrace(); + hasSBA = false; + return false; + } + try { + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + int width = scaledResolution.getScaledWidth(); + int height = scaledResolution.getScaledHeight(); + + GuiContainer container = new GuiContainer(null) { + protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { + } + }; + container.setWorldAndResolution(Minecraft.getMinecraft(), width, height); + + guiContainerHook_drawBackpacks.invoke(null, container, mouseX, mouseY, fontRendererObj); + } catch(Exception e) { return false; } + return true; + } + +} 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 72baf3a7..07c21304 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java @@ -515,7 +515,7 @@ public class APIManager { if(itemType >= 0 && itemType < categoryItemType.length) { category = categoryItemType[itemType]; } - if(internalname.equals("ENCHANTED_BOOK")) category = "ebook"; + if(internalname.contains("ENCHANTED_BOOK")) category = "ebook"; if(extras.endsWith("Potion")) category = "potion"; if(extras.contains("Rune")) category = "rune"; if(item_lore.split("\n")[0].endsWith("Furniture")) category = "furniture"; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java b/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java index 8cd82568..0de6cafc 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java @@ -279,6 +279,8 @@ public class Options { public List<Option> getOptions() { List<Option> options = new ArrayList<>(); + //Pane width near top so less scuffed + tryAddOption(paneWidthMult, options); //Buttons tryAddOption(enableItemEditing, options); tryAddOption(onlyShowOnSkyblock, options); @@ -298,7 +300,6 @@ public class Options { tryAddOption(disableItemTabOpen, options); //Sliders tryAddOption(bgBlurFactor, options); - tryAddOption(paneWidthMult, options); tryAddOption(ahNotification, options); tryAddOption(bgOpacity, options); tryAddOption(fgOpacity, options); 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 6aa2a1ab..295bce12 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java @@ -8,6 +8,7 @@ import com.mojang.authlib.GameProfile; import com.mojang.authlib.minecraft.MinecraftProfileTexture; import com.mojang.authlib.properties.Property; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.SBAIntegration; import io.github.moulberry.notenoughupdates.cosmetics.ShaderManager; import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField; import io.github.moulberry.notenoughupdates.questing.SBScoreboardData; @@ -39,6 +40,7 @@ import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.*; import net.minecraft.util.*; import net.minecraft.world.World; import org.apache.commons.codec.binary.Base64; @@ -51,6 +53,7 @@ import org.lwjgl.opengl.GL14; import org.lwjgl.opengl.GL20; import java.awt.*; +import java.io.ByteArrayInputStream; import java.io.IOException; import java.nio.charset.Charset; import java.text.NumberFormat; @@ -98,8 +101,8 @@ public class GuiProfileViewer extends GuiScreen { INVALID_NAME(null), BASIC(new ItemStack(Items.paper)), INVS(new ItemStack(Item.getItemFromBlock(Blocks.ender_chest))), - COLS(new ItemStack(Items.painting)); - //PETS(new ItemStack(Items.bone)); + COLS(new ItemStack(Items.painting)), + PETS(new ItemStack(Items.bone)); public final ItemStack stack; @@ -127,7 +130,9 @@ public class GuiProfileViewer extends GuiScreen { currentTime = System.currentTimeMillis(); if(startTime == 0) startTime = currentTime; - if(profile == null) currentPage = ProfileViewerPage.INVALID_NAME; + if(profile == null) { + currentPage = ProfileViewerPage.INVALID_NAME; + } if(profileId == null && profile != null && profile.getLatestProfile() != null) { profileId = profile.getLatestProfile(); } @@ -143,13 +148,12 @@ public class GuiProfileViewer extends GuiScreen { blurBackground(); renderBlurredBackground(width, height, guiLeft+2, guiTop+2, sizeX-4, sizeY-4); + GlStateManager.enableDepth(); GlStateManager.translate(0, 0, 5); renderTabs(true); GlStateManager.translate(0, 0, -3); - Minecraft.getMinecraft().getTextureManager().bindTexture(pv_bg); - Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST); - + GlStateManager.disableDepth(); GlStateManager.translate(0, 0, -2); renderTabs(false); GlStateManager.translate(0, 0, 2); @@ -161,30 +165,8 @@ public class GuiProfileViewer extends GuiScreen { GlStateManager.enableAlpha(); GlStateManager.alphaFunc(516, 0.1F); - switch (currentPage) { - case BASIC: - drawBasicPage(mouseX, mouseY, partialTicks); - break; - case INVS: - drawInvsPage(mouseX, mouseY, partialTicks); - break; - case COLS: - drawColsPage(mouseX, mouseY, partialTicks); - break; - case LOADING: - Utils.drawStringCentered(EnumChatFormatting.YELLOW+"Loading player profiles...", Minecraft.getMinecraft().fontRendererObj, - guiLeft+sizeX/2f, guiTop+101, true, 0); - break; - case INVALID_NAME: - Utils.drawStringCentered(EnumChatFormatting.RED+"Invalid name or API is down!", Minecraft.getMinecraft().fontRendererObj, - guiLeft+sizeX/2f, guiTop+101, true, 0); - break; - //case PETS: - // drawPetsPage(mouseX, mouseY, partialTicks); - // break; - } - - lastTime = currentTime; + Minecraft.getMinecraft().getTextureManager().bindTexture(pv_bg); + Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST); if(!(currentPage == ProfileViewerPage.LOADING)) { playerNameTextField.render(guiLeft+sizeX-100, guiTop+sizeY+5); @@ -222,6 +204,32 @@ public class GuiProfileViewer extends GuiScreen { } } + GlStateManager.color(1, 1, 1, 1); + switch (currentPage) { + case BASIC: + drawBasicPage(mouseX, mouseY, partialTicks); + break; + case INVS: + drawInvsPage(mouseX, mouseY, partialTicks); + break; + case COLS: + drawColsPage(mouseX, mouseY, partialTicks); + break; + case PETS: + drawPetsPage(mouseX, mouseY, partialTicks); + break; + case LOADING: + Utils.drawStringCentered(EnumChatFormatting.YELLOW+"Loading player profiles...", Minecraft.getMinecraft().fontRendererObj, + guiLeft+sizeX/2f, guiTop+101, true, 0); + break; + case INVALID_NAME: + Utils.drawStringCentered(EnumChatFormatting.RED+"Invalid name or API is down!", Minecraft.getMinecraft().fontRendererObj, + guiLeft+sizeX/2f, guiTop+101, true, 0); + break; + } + + lastTime = currentTime; + if(tooltipToDisplay != null) { List<String> grayTooltip = new ArrayList<>(tooltipToDisplay.size()); for(String line : tooltipToDisplay) { @@ -236,18 +244,6 @@ public class GuiProfileViewer extends GuiScreen { return profile.getProfileInformation(profileId) != null; } - private boolean isCollectionApiEnabled() { - return profile.getCollectionInfo(profileId) != null; - } - - private boolean isInventoryApiEnabled() { - return profile.getInventoryInfo(profileId) != null; - } - - private boolean isSkillsApiEnabled() { - return profile.getSkillInfo(profileId) != null; - } - private void renderTabs(boolean renderPressed) { int ignoredTabs = 0; for(int i=0; i<ProfileViewerPage.values().length; i++) { @@ -265,7 +261,6 @@ public class GuiProfileViewer extends GuiScreen { private void renderTab(ItemStack stack, int xIndex, boolean pressed) { GlStateManager.disableLighting(); - GlStateManager.enableDepth(); GlStateManager.enableBlend(); GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); GlStateManager.enableAlpha(); @@ -277,7 +272,7 @@ public class GuiProfileViewer extends GuiScreen { float uMin = 0; float uMax = 28/256f; float vMin = 20/256f; - float vMax = 52/256f; + float vMax = 51/256f; if(pressed) { vMin = 52/256f; vMax = 84/256f; @@ -293,14 +288,15 @@ public class GuiProfileViewer extends GuiScreen { } GlStateManager.disableLighting(); - GlStateManager.enableDepth(); GlStateManager.enableBlend(); GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); GlStateManager.enableAlpha(); GlStateManager.alphaFunc(516, 0.1F); Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements); - Utils.drawTexturedRect(x, y, 28, 32, uMin, uMax, vMin, vMax, GL11.GL_NEAREST); + Utils.drawTexturedRect(x, y, 28, pressed?32:31, uMin, uMax, vMin, vMax, GL11.GL_NEAREST); + + GlStateManager.enableDepth(); Utils.drawItemStack(stack, x+6, y+9); } @@ -339,6 +335,26 @@ public class GuiProfileViewer extends GuiScreen { return; } } + break; + case PETS: + JsonObject petsInfo = profile.getPetsInfo(profileId); + if(petsInfo == null) break; + JsonArray pets = petsInfo.get("pets").getAsJsonArray(); + for(int i=petsPage*20; i<Math.min(petsPage*20+20, pets.size()); i++) { + int xIndex = i % COLLS_XCOUNT; + int yIndex = i / COLLS_XCOUNT; + + float x = 5 + COLLS_XPADDING + (COLLS_XPADDING + 20) * xIndex; + float y = 7 + COLLS_YPADDING + (COLLS_YPADDING + 20) * yIndex; + + if(mouseX > guiLeft+x && mouseX < guiLeft+x+20) { + if(mouseY > guiTop+y && mouseY < guiTop+y+20) { + selectedPet = pets.get(i).getAsJsonObject(); + return; + } + } + } + break; } if(mouseX > guiLeft+sizeX-100 && mouseX < guiLeft+sizeX) { if(mouseY > guiTop+sizeY+5 && mouseY < guiTop+sizeY+25) { @@ -375,7 +391,7 @@ public class GuiProfileViewer extends GuiScreen { } else { profileDropdownSelected = !profileDropdownSelected; } - } else if(scaledResolution.getScaleFactor() != 4) { + } else if(scaledResolution.getScaleFactor() != 4 && profileDropdownSelected) { int dropdownOptionSize = scaledResolution.getScaleFactor()==3?10:20; int extraY = mouseY - (guiTop+sizeY+23); int index = extraY/dropdownOptionSize; @@ -399,6 +415,7 @@ public class GuiProfileViewer extends GuiScreen { @Override protected void keyTyped(char typedChar, int keyCode) throws IOException { super.keyTyped(typedChar, keyCode); + SBAIntegration.keyTyped(keyCode); switch (currentPage) { case INVS: keyTypedInvs(typedChar, keyCode); @@ -551,6 +568,31 @@ public class GuiProfileViewer extends GuiScreen { } } + public int getLevel(JsonArray levels, int offset, float exp) { + float xpTotal = 0; + int level = 1; + + for(int i=offset; i<offset+99; i++) { + xpTotal += levels.get(i).getAsFloat(); + + if(xpTotal > exp) { + break; + } else { + level += 1; + } + } + + if(level <= 0) { + level = 1; + } else if(level > 100) { + level = 100; + } + return level; + } + + private JsonObject selectedPet = null; + private int petsPage = 0; + private List<JsonObject> sortedPets = null; private static HashMap<String, String> minionRarityToNumMap = new HashMap<>(); static { minionRarityToNumMap.put("COMMON", "0"); @@ -560,33 +602,154 @@ public class GuiProfileViewer extends GuiScreen { minionRarityToNumMap.put("LEGENDARY", "4"); } private void drawPetsPage(int mouseX, int mouseY, float partialTicks) { + JsonObject petsInfo = profile.getPetsInfo(profileId); + if(petsInfo == null) return; + JsonObject petsJson = Utils.getConstant("pets"); + if(petsJson == null) return; + + String location = null; + JsonObject status = profile.getPlayerStatus(); + if(status != null && status.has("mode")) { + location = status.get("mode").getAsString(); + } + + backgroundRotation += (currentTime - lastTime)/400f; + backgroundRotation %= 360; + + String panoramaIdentifier = "day"; + if(SBScoreboardData.getInstance().currentTimeDate != null) { + if(SBScoreboardData.getInstance().currentTimeDate.getHours() <= 6 || + SBScoreboardData.getInstance().currentTimeDate.getHours() >= 20) { + panoramaIdentifier = "night"; + } + } + + Panorama.drawPanorama(-backgroundRotation, guiLeft+212, guiTop+44, 81, 108, -0.37f, 0.6f, + getPanoramasForLocation(location==null?"dynamic":location, panoramaIdentifier)); + Minecraft.getMinecraft().getTextureManager().bindTexture(pv_pets); Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST); - JsonObject petsInfo = profile.getPetsInfo(profileId); - if(petsInfo == null) return; + Utils.drawStringCentered(EnumChatFormatting.DARK_PURPLE+"Pets", Minecraft.getMinecraft().fontRendererObj, + guiLeft+100, guiTop+14, true, 4210752); + GlStateManager.color(1, 1, 1, 1); JsonArray pets = petsInfo.get("pets").getAsJsonArray(); - for(int i=0; i<pets.size(); i++) { - JsonObject pet = pets.get(i).getAsJsonObject(); - } + if(sortedPets == null) { + sortedPets = new ArrayList<>(); + for(int i=0; i<pets.size(); i++) { + sortedPets.add(pets.get(i).getAsJsonObject()); + } + sortedPets.sort((pet1, pet2) -> { + String tier1 = pet1.get("tier").getAsString(); + String tierNum1 = minionRarityToNumMap.get(tier1); + int tierNum1I = Integer.parseInt(tierNum1); + float exp1 = pet1.get("exp").getAsFloat(); + + String tier2 = pet2.get("tier").getAsString(); + String tierNum2 = minionRarityToNumMap.get(tier2); + int tierNum2I = Integer.parseInt(tierNum2); + float exp2 = pet2.get("exp |
