diff options
author | BuildTools <james.jenour@protonmail.com> | 2020-12-31 01:26:26 +0800 |
---|---|---|
committer | BuildTools <james.jenour@protonmail.com> | 2020-12-31 01:26:26 +0800 |
commit | 9ae63509ab33c4d3f0ee19bc618ef4e4c654ef46 (patch) | |
tree | b5d9120c9211ec989c05f0fb7d02d6497e49f8d0 | |
parent | 38bfc81ad013925463cd382bf99807d15b4fc53e (diff) | |
download | NotEnoughUpdates-9ae63509ab33c4d3f0ee19bc618ef4e4c654ef46.tar.gz NotEnoughUpdates-9ae63509ab33c4d3f0ee19bc618ef4e4c654ef46.tar.bz2 NotEnoughUpdates-9ae63509ab33c4d3f0ee19bc618ef4e4c654ef46.zip |
1.8-PRE1
21 files changed, 204 insertions, 214 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/BetterPortals.java b/src/main/java/io/github/moulberry/notenoughupdates/BetterPortals.java index 8c512164..03003d4b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/BetterPortals.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/BetterPortals.java @@ -151,6 +151,9 @@ public class BetterPortals extends Gui { @SubscribeEvent public void tick(TickEvent.ClientTickEvent event) { + if(event.phase != TickEvent.Phase.END) { + return; + } if(Minecraft.getMinecraft().theWorld != null) { List<Vector3f> travelToPositions = new ArrayList<>(); for(Entity entity : Minecraft.getMinecraft().theWorld.loadedEntityList) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/CalendarOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/CalendarOverlay.java index db168747..ccfe4a65 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/CalendarOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/CalendarOverlay.java @@ -160,15 +160,19 @@ public class CalendarOverlay { if(jingleIndex == 0) { if (NotEnoughUpdates.INSTANCE.manager.config.eventNotificationSounds.value) { - Minecraft.getMinecraft().thePlayer.playSound("notenoughupdates:calendar_notif_jingle", 1, 1); - } - if (NotEnoughUpdates.INSTANCE.manager.config.eventNotificationSounds.value) { - Minecraft.getMinecraft().thePlayer.playSound("notenoughupdates:calendar_notif_in", 1, 1); + Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create( + new ResourceLocation("notenoughupdates:calendar_notif_jingle") + )); + Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create( + new ResourceLocation("notenoughupdates:calendar_notif_in") + )); } jingleIndex = -15*20; } else if(jingleIndex >= 1) { if (NotEnoughUpdates.INSTANCE.manager.config.eventNotificationSounds.value) { - Minecraft.getMinecraft().thePlayer.playSound("notenoughupdates:calendar_notif_in", 1, 1); + Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create( + new ResourceLocation("notenoughupdates:calendar_notif_in") + )); } jingleIndex = -15*20; } else if(jingleIndex < -1) { @@ -176,7 +180,9 @@ public class CalendarOverlay { } if(jingleIndex == -20*6-10) { if(NotEnoughUpdates.INSTANCE.manager.config.eventNotificationSounds.value) { - Minecraft.getMinecraft().thePlayer.playSound("notenoughupdates:calendar_notif_out", 1, 1); + Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create( + new ResourceLocation("notenoughupdates:calendar_notif_out") + )); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/CustomItemEffects.java b/src/main/java/io/github/moulberry/notenoughupdates/CustomItemEffects.java index dfd26e9a..796d630c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/CustomItemEffects.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/CustomItemEffects.java @@ -121,7 +121,7 @@ public class CustomItemEffects { ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem(); if(held != null) { String internal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held); - if(internal != null && internal.equals("ASPECT_OF_THE_END")) { + if(internal != null && (internal.equals("ASPECT_OF_THE_END") || internal.equals("HYPERION"))) { aoteUseMillis = System.currentTimeMillis(); if(aoteTeleportationCurr == null) { aoteTeleportationCurr = new Vector3f(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index e4ec49cb..47ea832f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -151,6 +151,8 @@ public class NEUEventListener { } DungeonWin.tick(); if(longUpdate) { + NotEnoughUpdates.INSTANCE.overlay.redrawItems(); + if(NotEnoughUpdates.INSTANCE.manager.config.slowDungeonBlocks.value) { DungeonBlocks.tick(); } @@ -212,17 +214,15 @@ public class NEUEventListener { } } SBInfo.getInstance().tick(); - //GuiQuestLine.questLine.tick(); } if(currentTime - lastSkyblockScoreboard < 5*60*1000) { //5 minutes neu.manager.auctionManager.tick(); } else { neu.manager.auctionManager.markNeedsUpdate(); } - //ItemRarityHalo.resetItemHaloCache(); } if(longUpdate && neu.hasSkyblockScoreboard()) { - if(neu.manager.getCurrentProfile() == null || neu.manager.getCurrentProfile().length() == 0) { + /*if(neu.manager.getCurrentProfile() == null || neu.manager.getCurrentProfile().length() == 0) { ProfileViewer.Profile profile = NotEnoughUpdates.profileViewer.getProfile(Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""), callback->{}); if(profile != null) { @@ -231,8 +231,8 @@ public class NEUEventListener { neu.manager.setCurrentProfileBackup(profile.getLatestProfile()); } } - } - if(neu.manager.getCurrentProfile() != null && neu.manager.getCurrentProfile().length() > 0) { + }*/ + /*if(neu.manager.getCurrentProfile() != null && neu.manager.getCurrentProfile().length() > 0) { HashSet<String> newItem = new HashSet<>(); if(Minecraft.getMinecraft().currentScreen instanceof GuiContainer && !(Minecraft.getMinecraft().currentScreen instanceof GuiCrafting)) { @@ -275,7 +275,7 @@ public class NEUEventListener { } } newItemAddMap.keySet().retainAll(newItem); - } + }*/ } } @@ -310,11 +310,15 @@ public class NEUEventListener { } @SubscribeEvent - public void onRenderGameOverlay(RenderGameOverlayEvent event) { - if(event.type != null && event.type.equals(RenderGameOverlayEvent.ElementType.BOSSHEALTH) && + public void onRenderGameOverlayPre(RenderGameOverlayEvent.Pre event) { + if (event.type != null && event.type.equals(RenderGameOverlayEvent.ElementType.BOSSHEALTH) && Minecraft.getMinecraft().currentScreen instanceof GuiContainer && neu.overlay.isUsingMobsFilter()) { event.setCanceled(true); } + } + + @SubscribeEvent + public void onRenderGameOverlayPost(RenderGameOverlayEvent.Post event) { long timeRemaining = 15000 - (System.currentTimeMillis() - notificationDisplayMillis); if(event.type == RenderGameOverlayEvent.ElementType.ALL) { DungeonWin.render(event.partialTicks); @@ -746,6 +750,7 @@ public class NEUEventListener { ItemStack item = lower.getStackInSlot(11+i); String internal = neu.manager.getInternalNameForItem(item); if(internal != null) { + internal = internal.replace("\u00CD", "I").replace("\u0130", "I"); float bazaarPrice = -1; JsonObject bazaarInfo = neu.manager.auctionManager.getBazaarInfo(internal); if(bazaarInfo != null && bazaarInfo.has("avg_sell")) { @@ -1018,59 +1023,6 @@ public class NEUEventListener { } } } - /*if(Minecraft.getMinecraft().theWorld != null && Keyboard.getEventKey() == Keyboard.KEY_RBRACKET && Keyboard.getEventKeyState()) { - Minecraft.getMinecraft().displayGuiScreen(null); - started = true; - final Object[] items = neu.manager.getItemInformation().values().toArray(); - AtomicInteger i = new AtomicInteger(0); - - Runnable checker = new Runnable() { - @Override - public void run() { - int in = i.getAndIncrement(); - /*if(missingRecipe.get()) { - String internalname = ((JsonObject)items[in]).get("internalname").getAsString(); - - JsonArray arr = null; - File f = new File(neu.manager.configLocation, "missing.json"); - try(InputStream instream = new FileInputStream(f)) { - BufferedReader reader = new BufferedReader(new InputStreamReader(instream, StandardCharsets.UTF_8)); - JsonObject json = neu.manager.gson.fromJson(reader, JsonObject.class); - arr = json.getAsJsonArray("missing"); - } catch(IOException e) {} - - try { - JsonObject json = new JsonObject(); - if(arr == null) arr = new JsonArray(); - arr.add(new JsonPrimitive(internalname)); - json.add("missing", arr); - neu.manager.writeJson(json, f); - } catch(IOException e) {} - } - missingRecipe.set(false); - - ses.schedule(() -> { - int index = i.get(); - JsonObject o = (JsonObject)items[index]; - if(Minecraft.getMinecraft().currentScreen != null) { - Minecraft.getMinecraft().displayGuiScreen(null); - } - Minecraft.getMinecraft().thePlayer.sendChatMessage("/viewrecipe " + o.get("internalname").getAsString()); - - ses.schedule(this, 1000, TimeUnit.MILLISECONDS); - }, 100, TimeUnit.MILLISECONDS); - } - }; - - int index = i.get(); - JsonObject o = (JsonObject)items[index]; - if(Minecraft.getMinecraft().currentScreen != null) { - Minecraft.getMinecraft().displayGuiScreen(null); - } - Minecraft.getMinecraft().thePlayer.sendChatMessage("/viewrecipe " + o.get("internalname").getAsString()); - - ses.schedule(checker, 1000, TimeUnit.MILLISECONDS); - }*/ } private static String[] rarityArrC = new String[] { @@ -1088,8 +1040,12 @@ public class NEUEventListener { public void onItemTooltipLow(ItemTooltipEvent event) { if(!NotEnoughUpdates.INSTANCE.isOnSkyblock()) return; - boolean hasEnchantments = event.itemStack.hasTagCompound() && event.itemStack.getTagCompound().hasKey("ExtraAttributes", 10) && - event.itemStack.getTagCompound().getCompoundTag("ExtraAttributes").hasKey("enchantments", 10); + String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(event.itemStack); + if(internalname == null) { + return; + } + + boolean hasEnchantments = event.itemStack.getTagCompound().getCompoundTag("ExtraAttributes").hasKey("enchantments", 10); Set<String> enchantIds = new HashSet<>(); if(hasEnchantments) enchantIds = event.itemStack.getTagCompound().getCompoundTag("ExtraAttributes").getCompoundTag("enchantments").getKeySet(); @@ -1312,7 +1268,6 @@ public class NEUEventListener { if(line.contains(EnumChatFormatting.GRAY+"Buy it now: ") || line.contains(EnumChatFormatting.GRAY+"Bidder: ") || line.contains(EnumChatFormatting.GRAY+"Starting bid: ")) { - String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(event.itemStack); if(internalname != null) { newTooltip.add(""); if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && !Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { @@ -1360,38 +1315,6 @@ public class NEUEventListener { newTooltip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Raw Craft Cost: "+ EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format((int)craftCost.craftCost)+" coins"); } - - /*JsonObject auctionInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(internalname); - - boolean hasAuctionPrice = auctionInfo != null; - - int lowestBin = NotEnoughUpdates.INSTANCE.manager.auctionManager.getLowestBin(internalname); - - NumberFormat format = NumberFormat.getInstance(Locale.US); - APIManager.CraftInfo craftCost = NotEnoughUpdates.INSTANCE.manager.auctionManager.getCraftCost(internalname); - - if(lowestBin > 0) { - newTooltip.add(EnumChatFormatting.GRAY+"Lowest BIN: "+ - EnumChatFormatting.GOLD+format.format(lowestBin)+" coins"); - } - if(hasAuctionPrice) { - int auctionPrice = (int)(auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat()); - newTooltip.add(EnumChatFormatting.GRAY+"AH Price: "+ - EnumChatFormatting.GOLD+format.format(auctionPrice)+" coins"); - newTooltip.add(EnumChatFormatting.GRAY+"AH Sales: "+ - EnumChatFormatting.GOLD+format.format(auctionInfo.get("sales").getAsFloat())+" sales/day"); - if(auctionInfo.has("clean_price")) { - newTooltip.add(EnumChatFormatting.GRAY+"AH Price (Clean): "+ - EnumChatFormatting.GOLD+format.format((int)auctionInfo.get("clean_price").getAsFloat())+" coins"); - newTooltip.add(EnumChatFormatting.GRAY+"AH Sales (Clean): "+ - EnumChatFormatting.GOLD+format.format(auctionInfo.get("clean_sales").getAsFloat())+" sales/day"); - } - - } - if(craftCost.fromRecipe) { - newTooltip.add(EnumChatFormatting.GRAY+"Raw Craft Cost: "+ - EnumChatFormatting.GOLD+format.format((int)craftCost.craftCost)+" coins"); - }*/ } } } @@ -1551,8 +1474,6 @@ public class NEUEventListener { event.toolTip.addAll(newTooltip); if(neu.manager.config.invAuctionPrice.value || neu.manager.config.invBazaarPrice.value) { - String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(event.itemStack); - if(internalname != null) { JsonObject auctionInfo = neu.manager.auctionManager.getItemAuctionInfo(internalname); JsonObject bazaarInfo = neu.manager.auctionManager.getBazaarInfo(internalname); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java index 8073227c..d2467176 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java @@ -221,63 +221,15 @@ public class NEUManager { if(latestRepoCommit == null || latestRepoCommit.isEmpty()) return; if(new File(configLocation, "repo").exists() && new File(configLocation, "repo/items").exists()) { - if(currentCommitJSON != null && currentCommitJSON.get("sha").getAsString().equals(latestRepoCommit)) { dialog.setVisible(false); return; } - - /*HashMap<String, String> oldShas = new HashMap<>(); - for (Map.Entry<String, JsonElement> entry : itemShaConfig.entrySet()) { - if (new File(repoLocation, entry.getKey() + ".json").exists()) { - oldShas.put(entry.getKey() + ".json", entry.getValue().getAsString()); - } - } - changedFiles = neuio.getChangedItems(oldShas);*/ } if (Display.isActive()) dialog.toFront(); - if (false) {//changedFiles != null && changedFiles.size() <= 20) { - /*String startMessage = "NotEnoughUpdates: Syncing with remote repository ("; - int downloaded = 0; - - String dlUrl = "https://raw.githubusercontent.com/Moulberry/NotEnoughUpdates-REPO/master/"; - - for (String name : changedFiles.keySet()) { - pane.setMessage(startMessage + (++downloaded) + "/" + changedFiles.size() + ")\nCurrent: " + name); - dialog.pack(); - if(config.dev.value) dialog.setVisible(true); - if (Display.isActive()) dialog.toFront(); - - File item = new File(repoLocation, name); - try { - item.getParentFile().mkdirs(); - item.createNewFile(); - } catch (IOException e) { - continue; - } - URL url = new URL(dlUrl+name); - URLConnection urlConnection = url.openConnection(); - urlConnection.setConnectTimeout(5000); - urlConnection.setReadTimeout(5000); - try (BufferedInputStream inStream = new BufferedInputStream(urlConnection.getInputStream()); - FileOutputStream fileOutputStream = new FileOutputStream(item)) { - byte dataBuffer[] = new byte[1024]; - int bytesRead; - while ((bytesRead = inStream.read(dataBuffer, 0, 1024)) != -1) { - fileOutputStream.write(dataBuffer, 0, bytesRead); - } - itemShaConfig.addProperty(name.substring(0, name.length() - 5), - changedFiles.get(name)); - } catch (IOException e) { - } - } - try { - writeJson(itemShaConfig, itemShaLocation); - } catch (IOException e) { - e.printStackTrace(); - }*/ + if (false) { } else { Utils.recursiveDelete(repoLocation); repoLocation.mkdirs(); @@ -318,17 +270,6 @@ public class NEUManager { if (Display.isActive()) dialog.toFront(); unzipIgnoreFirstFolder(itemsZip.getAbsolutePath(), repoLocation.getAbsolutePath()); - - /*if (changedFiles != null) { - for (Map.Entry<String, String> changedFile : changedFiles.entrySet()) { - itemShaConfig.addProperty(changedFile.getKey().substring(0, changedFile.getKey().length() - 5), - changedFile.getValue()); - } - try { - writeJson(itemShaConfig, itemShaLocation); - } catch (IOException e) { - } - }*/ } if(currentCommitJSON == null || !currentCommitJSON.get("sha").getAsString().equals(latestRepoCommit)) { @@ -360,6 +301,7 @@ public class NEUManager { } }); + System.out.println("finished thread create"); File items = new File(repoLocation, "items"); if(items.exists()) { File[] itemFiles = new File(repoLocation, "items").listFiles(); @@ -370,7 +312,6 @@ public class NEUManager { } } } - thread.start(); } @@ -1396,14 +1337,29 @@ public class NEUManager { } public ItemStack jsonToStack(JsonObject json, boolean useCache) { - return jsonToStack(json, useCache, true); + return jsonToStack(json, useCache, true, false); } - public ItemStack jsonToStack(JsonObject json, boolean useCache, boolean useReplacements) { + private static ExecutorService asyncItemES = Executors.newFixedThreadPool(10); + public ItemStack jsonToStack(JsonObject json, boolean useCache, boolean useReplacements, boolean multithread) { if(json == null) return new ItemStack(Items.painting, 1, 10); - - if(useCache && itemstackCache.containsKey(json.get("internalname").getAsString())) { - return itemstackCache.get(json.get("internalname").getAsString()).copy(); + String internalname = json.get("internalname").getAsString(); + + if(useCache) { + if(itemstackCache.containsKey(internalname)) { + ItemStack stack = itemstackCache.get(internalname); + if(stack == null) { + if(multithread) { + return null; + } + } else { + return stack.copy(); + } + } else if(multithread) { + asyncItemES.submit(() -> jsonToStack(json, true, useReplacements, false)); + itemstackCache.put(internalname, null); + return null; + } } ItemStack stack = new ItemStack(Item.itemRegistry.getObject( @@ -1452,7 +1408,7 @@ public class NEUManager { } } - if(useCache) itemstackCache.put(json.get("internalname").getAsString(), stack); + if(useCache) itemstackCache.put(internalname, stack); return stack; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index 7fc519a8..94302007 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -2255,7 +2255,8 @@ public class NEUOverlay extends Gui { iterateItemSlots(new ItemSlotConsumer() { public void consume(int x, int y, int id) { JsonObject json = getSearchedItemPage(id); - if (json == null || !manager.jsonToStack(json).hasEffect()) { + ItemStack stack = manager.jsonToStack(json, true, true, true); + if (json == null || stack == null || !stack.hasEffect()) { return; } @@ -2409,11 +2410,13 @@ public class NEUOverlay extends Gui { renderEntity(x + ITEM_SIZE / 2, y + ITEM_SIZE, scale, name, entities); } else { if(!items) return; - ItemStack stack = manager.jsonToStack(json); - if(glint) { - Utils.drawItemStack(stack, x, y); - } else { - Utils.drawItemStackWithoutGlint(stack, x, y); + ItemStack stack = manager.jsonToStack(json, true, true, true); + if(stack != null) { + if(glint) { + Utils.drawItemStack(stack, x, y); + } else { + Utils.drawItemStackWithoutGlint(stack, x, y); + } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index fefa6ec0..a7f37935 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -99,6 +99,11 @@ public class NotEnoughUpdates { SimpleCommand collectionLogCommand = new SimpleCommand("neucl", new SimpleCommand.ProcessCommandRunnable() { public void processCommand(ICommandSender sender, String[] args) { + if(true) { + sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + + "This feature has been disabled temporarily.")); + return; + } if(!OpenGlHelper.isFramebufferEnabled()) { sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "This feature requires FBOs to work. Try disabling Optifine's 'Fast Render'.")); @@ -867,6 +872,7 @@ public class NotEnoughUpdates { MinecraftForge.EVENT_BUS.register(CustomItemEffects.INSTANCE); MinecraftForge.EVENT_BUS.register(new DungeonMap()); MinecraftForge.EVENT_BUS.register(new SunTzu()); + //MinecraftForge.EVENT_BUS.register(new BetterPortals()); File f = new File(event.getModConfigurationDirectory(), "notenoughupdates"); 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 242ad2af..4013a790 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java @@ -171,16 +171,14 @@ public class APIManager { } public void tick() { - if(manager.config.apiKey.value == null || manager.config.apiKey.value.isEmpty()) return; - customAH.tick(); long currentTime = System.currentTimeMillis(); - if(manager.config.neuAuctionHouse.value) { + if(manager.config.neuAuctionHouse.value && manager.config.apiKey.value != null && + !manager.config.apiKey.value.isEmpty()) { if(currentTime - lastAuctionUpdate > 60*1000) { lastAuctionUpdate = currentTime; updatePageTick(); } - if(currentTime - lastShortAuctionUpdate > 10*1000) { lastShortAuctionUpdate = currentTime; updatePageTickShort(); @@ -198,11 +196,11 @@ public class APIManager { } } } - if(currentTime - lastAuctionAvgUpdate > 30*60*1000) { //30 minutes - lastAuctionAvgUpdate = currentTime - 28*60*1000; //Try again in 2 minutes if updateAvgPrices doesn't succeed + if(currentTime - lastAuctionAvgUpdate > 5*60*1000) { //5 minutes + lastAuctionAvgUpdate = currentTime - 4*60*1000; //Try again in 1 minute if updateAvgPrices doesn't succeed updateAvgPrices(); } - if(currentTime - lastBazaarUpdate > 10*60*1000) { + if(currentTime - lastBazaarUpdate > 5*60*1000) { //5 minutes lastBazaarUpdate = currentTime; updateBazaar(); } @@ -585,7 +583,7 @@ public class APIManager { //System.out.println("Trying to update page: " + page); HashMap<String, String> args = new HashMap<>(); args.put("page", ""+page); - manager.hypixelApi.getHypixelApiAsync(manager.config.apiKey.value, "skyblock/auctions", + manager.hypixelApi.getHypixelApiAsync(null, "skyblock/auctions", args, jsonObject -> { if(jsonObject == null) return; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java index 42346651..f7b22db0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java @@ -206,6 +206,7 @@ public class CustomAH extends Gui { } public void tick() { + if(!manager.config.neuAuctionHouse.value) return; if(Minecraft.getMinecraft().currentScreen instanceof CustomAHGui || renderOverAuctionView) { if(shouldUpdateSearch) updateSearch(); if(shouldSortItems) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java index c542600e..76885703 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java @@ -6,6 +6,7 @@ import io.github.moulberry.notenoughupdates.NEUManager; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.util.HypixelApi; import net.minecraft.client.Minecraft; +import net.minecraft.client.shader.Framebuffer; import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.client.event.RenderPlayerEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @@ -13,6 +14,8 @@ import net.minecraftforge.fml.common.gameevent.TickEvent; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.tuple.MutablePair; import org.apache.commons.lang3.tuple.Pair; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL30; import java.io.IOException; import java.util.HashMap; @@ -33,8 +36,8 @@ public class CapeManager { private HashSet<String> availableCapes = new HashSet<>(); private String[] capes = new String[]{"patreon1", "patreon2", "fade", "contrib", "nullzee", - "gravy", "space", "mcworld", "lava", "packshq", "mbstaff", "thebakery" }; - public Boolean[] specialCapes = new Boolean[]{ true, true, false, true, true, true, false, false, false, true, true, true }; + "gravy", "space", "mcworld", "lava", "packshq", "mbstaff", "thebakery", "negative" }; + public Boolean[] specialCapes = new Boolean[]{ true, true, false, true, true, true, false, false, false, true, true, true, false }; public static CapeManager getInstance() { return INSTANCE; @@ -146,6 +149,35 @@ public class CapeManager { return null; } + private static Framebuffer checkFramebufferSizes(Framebuffer framebuffer, int width, int height) { + if(framebuffer == null || framebuffer.framebufferWidth != width || framebuffer.framebufferHeight != height) { + if(framebuffer == null) { + framebuffer = new Framebuffer(width, height, true); + } else { + framebuffer.createBindFramebuffer(width, height); + } + framebuffer.setFramebufferFilter(GL11.GL_NEAREST); + } + return framebuffer; + } + + public Framebuffer backgroundFramebuffer = null; + @SubscribeEvent + public void onRenderPlayer(RenderPlayerEvent.Pre e) { + int width = Minecraft.getMinecraft().displayWidth; + int height = Minecraft.getMinecraft().displayHeight; + backgroundFramebuffer = checkFramebufferSizes(backgroundFramebuffer, + width, height); + + GL30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, Minecraft.getMinecraft().getFramebuffer().framebufferObject); + GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, backgroundFramebuffer.framebufferObject); + GL30.glBlitFramebuffer(0, 0, width, height, + 0, 0, width, height, + GL11.GL_COLOR_BUFFER_BIT, GL11.GL_NEAREST); + + Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true); + } + @SubscribeEvent public void onRenderPlayer(RenderPlayerEvent.Post e) { if(e.partialRenderTick == 1.0F) return; //rendering in inventory @@ -172,6 +204,8 @@ public class CapeManager { @SubscribeEvent public void onTick(TickEvent.ClientTickEvent event) { + if (event.phase != TickEvent.Phase.END) return; + String clientUuid = null; if(Minecraft.getMinecraft().thePlayer != null) { clientUuid = Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""); @@ -209,6 +243,4 @@ public class CapeManager { return capes; } - //private String[] contributors = new String[]{"thatgravyboat", "twasnt", "traxyrr", "some1sm", "meguminqt", "marethyu_77"}; - } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeNode.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeNode.java index bfd33e48..b01365d3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeNode.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeNode.java @@ -308,18 +308,6 @@ public class CapeNode { .normal(nodeNorm.x, nodeNorm.y, nodeNorm.z).endVertex(); } tessellator.draw(); - - /*for(CapeNode node : new CapeNode[]{this, nodeDown, nodeRight, nodeDownRight}) { - Vector3f nodeNorm = node.normal(); - worldrenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_TEX_NORMAL); - worldrenderer.pos(node.renderPosition.x+nodeNorm.x*0.05f, node.renderPosition.y+nodeNorm.y*0.05f, node.renderPosition.z+nodeNorm.z*0.05f) - .tex(node.texU, node.texV) - .normal(nodeNorm.x, nodeNorm.y, nodeNorm.z).endVertex(); - worldrenderer.pos(node.renderPosition.x+nodeNorm.x*0.25f, node.renderPosition.y+nodeNorm.y*0.25f, node.renderPosition.z+nodeNorm.z*0.25f) - .tex(node.texU, node.texV) - .normal(nodeNorm.x, nodeNorm.y, nodeNorm.z).endVertex(); - tessellator.draw(); - }*/ } if(nodeLeft == null || nodeRight == null) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java index cc5faa3f..9de2731c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java @@ -22,6 +22,7 @@ import org.lwjgl.BufferUtils; import org.lwjgl.Sys; import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.*; +import org.lwjgl.util.vector.Vector2f; import org.lwjgl.util.vector.Vector3f; import java.nio.FloatBuffer; @@ -85,6 +86,8 @@ public class NEUCape { shaderName = "lightning_cape"; } else if(capeName.equalsIgnoreCase("thebakery")) { shaderName = "biscuit_cape"; + } else if(capeName.equalsIgnoreCase("negative")) { + shaderName = "negative"; } else { shaderName = "shiny_cape"; } @@ -115,7 +118,9 @@ public class NEUCape { } private void bindTexture() { - if(capeTextures != null && capeTextures.length>0) { + if(capeName.equalsIgnoreCase("negative")) { + CapeManager.getInstance().backgroundFramebuffer.bindFramebufferTexture(); + } else if(capeTextures != null && capeTextures.length>0) { long currentTime = System.currentTimeMillis(); if(currentTime - lastFrameUpdate > 100) { lastFrameUpdate = currentTime/100*100; @@ -315,6 +320,11 @@ public class NEUCape { } else if(shaderName.equalsIgnoreCase("biscuit_cape") || shaderName.equalsIgnoreCase("shiny_cape")) { shaderManager.loadData(shaderName, "millis", (int) (System.currentTimeMillis() - startTime)); shaderManager.loadData(shaderName, "eventMillis", (int)(System.currentTimeMillis()-eventMillis)); + } else if(shaderName.equalsIgnoreCase("negative")) { + shaderManager.loadData(shaderName, "screensize", new Vector2f( + Minecraft.getMinecraft().displayWidth, + Minecraft.getMinecraft().displayHeight + )); } } @@ -339,8 +349,8 @@ public class NEUCape { GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO); bindTexture(); - GL11.glTexParameteri(GL11.GL_TEXTURE_2D, 0x8191, GL11.GL_TRUE); GlStateManager.enableTexture2D(); + GlStateManager.enableDepth(); GlStateManager.disableCull(); if(shaderName.equals("mcworld_cape")) { @@ -363,7 +373,7 @@ public class NEUCape { GL20.glUseProgram(0); - GL11.glEnable(GL11.GL_CULL_FACE); + GlStateManager.enableCull(); GlStateManager.enableTexture2D(); GlStateManager.disableBlend(); GlStateManager.popMatrix(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/ShaderManager.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/ShaderManager.java index 7d74ae22..a750f597 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/ShaderManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/ShaderManager.java @@ -4,6 +4,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.GL43; +import org.lwjgl.util.vector.Vector2f; import org.lwjgl.util.vector.Vector3f; import org.lwjgl.util.vector.Vector4f; @@ -54,6 +55,9 @@ public class ShaderManager { GL20.glUniform1i(location, (Integer) value); } else if(value instanceof Float) { GL20.glUniform1f(location, (Float) value); + } else if(value instanceof Vector2f) { + Vector2f vec = (Vector2f) value; + GL20.glUniform2f(location, vec.x, vec.y); } else if(value instanceof Vector3f) { Vector3f vec = (Vector3f) value; GL20.glUniform3f(location, vec.x, vec.y, vec.z); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java b/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java index 09f00beb..692c1d4f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java @@ -241,6 +241,8 @@ public class SBGamemodes { @SubscribeEvent public void onTick(TickEvent.ClientTickEvent event) { + if (event.phase != TickEvent.Phase.START) return; + if(getGamemode() == null || !NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return; boolean inDungeons = SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().equals("dungeon"); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityRenderer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityRenderer.java index 1f77b9cc..b9820033 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityRenderer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityRenderer.java @@ -1,13 +1,19 @@ package io.github.moulberry.notenoughupdates.mixins; +import io.github.moulberry.notenoughupdates.BetterContainers; import io.github.moulberry.notenoughupdates.CustomItemEffects; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.renderer.EntityRenderer; +import net.minecraft.client.renderer.RenderGlobal; +import net.minecraft.entity.Entity; +import net.minecraft.util.EnumWorldBlockLayer; import org.lwjgl.util.vector.Vector3f; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(EntityRenderer.class) 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 dd250d90..9480db06 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java @@ -734,7 +734,7 @@ public class GuiProfileViewer extends GuiScreen { JsonObject petItem = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(petname+";"+tierNum); if(petItem == null) continue; - ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(petItem, false, false); + ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(petItem, false, false, false); HashMap<String, String> replacements = NotEnoughUpdates.INSTANCE.manager.getLoreReplacements(petname, tier, (int)Math.floor(level)); if(heldItem != null) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/questing/SBInfo.java b/src/main/java/io/github/moulberry/notenoughupdates/questing/SBInfo.java index 2d594ccf..67cd79a9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/questing/SBInfo.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/questing/SBInfo.java @@ -84,10 +84,8 @@ public class SBInfo { ScoreObjective sidebarObjective = scoreboard.getObjectiveInDisplaySlot(1); //ยง707/14/20 - List<Score> scores = new ArrayList<>(); - for(Score score : scoreboard.getSortedScores(sidebarObjective)) { - scores.add(score); - } + List<Score> scores = new ArrayList<>(scoreboard.getSortedScores(sidebarObjective)); + List<String> lines = new ArrayList<>(); for(int i=scores.size()-1; i>=0; i--) { Score score = scores.get(i); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java b/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java index db630b84..c237959a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java @@ -26,7 +26,7 @@ public class HypixelApi { private static final int FAILS_BEFORE_SWITCH = 3; private int currentUrl = 0; private long lastPrimaryUrl = 0; - private final String[] myApiURLs = {"https://moulberry.codes/", "http://51.79.51.21/", "http://moulberry.codes/", "http://51.75.78.252/" }; + private final String[] myApiURLs = {"https://moulberry.codes/"};//, "http://moulberry.codes/", "http://51.79.51.21/"};//, "http://51.75.78.252/" }; private final Integer[] myApiSuccesses = {0, 0, 0, 0}; public void getHypixelApiAsync(String apiKey, String method, HashMap<String, String> args, Consumer<JsonObject> consumer) { @@ -34,7 +34,7 @@ public class HypixelApi { } public void getHypixelApiAsync(String apiKey, String method, HashMap<String, String> args, Consumer<JsonObject> consumer, Runnable error) { - getApiAsync(generateApiUrl(apiKey.trim(), method, args), consumer, error); + getApiAsync(generateApiUrl(apiKey!=null?apiKey.trim():null, method, args), consumer, error); } private String getMyApiURL() { @@ -79,6 +79,7 @@ public class HypixelApi { try { consumer.accept(getApiSync(getMyApiURL()+urlS)); } catch(Exception e) { + e.printStackTrace(); myApiError(current); error.run(); } @@ -132,9 +133,16 @@ public class HypixelApi { } public String generateApiUrl(String apiKey, String method, HashMap<String, String> args) { - StringBuilder url = new StringBuilder("https://api.hypixel.net/" + method + "?key=" + apiKey); + StringBuilder url = new StringBuilder("https://api.hypixel.net/" + method + (apiKey != null ? ("?key=" + apiKey) : "")); + boolean first = true; for(Map.Entry<String, String> entry : args.entrySet()) { - url.append("&").append(entry.getKey()).append("=").append(entry.getValue()); + if(first && apiKey == null) { + url.append("?"); + first = false; + } else { + url.append("&"); + } + url.append(entry.getKey()).append("=").append(entry.getValue()); } return url.toString(); } diff --git a/src/main/resources/assets/notenoughupdates/shaders/negative.frag b/src/main/resources/assets/notenoughupdates/shaders/negative.frag new file mode 100644 index 00000000..a601bd0c --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/shaders/negative.frag @@ -0,0 +1,33 @@ +#version 130 + +varying vec4 passColour; +varying vec3 passNormal; +uniform sampler2D textureIn; +varying vec4 passPosition; +uniform vec2 screensize; + +int a(float f) { + return int(round(f*1999)); +} + +void main() { + vec2 viewportCoord = gl_FragCoord.xy/screensize.xy; + vec4 texture = texture2D(textureIn, viewportCoord); + + int offsetFactor = a(viewportCoord.x)^a(viewportCoord.y); + float dist = 1+mod(offsetFactor/4, 2); + float xOffset = dist*mod(offsetFactor-1, 2); + float yOffset = dist*mod(offsetFactor-2, 2); + + texture = texture2D(textureIn, vec2(viewportCoord.x+xOffset/screensize.x, viewportCoord.y+yOffset/screensize.y)); + texture = vec4(texture.rgb*texture.a, 1); + texture.rgb = 1 - texture.rgb; + + gl_FragColor = texture * passColour; + + vec3 fakeSunNormal = normalize(vec3(0.2f,1.0f,-0.2f)); + vec3 normNormal = normalize(passNormal); + float shading = max(0.6f, dot(fakeSunNormal, normNormal)); + + gl_FragColor = vec4(gl_FragColor.rgb*shading, 1); +}
\ No newline at end of file diff --git a/src/main/resources/assets/notenoughupdates/shaders/negative.vert b/src/main/resources/assets/notenoughupdates/shaders/negative.vert new file mode 100644 index 00000000..9ccbcd6f --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/shaders/negative.vert @@ -0,0 +1,15 @@ +#version 120 + +varying vec4 passColour; +varying vec3 passNormal; +varying vec4 passPosition; +uniform vec2 screensize; + +void main() { + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + gl_TexCoord[0] = gl_MultiTexCoord0; + + passColour = gl_Color; + passNormal = normalize(gl_Normal); + passPosition = gl_Position; +}
\ No newline at end of file diff --git a/src/main/resources/assets/notenoughupdates/wkhtmltox.zip b/src/main/resources/assets/notenoughupdates/wkhtmltox.zip Binary files differdeleted file mode 100644 index 88e17154..00000000 --- a/src/main/resources/assets/notenoughupdates/wkhtmltox.zip +++ /dev/null |