From 275fe45caa8eb1048914d864aafae21f3f3a1157 Mon Sep 17 00:00:00 2001 From: Moulberry Date: Sat, 3 Oct 2020 06:09:28 +1000 Subject: 1.3.3-ALPA --- .../notenoughupdates/AccessoryBagOverlay.java | 527 +++++++++++++ .../notenoughupdates/BetterContainers.java | 333 ++++++++ .../moulberry/notenoughupdates/BetterPortals.java | 206 +++++ .../moulberry/notenoughupdates/GuiTextures.java | 5 + .../notenoughupdates/MorusIntegration.java | 60 ++ .../notenoughupdates/NEUEventListener.java | 29 +- .../moulberry/notenoughupdates/NEUOverlay.java | 171 +++- .../notenoughupdates/NEUOverlayPlacements.java | 63 +- .../notenoughupdates/NotEnoughUpdates.java | 18 +- .../moulberry/notenoughupdates/SBAIntegration.java | 21 +- .../moulberry/notenoughupdates/TradeWindow.java | 22 +- .../notenoughupdates/auction/APIManager.java | 78 +- .../notenoughupdates/auction/CustomAH.java | 4 +- .../notenoughupdates/infopanes/DevInfoPane.java | 862 ++++++++++++++++++++- .../infopanes/SettingsInfoPane.java | 2 + .../notenoughupdates/mbgui/MBAnchorPoint.java | 18 +- .../notenoughupdates/mbgui/MBDeserializer.java | 20 + .../notenoughupdates/mbgui/MBGuiElement.java | 2 + .../notenoughupdates/mbgui/MBGuiGroupAligned.java | 67 ++ .../notenoughupdates/mbgui/MBGuiGroupFloating.java | 23 +- .../notenoughupdates/mbgui/MBGuiGroupHorz.java | 47 -- .../notenoughupdates/mixins/MixinGuiChest.java | 32 + .../notenoughupdates/mixins/MixinGuiContainer.java | 52 ++ .../notenoughupdates/options/Options.java | 12 + .../profileviewer/GuiProfileViewer.java | 67 +- .../profileviewer/PlayerStats.java | 21 +- .../profileviewer/ProfileViewer.java | 162 +--- .../notenoughupdates/util/HypixelApi.java | 2 + .../moulberry/notenoughupdates/util/TexLoc.java | 8 +- 29 files changed, 2560 insertions(+), 374 deletions(-) create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/AccessoryBagOverlay.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/BetterContainers.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/BetterPortals.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/MorusIntegration.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBDeserializer.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupAligned.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupHorz.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiChest.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/AccessoryBagOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/AccessoryBagOverlay.java new file mode 100644 index 00000000..65d4efc7 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/AccessoryBagOverlay.java @@ -0,0 +1,527 @@ +package io.github.moulberry.notenoughupdates; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import io.github.moulberry.notenoughupdates.profileviewer.PlayerStats; +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.GuiChest; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.EnumChatFormatting; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.awt.*; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.*; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static io.github.moulberry.notenoughupdates.GuiTextures.*; + +public class AccessoryBagOverlay { + + private static final int TAB_BASIC = 0; + private static final int TAB_TOTAL = 1; + private static final int TAB_BONUS = 2; + private static final int TAB_DUP = 3; + private static final int TAB_MISSING = 4; + + private static final ItemStack[] TAB_STACKS = new ItemStack[] { + Utils.createItemStack(Items.dye, EnumChatFormatting.DARK_AQUA+"Basic Information", + 10, EnumChatFormatting.GREEN+"- Talis count by rarity"), + Utils.createItemStack(Items.diamond_sword, EnumChatFormatting.DARK_AQUA+"Total Stat Bonuses", + 0), + Utils.createItemStack(Item.getItemFromBlock(Blocks.anvil), EnumChatFormatting.DARK_AQUA+"Total Stat Bonuses (from reforges)", + 0), + Utils.createItemStack(Items.dye, EnumChatFormatting.DARK_AQUA+"Duplicates", + 8), + Utils.createItemStack(Item.getItemFromBlock(Blocks.barrier), EnumChatFormatting.DARK_AQUA+"Missing", + 0), + }; + + private static int currentTab = TAB_BASIC; + + public static boolean mouseClick() { + if(!Mouse.getEventButtonState()) return false; + try { + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + + int width = scaledResolution.getScaledWidth(); + int height = scaledResolution.getScaledHeight(); + + int mouseX = Mouse.getX() / scaledResolution.getScaleFactor(); + int mouseY = height - Mouse.getY() / scaledResolution.getScaleFactor(); + + int xSize = (int) Utils.getField(GuiContainer.class, Minecraft.getMinecraft().currentScreen, "xSize", "field_146999_f"); + int ySize = (int) Utils.getField(GuiContainer.class, Minecraft.getMinecraft().currentScreen, "ySize", "field_147000_g"); + int guiLeft = (int) Utils.getField(GuiContainer.class, Minecraft.getMinecraft().currentScreen, "guiLeft", "field_147003_i"); + int guiTop = (int) Utils.getField(GuiContainer.class, Minecraft.getMinecraft().currentScreen, "guiTop", "field_147009_r"); + + if(mouseX < guiLeft+xSize+3 || mouseX > guiLeft+xSize+80+28) return false; + if(mouseY < guiTop || mouseY > guiTop+166) return false; + + if(mouseX > guiLeft+xSize+83 && mouseY < guiTop+20*TAB_MISSING+22) { + currentTab = (mouseY - guiTop)/20; + if(currentTab < 0) currentTab = 0; + if(currentTab > TAB_MISSING) currentTab = TAB_MISSING; + } + + return true; + } catch(Exception e) { + return false; + } + } + + public static void resetCache() { + accessoryStacks = new HashSet<>(); + pagesVisited = new HashSet<>(); + talismanCountRarity = null; + totalStats = null; + reforgeStats = null; + } + + private static Set accessoryStacks = new HashSet<>(); + private static Set pagesVisited = new HashSet<>(); + + public static void renderVisitOverlay(int x, int y) { + Utils.drawStringCenteredScaledMaxWidth("Please visit all", Minecraft.getMinecraft().fontRendererObj, x+40, y+78, true, 70, -1); + Utils.drawStringCenteredScaledMaxWidth("pages of the bag", Minecraft.getMinecraft().fontRendererObj, x+40, y+86, true, 70, -1); + } + + private static TreeMap talismanCountRarity = null; + public static void renderBasicOverlay(int x, int y) { + if(talismanCountRarity == null) { + talismanCountRarity = new TreeMap<>(); + for(ItemStack stack : accessoryStacks) { + int rarity = getRarity(stack); + if(rarity >= 0) { + talismanCountRarity.put(rarity, talismanCountRarity.getOrDefault(rarity, 0)+1); + } + } + } + + Utils.drawStringCenteredScaledMaxWidth("# By Rarity", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, true, 70, + new Color(80, 80, 80).getRGB()); + + int yIndex = 0; + for(Map.Entry entry : talismanCountRarity.descendingMap().entrySet()) { + String rarityName = rarityArrC[entry.getKey()]; + renderAlignedString(rarityName, EnumChatFormatting.WHITE.toString()+entry.getValue(), x+5, y+20+11*yIndex, 70); + yIndex++; + } + } + + + private static PlayerStats.Stats totalStats = null; + public static void renderTotalStatsOverlay(int x, int y) { + if(totalStats == null) { + totalStats = new PlayerStats.Stats(); + for(ItemStack stack : accessoryStacks) { + if(stack != null) totalStats.add(getStatForItem(stack, STAT_PATTERN_MAP, true)); + } + } + + Utils.drawStringCenteredScaledMaxWidth("Total Stats", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, true, 70, + new Color(80, 80, 80).getRGB()); + int yIndex = 0; + for(int i=0; i duplicates = new HashSet<>(); + public static void renderDuplicatesOverlay(int x, int y) { + Utils.drawStringCenteredScaledMaxWidth("Duplicates", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, true, 70, + new Color(80, 80, 80).getRGB()); + } + + public static void renderMissingOverlay(int x, int y) { + } + + public static void renderOverlay() { + if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) { + GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen; + ContainerChest cc = (ContainerChest) eventGui.inventorySlots; + String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText(); + if(containerName.trim().startsWith("Accessory Bag")) { + try { + int xSize = (int) Utils.getField(GuiContainer.class, eventGui, "xSize", "field_146999_f"); + int ySize = (int) Utils.getField(GuiContainer.class, eventGui, "ySize", "field_147000_g"); + int guiLeft = (int) Utils.getField(GuiContainer.class, eventGui, "guiLeft", "field_147003_i"); + int guiTop = (int) Utils.getField(GuiContainer.class, eventGui, "guiTop", "field_147009_r"); + + if(accessoryStacks.isEmpty()) { + for(ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) { + if(stack != null && isAccessory(stack)) { + accessoryStacks.add(stack); + } + } + } + + if(containerName.trim().contains("(")) { + String first = containerName.trim().split("\\(")[1].split("/")[0]; + Integer currentPageNumber = Integer.parseInt(first); + //System.out.println("current:"+currentPageNumber); + if(!pagesVisited.contains(currentPageNumber)) { + boolean hasStack = false; + if(Minecraft.getMinecraft().thePlayer.openContainer instanceof ContainerChest) { + IInventory inv = ((ContainerChest)Minecraft.getMinecraft().thePlayer.openContainer).getLowerChestInventory(); + for(int i=0; i pagesVisited.size()) { + Minecraft.getMinecraft().getTextureManager().bindTexture(accessory_bag_overlay); + Utils.drawTexturedRect(guiLeft+xSize+3, guiTop, 80, 149, 0, 80/256f, 0, 149/256f, GL11.GL_NEAREST); + + renderVisitOverlay(guiLeft+xSize+3, guiTop); + return; + } + } else if(pagesVisited.isEmpty()) { + boolean hasStack = false; + if(Minecraft.getMinecraft().thePlayer.openContainer instanceof ContainerChest) { + IInventory inv = ((ContainerChest)Minecraft.getMinecraft().thePlayer.openContainer).getLowerChestInventory(); + for(int i=0; i= length) { + for(int xOff=-2; xOff<=2; xOff++) { + for(int yOff=-2; yOff<=2; yOff++) { + if(Math.abs(xOff) != Math.abs(yOff)) { + Utils.drawStringCenteredScaledMaxWidth(Utils.cleanColourNotModifiers(first + " " + second), Minecraft.getMinecraft().fontRendererObj, + x+length/2f+xOff/2f, y+4+yOff/2f, false, length, + new Color(0, 0, 0, 200/Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB()); + } + } + } + + GlStateManager.color(1, 1, 1, 1); + Utils.drawStringCenteredScaledMaxWidth(first + " " + second, Minecraft.getMinecraft().fontRendererObj, + x+length/2f, y+4, false, length, 4210752); + } else { + for(int xOff=-2; xOff<=2; xOff++) { + for(int yOff=-2; yOff<=2; yOff++) { + if(Math.abs(xOff) != Math.abs(yOff)) { + fontRendererObj.drawString(Utils.cleanColourNotModifiers(first), + x+xOff/2f, y+yOff/2f, + new Color(0, 0, 0, 200/Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB(), false); + } + } + } + + int secondLen = fontRendererObj.getStringWidth(second); + GlStateManager.color(1, 1, 1, 1); + fontRendererObj.drawString(first, x, y, 4210752, false); + for(int xOff=-2; xOff<=2; xOff++) { + for(int yOff=-2; yOff<=2; yOff++) { + if(Math.abs(xOff) != Math.abs(yOff)) { + fontRendererObj.drawString(Utils.cleanColourNotModifiers(second), + x+length-secondLen+xOff/2f, y+yOff/2f, + new Color(0, 0, 0, 200/Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB(), false); + } + } + } + + GlStateManager.color(1, 1, 1, 1); + fontRendererObj.drawString(second, x+length-secondLen, y, 4210752, false); + } + } + + private static final Pattern HEALTH_PATTERN_BONUS = Pattern.compile("^Health: (?:\\+|-)[0-9]+ HP \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)"); + private static final Pattern DEFENCE_PATTERN_BONUS = Pattern.compile("^Defense: (?:\\+|-)[0-9]+ \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)"); + private static final Pattern STRENGTH_PATTERN_BONUS = Pattern.compile("^Strength: (?:\\+|-)[0-9]+ \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)"); + private static final Pattern SPEED_PATTERN_BONUS = Pattern.compile("^Speed: (?:\\+|-)[0-9]+ \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)"); + private static final Pattern CC_PATTERN_BONUS = Pattern.compile("^Crit Chance: (?:\\+|-)[0-9]+% \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)"); + private static final Pattern CD_PATTERN_BONUS = Pattern.compile("^Crit Damage: (?:\\+|-)[0-9]+% \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)"); + private static final Pattern ATKSPEED_PATTERN_BONUS = Pattern.compile("^Bonus Attack Speed: (?:\\+|-)[0-9]+% \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)"); + private static final Pattern INTELLIGENCE_PATTERN_BONUS = Pattern.compile("^Intelligence: (?:\\+|-)[0-9]+ \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)"); + private static final Pattern SCC_PATTERN_BONUS = Pattern.compile("^Sea Creature Chance: (?:\\+|-)[0-9]+ \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)"); + private static final HashMap STAT_PATTERN_MAP_BONUS = new HashMap<>(); + static { + STAT_PATTERN_MAP_BONUS.put("health", HEALTH_PATTERN_BONUS); + STAT_PATTERN_MAP_BONUS.put("defence", DEFENCE_PATTERN_BONUS); + STAT_PATTERN_MAP_BONUS.put("strength", STRENGTH_PATTERN_BONUS); + STAT_PATTERN_MAP_BONUS.put("speed", SPEED_PATTERN_BONUS); + STAT_PATTERN_MAP_BONUS.put("crit_chance", CC_PATTERN_BONUS); + STAT_PATTERN_MAP_BONUS.put("crit_damage", CD_PATTERN_BONUS); + STAT_PATTERN_MAP_BONUS.put("bonus_attack_speed", ATKSPEED_PATTERN_BONUS); + STAT_PATTERN_MAP_BONUS.put("intelligence", INTELLIGENCE_PATTERN_BONUS); + STAT_PATTERN_MAP_BONUS.put("sea_creature_chance", SCC_PATTERN_BONUS); + } + + private static final Pattern HEALTH_PATTERN = Pattern.compile("^Health: ((?:\\+|-)[0-9]+)"); + private static final Pattern DEFENCE_PATTERN = Pattern.compile("^Defense: ((?:\\+|-)[0-9]+)"); + private static final Pattern STRENGTH_PATTERN = Pattern.compile("^Strength: ((?:\\+|-)[0-9]+)"); + private static final Pattern SPEED_PATTERN = Pattern.compile("^Speed: ((?:\\+|-)[0-9]+)"); + private static final Pattern CC_PATTERN = Pattern.compile("^Crit Chance: ((?:\\+|-)[0-9]+)"); + private static final Pattern CD_PATTERN = Pattern.compile("^Crit Damage: ((?:\\+|-)[0-9]+)"); + private static final Pattern ATKSPEED_PATTERN = Pattern.compile("^Bonus Attack Speed: ((?:\\+|-)[0-9]+)"); + private static final Pattern INTELLIGENCE_PATTERN = Pattern.compile("^Intelligence: ((?:\\+|-)[0-9]+)"); + private static final Pattern SCC_PATTERN = Pattern.compile("^Sea Creature Chance: ((?:\\+|-)[0-9]+)"); + private static final HashMap STAT_PATTERN_MAP = new HashMap<>(); + static { + STAT_PATTERN_MAP.put("health", HEALTH_PATTERN); + STAT_PATTERN_MAP.put("defence", DEFENCE_PATTERN); + STAT_PATTERN_MAP.put("strength", STRENGTH_PATTERN); + STAT_PATTERN_MAP.put("speed", SPEED_PATTERN); + STAT_PATTERN_MAP.put("crit_chance", CC_PATTERN); + STAT_PATTERN_MAP.put("crit_damage", CD_PATTERN); + STAT_PATTERN_MAP.put("bonus_attack_speed", ATKSPEED_PATTERN); + STAT_PATTERN_MAP.put("intelligence", INTELLIGENCE_PATTERN); + STAT_PATTERN_MAP.put("sea_creature_chance", SCC_PATTERN); + } + private static PlayerStats.Stats getStatForItem(ItemStack stack, HashMap patternMap, boolean addExtras) { + String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack); + NBTTagCompound tag = stack.getTagCompound(); + PlayerStats.Stats stats = new PlayerStats.Stats(); + + if(internalname == null) { + return stats; + } + + if(tag != null) { + NBTTagCompound display = tag.getCompoundTag("display"); + if (display.hasKey("Lore", 9)) { + NBTTagList list = display.getTagList("Lore", 8); + for (int i = 0; i < list.tagCount(); i++) { + String line = list.getStringTagAt(i); + for(Map.Entry entry : patternMap.entrySet()) { + Matcher matcher = entry.getValue().matcher(Utils.cleanColour(line)); + if(matcher.find()) { + int bonus = Integer.parseInt(matcher.group(1)); + stats.addStat(entry.getKey(), bonus); + } + } + } + } + } + + if(!addExtras) return stats; + + if(internalname.equals("DAY_CRYSTAL") || internalname.equals("NIGHT_CRYSTAL")) { + stats.addStat(PlayerStats.STRENGTH, 2.5f); + stats.addStat(PlayerStats.DEFENCE, 2.5f); + } + + if(internalname.equals("NEW_YEAR_CAKE_BAG") && tag != null && tag.hasKey("ExtraAttributes", 10)) { + NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes"); + + byte[] bytes = null; + for (String key : ea.getKeySet()) { + if (key.endsWith("backpack_data") || key.equals("new_year_cake_bag_data")) { + bytes = ea.getByteArray(key); + try { + NBTTagCompound contents_nbt = CompressedStreamTools.readCompressed(new ByteArrayInputStream(bytes)); + NBTTagList items = contents_nbt.getTagList("i", 10); + HashSet cakes = new HashSet<>(); + for(int j=0; j 0) { + NBTTagCompound nbt = items.getCompoundTagAt(j).getCompoundTag("tag"); + if(nbt != null && nbt.hasKey("ExtraAttributes", 10)) { + NBTTagCompound ea2 = nbt.getCompoundTag("ExtraAttributes"); + if (ea2.hasKey("new_years_cake")) { + cakes.add(ea2.getInteger("new_years_cake")); + } + } + } + } + stats.addStat(PlayerStats.HEALTH, cakes.size()); + } catch(IOException e) { + e.printStackTrace(); + return stats; + } + break; + } + } + } + return stats; + } + + private static String[] rarityArr = new String[] { + "COMMON", "UNCOMMON", "RARE", "EPIC", "LEGENDARY", "MYTHIC", "SPECIAL", "VERY SPECIAL", + }; + private static String[] rarityArrC = new String[] { + EnumChatFormatting.WHITE+EnumChatFormatting.BOLD.toString()+"COMMON", + EnumChatFormatting.GREEN+EnumChatFormatting.BOLD.toString()+"UNCOMMON", + EnumChatFormatting.BLUE+EnumChatFormatting.BOLD.toString()+"RARE", + EnumChatFormatting.DARK_PURPLE+EnumChatFormatting.BOLD.toString()+"EPIC", + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD.toString()+"LEGENDARY", + EnumChatFormatting.LIGHT_PURPLE+EnumChatFormatting.BOLD.toString()+"MYTHIC", + EnumChatFormatting.RED+EnumChatFormatting.BOLD.toString()+"SPECIAL", + EnumChatFormatting.RED+EnumChatFormatting.BOLD.toString()+"VERY SPECIAL", + EnumChatFormatting.DARK_RED+EnumChatFormatting.BOLD.toString()+"SUPREME", + }; + public static int checkItemType(ItemStack stack, boolean contains, String... typeMatches) { + NBTTagCompound tag = stack.getTagCompound(); + if(tag != null) { + NBTTagCompound display = tag.getCompoundTag("display"); + if (display.hasKey("Lore", 9)) { + NBTTagList list = display.getTagList("Lore", 8); + for (int i = list.tagCount()-1; i >= 0; i--) { + String line = list.getStringTagAt(i); + for(String rarity : rarityArr) { + for(int j=0; j= 0; + } + + public static int getRarity(ItemStack stack) { + NBTTagCompound tag = stack.getTagCompound(); + if(tag != null) { + NBTTagCompound display = tag.getCompoundTag("display"); + if (display.hasKey("Lore", 9)) { + NBTTagList list = display.getTagList("Lore", 8); + for (int i = list.tagCount(); i >= 0; i--) { + String line = list.getStringTagAt(i); + for(int j=0; j 0 && buttons[xi][yi-1]; + boolean right = xi < buttons.length-1 && buttons[xi+1][yi]; + boolean down = yi < buttons[xi].length-1 && buttons[xi][yi+1]; + boolean left = xi > 0 && buttons[xi-1][yi]; + + boolean upleft = yi > 0 && xi > 0 && buttons[xi-1][yi-1]; + boolean upright = yi > 0 && xi < buttons.length-1 && buttons[xi+1][yi-1]; + boolean downright = xi < buttons.length-1 && yi < buttons[xi+1].length-1 && buttons[xi+1][yi+1]; + boolean downleft = xi > 0 && yi < buttons[xi-1].length-1 && buttons[xi-1][yi+1]; + + int ctmIndex = getCTMIndex(up, right, down, left, upleft, upright, downright, downleft); + int[] rgbs = bufferedImageButton.getRGB((ctmIndex%12)*19*horzTexMult, (ctmIndex/12)*19*vertTexMult, + 18*horzTexMult, 18*vertTexMult, null, 0, 18*vertTexMult); + bufferedImageNew.setRGB(x, y, 18*horzTexMult, 18*vertTexMult, rgbs, 0, 18*vertTexMult); + } else { + boolean up = yi > 0 && slots[xi][yi-1]; + boolean right = xi < slots.length-1 && slots[xi+1][yi]; + boolean down = yi < slots[xi].length-1 && slots[xi][yi+1]; + boolean left = xi > 0 && slots[xi-1][yi]; + + boolean upleft = yi > 0 && xi > 0 && slots[xi-1][yi-1]; + boolean upright = yi > 0 && xi < slots.length-1 && slots[xi+1][yi-1]; + boolean downright = xi < slots.length-1 && yi < slots[xi+1].length-1 && slots[xi+1][yi+1]; + boolean downleft = xi > 0 && yi < slots[xi-1].length-1 && slots[xi-1][yi+1]; + + int ctmIndex = getCTMIndex(up, right, down, left, upleft, upright, downright, downleft); + int[] rgbs = bufferedImageSlot.getRGB((ctmIndex%12)*19*horzTexMult, (ctmIndex/12)*19*vertTexMult, + 18*horzTexMult, 18*vertTexMult, null, 0, 18*vertTexMult); + bufferedImageNew.setRGB(x, y, 18*horzTexMult, 18*vertTexMult, rgbs, 0, 18*vertTexMult); + } + } + } + texture = new DynamicTexture(bufferedImageNew); + } catch(Exception e) { + e.printStackTrace(); + } + } + } + + public static void reset() { + texture = null; + loaded = false; + clickedSlot = -1; + clickedSlotMillis = 0; + } + + private static boolean isChestOpen() { + return Minecraft.getMinecraft().currentScreen instanceof GuiChest && + NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && + (NotEnoughUpdates.INSTANCE.manager.config.dynamicMenuBackgroundStyle.value >= 1 && + NotEnoughUpdates.INSTANCE.manager.config.dynamicMenuButtonStyle.value >= 1); + } + + private static boolean hasItem() { + if(!isChestOpen()) return false; + Container container = ((GuiChest)Minecraft.getMinecraft().currentScreen).inventorySlots; + if(container instanceof ContainerChest) { + IInventory lower = ((ContainerChest)container).getLowerChestInventory(); + int size = lower.getSizeInventory(); + for(int index=0; index loadedPortals = new HashSet<>(); + private HashMap portalNameMap = new HashMap<>(); + + @SubscribeEvent + public void onWorldChange(WorldEvent.Load event) { + portalNameMap.clear(); + loadedPortals.clear(); + } + + /** The current GL viewport */ + private static final IntBuffer VIEWPORT = GLAllocation.createDirectIntBuffer(16); + /** The current GL modelview matrix */ + private static final FloatBuffer MODELVIEW = GLAllocation.createDirectFloatBuffer(16); + /** The current GL projection matrix */ + private static final FloatBuffer PROJECTION = GLAllocation.createDirectFloatBuffer(16); + private static final FloatBuffer WINCOORDS = GLAllocation.createDirectFloatBuffer(3); + + private float getFOVModifier(float partialTicks) { + Entity entity = Minecraft.getMinecraft().getRenderViewEntity(); + + float f = Minecraft.getMinecraft().gameSettings.fovSetting; + //f = f * (this.fovModifierHandPrev + (this.fovModifierHand - this.fovModifierHandPrev) * partialTicks); + + if (entity instanceof EntityLivingBase && ((EntityLivingBase)entity).getHealth() <= 0.0F) { + float f1 = (float)((EntityLivingBase)entity).deathTime + partialTicks; + f /= (1.0F - 500.0F / (f1 + 500.0F)) * 2.0F + 1.0F; + } + + Block block = ActiveRenderInfo.getBlockAtEntityViewpoint(Minecraft.getMinecraft().theWorld, entity, partialTicks); + + if (block.getMaterial() == Material.water) { + f = f * 60.0F / 70.0F; + } + + return net.minecraftforge.client.ForgeHooksClient.getFOVModifier(Minecraft.getMinecraft().entityRenderer, entity, block, partialTicks, f); + } + + TexLoc tl = new TexLoc(0, 1, Keyboard.KEY_M); + + @SubscribeEvent + public void renderWorld(RenderGameOverlayEvent event) { + + GlStateManager.getFloat(2982, MODELVIEW); + GlStateManager.getFloat(2983, PROJECTION); + GL11.glGetInteger(GL11.GL_VIEWPORT, VIEWPORT); + + EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; + GlStateManager.disableCull(); + + tl.handleKeyboardInput(); + + WINCOORDS.flip().limit(3); + + /*float objx = -(float)(0-player.posX); + float objy = (float)(100-player.posY-player.eyeHeight); + float objz = (float)(0-player.posZ);*/ + + float dX = -(float)(0-player.posX); + float dY = (float)(100-player.posY-player.eyeHeight); + float dZ = (float)(0-player.posZ); + + //GLU.gluProject(objx, objy, objz, MODELVIEW, PROJECTION, VIEWPORT, WINCOORDS); + + double x = dX*Math.cos(Math.toRadians(player.rotationYawHead))-dZ*Math.sin(Math.toRadians(player.rotationYawHead)); + double z = dX*Math.sin(Math.toRadians(player.rotationYawHead))+dZ*Math.cos(Math.toRadians(player.rotationYawHead)); + + float fov = getFOVModifier(event.partialTicks); + x = x / z * Math.toRadians(fov); + dY = (float)(dY / z * Math.toRadians(fov)); + + //System.out.println(z); + + //GLU.gluProject((float)x, dY, (float)z, MODELVIEW, PROJECTION, VIEWPORT, WINCOORDS); + //x = x / z * 2; + //dY = (float)(dY / z * 2); + + GL11.glEnable(GL11.GL_SCISSOR_TEST); + + GL11.glScissor((int)(x*Minecraft.getMinecraft().displayWidth*tl.x/tl.y)+Minecraft.getMinecraft().displayWidth/2, + (int)(dY+Minecraft.getMinecraft().displayHeight/2), 2, 2); + + drawRect(0, 0, 2000, 2000, -1); + + GL11.glDisable(GL11.GL_SCISSOR_TEST); + + /*for(BlockPos pos : portalNameMap.keySet()) { + WINCOORDS.flip().limit(3); + + /*float objx = -(float)((pos.getX()-player.posX)*Math.cos(Math.toRadians(player.rotationYawHead))*Math.cos(Math.toRadians(player.rotationPitch))); + float objy = (float)((pos.getY()-player.posY)*Math.sin(Math.toRadians(player.rotationPitch))); + float objz = (float)((pos.getZ()-player.posZ)*Math.sin(Math.toRadians(player.rotationYawHead))); + + float objx = -(float)(pos.getX()-player.posX); + float objy = (float)(pos.getY()-player.posY-player.eyeHeight); + float objz = (float)(pos.getZ()-player.posZ); + + GLU.gluProject(objx, objy, objz, MODELVIEW, PROJECTION, VIEWPORT, WINCOORDS); + //GLU.glu + + GL11.glEnable(GL11.GL_SCISSOR_TEST); + + //System.out.println(WINCOORDS.get(1)); + + GL11.glScissor((int)WINCOORDS.get(0)*2, + Minecraft.getMinecraft().displayHeight-(int)WINCOORDS.get(1), (int)50, (int)50); + + //0-1 + //-1 - 1 + //0-1920 + + drawRect(0, 0, 2000, 2000, -1); + + GL11.glDisable(GL11.GL_SCISSOR_TEST); + }*/ + + GlStateManager.enableCull(); + } + + @SubscribeEvent + public void tick(TickEvent.ClientTickEvent event) { + if(Minecraft.getMinecraft().theWorld != null) { + List travelToPositions = new ArrayList<>(); + for(Entity entity : Minecraft.getMinecraft().theWorld.loadedEntityList) { + if(entity instanceof EntityArmorStand) { + EntityArmorStand armorStand = (EntityArmorStand) entity; + if(armorStand.isInvisible() && armorStand.hasCustomName()) { + String customName = armorStand.getCustomNameTag(); + if(customName.equals(EnumChatFormatting.AQUA+"Travel to:")) { + travelToPositions.add(new Vector3f((float)armorStand.posX, (float)armorStand.posY, (float)armorStand.posZ)); + } + } + } + } + travelToPositions.removeAll(loadedPortals); + for(Entity entity : Minecraft.getMinecraft().theWorld.loadedEntityList) { + if(entity instanceof EntityArmorStand) { + EntityArmorStand armorStand = (EntityArmorStand) entity; + if(armorStand.isInvisible() && armorStand.hasCustomName()) { + String customName = armorStand.getCustomNameTag(); + for(Vector3f position : travelToPositions) { + if(position.x == (float)armorStand.posX && position.y-0.375 == (float)armorStand.posY && position.z == (float)armorStand.posZ) { + float smallestDist = 999; + BlockPos closestPortal = null; + for(int xOff=-3; xOff<=3; xOff++) { + for(int zOff=-3; zOff<=3; zOff++) { + if(xOff != 0 && zOff != 0) continue; + BlockPos pos = new BlockPos(armorStand.posX+xOff, armorStand.posY+2, armorStand.posZ+zOff); + if(Minecraft.getMinecraft().theWorld.getBlockState(pos).getBlock() == Blocks.portal) { + float dist = (float)(armorStand.posX-(pos.getX()+0.5) + armorStand.posZ-(pos.getZ()+0.5)); + if(closestPortal == null || dist < smallestDist) { + smallestDist = dist; + closestPortal = pos; + } + } + } + } + if(closestPortal != null) { + portalNameMap.put(closestPortal, customName); + } + } + } + } + } + } + loadedPortals.addAll(travelToPositions); + } + } + + public void tryRegisterPortal() { + + } + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/GuiTextures.java b/src/main/java/io/github/moulberry/notenoughupdates/GuiTextures.java index 9fcb218f..fb8671cb 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/GuiTextures.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/GuiTextures.java @@ -22,8 +22,13 @@ public class GuiTextures { public static final ResourceLocation slider_button = new ResourceLocation("notenoughupdates:slider_button.png"); public static final ResourceLocation item_mask = new ResourceLocation("notenoughupdates:item_mask.png"); + public static final ResourceLocation item_haschild = new ResourceLocation("notenoughupdates:item_haschild.png"); public static final ResourceLocation button_tex = new ResourceLocation("notenoughupdates:button.png"); + public static final ResourceLocation accessory_bag_overlay = new ResourceLocation("notenoughupdates:accessory_bag_overlay.png"); + + public static final ResourceLocation quickcommand_background = new ResourceLocation("notenoughupdates:quickcommand_background.png"); + public static final ResourceLocation gamemodes = new ResourceLocation("notenoughupdates:gamemodes.png"); public static final ResourceLocation radial_square_off = new ResourceLocation("notenoughupdates:radial_square_off.png"); public static final ResourceLocation radial_square_on = new ResourceLocation("notenoughupdates:radial_square_on.png"); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/MorusIntegration.java b/src/main/java/io/github/moulberry/notenoughupdates/MorusIntegration.java new file mode 100644 index 00000000..8ec4263a --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/MorusIntegration.java @@ -0,0 +1,60 @@ +package io.github.moulberry.notenoughupdates; + +import io.github.moulberry.morus.MorusSubstitutor; +import net.minecraft.client.Minecraft; +import net.minecraft.item.ItemStack; + +import java.util.HashMap; +import java.util.Map; + +public class MorusIntegration { + + private static MorusIntegration INSTANCE = new MorusIntegration(); + + public static MorusIntegration getInstance() { + return INSTANCE; + } + + private HashMap itemDrops = null; + private HashMap inventoryItems = null; + + public void tick() { + if(itemDrops == null) { + itemDrops = new HashMap<>(); + for(String item : NotEnoughUpdates.INSTANCE.manager.getItemInformation().keySet()) { + itemDrops.put(item, 0); + } + } + + HashMap newInventoryItems = getInventoryItems(); + if(inventoryItems != null) { + for(String internal : newInventoryItems.keySet()) { + int newAmount = newInventoryItems.get(internal); + int oldAmount = inventoryItems.getOrDefault(internal, 0); + if(newAmount > oldAmount) { + itemDrops.put(internal, itemDrops.getOrDefault(internal, 0)+newAmount-oldAmount); + } + } + } + inventoryItems = newInventoryItems; + + for(Map.Entry entry : itemDrops.entrySet()) { + MorusSubstitutor.putSubstiution("notenoughupdates", "itemdrops."+entry.getKey().toLowerCase(), ""+entry.getValue()); + } + + } + + public HashMap getInventoryItems() { + HashMap inventoryItems = new HashMap<>(); + if(Minecraft.getMinecraft().thePlayer != null) { + for(ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) { + String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack); + if(internalname != null) { + inventoryItems.put(internalname, inventoryItems.getOrDefault(internalname, 0)+stack.stackSize); + } + } + } + return inventoryItems; + } + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index fb6348ee..95eefef5 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -32,6 +32,7 @@ import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.client.event.*; import net.minecraftforge.event.entity.player.ItemTooltipEvent; +import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; @@ -136,7 +137,15 @@ public class NEUEventListener { if(longUpdate) { neu.updateSkyblockScoreboard(); CapeManager.getInstance().tick(); + + if(!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) { + AccessoryBagOverlay.resetCache(); + } + if(neu.hasSkyblockScoreboard()) { + if(Loader.isModLoaded("morus")) { + MorusIntegration.getInstance().tick(); + } lastSkyblockScoreboard = currentTime; if(!joinedSB) { joinedSB = true; @@ -173,8 +182,8 @@ public class NEUEventListener { } if(longUpdate && neu.hasSkyblockScoreboard()) { if(neu.manager.getCurrentProfile() == null || neu.manager.getCurrentProfile().length() == 0) { - ProfileViewer.Profile profile = neu.profileViewer.getProfile( - Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""), (json) -> {}); + ProfileViewer.Profile profile = neu.profileViewer.getProfile(Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""), + callback->{}); if(profile != null) { String latest = profile.getLatestProfile(); if(latest != null) { @@ -276,6 +285,7 @@ public class NEUEventListener { @SubscribeEvent public void onGuiOpen(GuiOpenEvent event) { neu.manager.auctionManager.customAH.lastGuiScreenSwitch = System.currentTimeMillis(); + BetterContainers.reset(); if(event.gui == null && neu.manager.auctionManager.customAH.isRenderOverAuctionView() && !(Minecraft.getMinecraft().currentScreen instanceof CustomAHGui)) { @@ -511,6 +521,7 @@ public class NEUEventListener { if(shouldRenderOverlay(event.gui) && neu.isOnSkyblock()) { renderDungeonChestOverlay(event.gui); + AccessoryBagOverlay.renderOverlay(); } } @@ -748,12 +759,16 @@ public class NEUEventListener { return; } if(shouldRenderOverlay(event.gui) && neu.isOnSkyblock()) { - if(!(hoverInv && focusInv)) { - if(neu.overlay.mouseInput()) { - event.setCanceled(true); - } + if(AccessoryBagOverlay.mouseClick()) { + event.setCanceled(true); } else { - neu.overlay.mouseInputInv(); + if(!(hoverInv && focusInv)) { + if(neu.overlay.mouseInput()) { + event.setCanceled(true); + } + } else { + neu.overlay.mouseInputInv(); + } } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index a3670a86..49a886b6 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -8,8 +8,8 @@ import io.github.moulberry.notenoughupdates.infopanes.*; import io.github.moulberry.notenoughupdates.itemeditor.NEUItemEditor; import io.github.moulberry.notenoughupdates.mbgui.MBAnchorPoint; import io.github.moulberry.notenoughupdates.mbgui.MBGuiElement; +import io.github.moulberry.notenoughupdates.mbgui.MBGuiGroupAligned; import i