From 03b9a8dbcc1ebd5f8c39e4733a741a4092ab0a1d Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sat, 27 Mar 2021 07:40:53 +0800 Subject: PRE26 --- .../notenoughupdates/ItemPriceInformation.java | 7 +- .../notenoughupdates/NEUEventListener.java | 181 +- .../moulberry/notenoughupdates/NEUManager.java | 139 +- .../moulberry/notenoughupdates/NEUOverlay.java | 124 +- .../notenoughupdates/NotEnoughUpdates.java | 57 +- .../notenoughupdates/core/GuiElementTextField.java | 17 +- .../notenoughupdates/cosmetics/CapeManager.java | 7 +- .../notenoughupdates/cosmetics/CapeNode.java | 60 +- .../notenoughupdates/cosmetics/GuiCosmetics.java | 2 +- .../notenoughupdates/cosmetics/NEUCape.java | 817 ++++-- .../notenoughupdates/infopanes/HTMLInfoPane.java | 83 +- .../miscfeatures/CustomItemEffects.java | 5 + .../miscfeatures/EnchantingSolvers.java | 13 +- .../notenoughupdates/miscfeatures/MiningStuff.java | 35 - .../miscfeatures/NullzeeSphere.java | 234 ++ .../miscfeatures/PetInfoOverlay.java | 257 +- .../notenoughupdates/miscgui/CalendarOverlay.java | 97 +- .../miscgui/GuiInvButtonEditor.java | 677 +++++ .../mixins/GuiContainerAccessor.java | 22 + .../notenoughupdates/mixins/MixinContainer.java | 2 +- .../notenoughupdates/mixins/MixinGuiContainer.java | 16 + .../notenoughupdates/mixins/MixinGuiInventory.java | 22 + .../notenoughupdates/mixins/MixinItemStack.java | 4 + .../mixins/MixinLayerCreeperCharge.java | 26 - .../mixins/MixinNetHandlerPlayClient.java | 6 +- .../mixins/MixinPlayerControllerMP.java | 4 +- .../notenoughupdates/mixins/MixinRenderItem.java | 82 + .../notenoughupdates/options/NEUConfig.java | 181 +- .../notenoughupdates/overlays/TimersOverlay.java | 7 +- .../profileviewer/GuiProfileViewer.java | 3 +- .../profileviewer/ProfileViewer.java | 2 +- .../assets/notenoughupdates/capes/alexxoffi.png | Bin 0 -> 588408 bytes .../notenoughupdates/capes/alexxoffi_preview.png | Bin 0 -> 135662 bytes .../assets/notenoughupdates/capes/dsm.png | Bin 62154 -> 56800 bytes .../assets/notenoughupdates/capes/dsm_preview.png | Bin 0 -> 42820 bytes .../assets/notenoughupdates/capes/furf.png | Bin 15699 -> 8145 bytes .../assets/notenoughupdates/capes/furf_preview.png | Bin 11892 -> 3360 bytes .../assets/notenoughupdates/capes/jakethybro.png | Bin 0 -> 151284 bytes .../notenoughupdates/capes/jakethybro_preview.png | Bin 0 -> 111454 bytes .../assets/notenoughupdates/capes/parallax.png | Bin 0 -> 357618 bytes .../assets/notenoughupdates/capes/zera.png | Bin 0 -> 325454 bytes .../assets/notenoughupdates/capes/zera_preview.png | Bin 0 -> 156882 bytes .../assets/notenoughupdates/invbuttons/editor.png | Bin 0 -> 1806 bytes .../invbuttons/expanded_inventory.png | Bin 0 -> 2494 bytes .../notenoughupdates/invbuttons/extraicons.json | 18 + .../invbuttons/extraicons/accessory.png | Bin 0 -> 1778 bytes .../invbuttons/extraicons/accessory_gold.png | Bin 0 -> 1859 bytes .../invbuttons/extraicons/armor.png | Bin 0 -> 1782 bytes .../invbuttons/extraicons/armor_gold.png | Bin 0 -> 1917 bytes .../invbuttons/extraicons/baubles.png | Bin 0 -> 776 bytes .../invbuttons/extraicons/baubles_gold.png | Bin 0 -> 810 bytes .../invbuttons/extraicons/cross.png | Bin 0 -> 1747 bytes .../invbuttons/extraicons/green_check.png | Bin 0 -> 1637 bytes .../notenoughupdates/invbuttons/extraicons/pet.png | Bin 0 -> 1826 bytes .../invbuttons/extraicons/pet_gold.png | Bin 0 -> 1919 bytes .../invbuttons/extraicons/question.png | Bin 0 -> 1517 bytes .../invbuttons/extraicons/recipe.png | Bin 0 -> 2176 bytes .../invbuttons/extraicons/search.png | Bin 0 -> 2018 bytes .../invbuttons/extraicons/settings.png | Bin 0 -> 3962 bytes .../invbuttons/extraicons/skyblock_menu.png | Bin 0 -> 2108 bytes .../invbuttons/extraicons/white_check.png | Bin 0 -> 1684 bytes .../notenoughupdates/invbuttons/presets.json | 2729 ++++++++++++++++++++ .../assets/notenoughupdates/search_bar.png | Bin 0 -> 2964 bytes .../assets/notenoughupdates/search_bar_gold.png | Bin 0 -> 4159 bytes .../shaders/capes/planets/planets.frag | 185 ++ .../shaders/capes/planets/planets.vert | 14 + .../shaders/capes/tunnel/tunnel.frag | 50 + .../shaders/capes/tunnel/tunnel.vert | 12 + src/main/resources/mixins.notenoughupdates.json | 5 +- 69 files changed, 5568 insertions(+), 634 deletions(-) create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/NullzeeSphere.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiInvButtonEditor.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mixins/GuiContainerAccessor.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiInventory.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLayerCreeperCharge.java create mode 100644 src/main/resources/assets/notenoughupdates/capes/alexxoffi.png create mode 100644 src/main/resources/assets/notenoughupdates/capes/alexxoffi_preview.png create mode 100644 src/main/resources/assets/notenoughupdates/capes/dsm_preview.png create mode 100644 src/main/resources/assets/notenoughupdates/capes/jakethybro.png create mode 100644 src/main/resources/assets/notenoughupdates/capes/jakethybro_preview.png create mode 100644 src/main/resources/assets/notenoughupdates/capes/parallax.png create mode 100644 src/main/resources/assets/notenoughupdates/capes/zera.png create mode 100644 src/main/resources/assets/notenoughupdates/capes/zera_preview.png create mode 100644 src/main/resources/assets/notenoughupdates/invbuttons/editor.png create mode 100644 src/main/resources/assets/notenoughupdates/invbuttons/expanded_inventory.png create mode 100644 src/main/resources/assets/notenoughupdates/invbuttons/extraicons.json create mode 100644 src/main/resources/assets/notenoughupdates/invbuttons/extraicons/accessory.png create mode 100644 src/main/resources/assets/notenoughupdates/invbuttons/extraicons/accessory_gold.png create mode 100644 src/main/resources/assets/notenoughupdates/invbuttons/extraicons/armor.png create mode 100644 src/main/resources/assets/notenoughupdates/invbuttons/extraicons/armor_gold.png create mode 100644 src/main/resources/assets/notenoughupdates/invbuttons/extraicons/baubles.png create mode 100644 src/main/resources/assets/notenoughupdates/invbuttons/extraicons/baubles_gold.png create mode 100644 src/main/resources/assets/notenoughupdates/invbuttons/extraicons/cross.png create mode 100644 src/main/resources/assets/notenoughupdates/invbuttons/extraicons/green_check.png create mode 100644 src/main/resources/assets/notenoughupdates/invbuttons/extraicons/pet.png create mode 100644 src/main/resources/assets/notenoughupdates/invbuttons/extraicons/pet_gold.png create mode 100644 src/main/resources/assets/notenoughupdates/invbuttons/extraicons/question.png create mode 100644 src/main/resources/assets/notenoughupdates/invbuttons/extraicons/recipe.png create mode 100644 src/main/resources/assets/notenoughupdates/invbuttons/extraicons/search.png create mode 100644 src/main/resources/assets/notenoughupdates/invbuttons/extraicons/settings.png create mode 100644 src/main/resources/assets/notenoughupdates/invbuttons/extraicons/skyblock_menu.png create mode 100644 src/main/resources/assets/notenoughupdates/invbuttons/extraicons/white_check.png create mode 100644 src/main/resources/assets/notenoughupdates/invbuttons/presets.json create mode 100644 src/main/resources/assets/notenoughupdates/search_bar.png create mode 100644 src/main/resources/assets/notenoughupdates/search_bar_gold.png create mode 100644 src/main/resources/assets/notenoughupdates/shaders/capes/planets/planets.frag create mode 100644 src/main/resources/assets/notenoughupdates/shaders/capes/planets/planets.vert create mode 100644 src/main/resources/assets/notenoughupdates/shaders/capes/tunnel/tunnel.frag create mode 100644 src/main/resources/assets/notenoughupdates/shaders/capes/tunnel/tunnel.vert (limited to 'src') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java b/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java index 58efa371..ff618f10 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java @@ -3,6 +3,7 @@ package io.github.moulberry.notenoughupdates; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.auction.APIManager; import io.github.moulberry.notenoughupdates.util.Constants; +import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; @@ -15,6 +16,10 @@ import java.util.Locale; public class ItemPriceInformation { public static boolean addToTooltip(List tooltip, String internalname, ItemStack stack) { + return addToTooltip(tooltip, internalname, stack, true); + } + + public static boolean addToTooltip(List tooltip, String internalname, ItemStack stack, boolean useStackSize) { JsonObject auctionInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(internalname); JsonObject bazaarInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo(internalname); float lowestBinAvg = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAvgBin(internalname); @@ -35,7 +40,7 @@ public class ItemPriceInformation { boolean shiftPressed = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT); int stackMultiplier = 1; - int shiftStackMultiplier = 64; + int shiftStackMultiplier = useStackSize && stack.stackSize > 1 ? stack.stackSize : 64; if(shiftPressed) { stackMultiplier = shiftStackMultiplier; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index 838f0b0a..8219c903 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -1,5 +1,6 @@ package io.github.moulberry.notenoughupdates; +import com.google.common.collect.Lists; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -16,6 +17,8 @@ import io.github.moulberry.notenoughupdates.dungeons.DungeonWin; import io.github.moulberry.notenoughupdates.gamemodes.SBGamemodes; import io.github.moulberry.notenoughupdates.miscfeatures.*; import io.github.moulberry.notenoughupdates.miscgui.*; +import io.github.moulberry.notenoughupdates.mixins.GuiContainerAccessor; +import io.github.moulberry.notenoughupdates.options.NEUConfig; import io.github.moulberry.notenoughupdates.overlays.*; import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer; import io.github.moulberry.notenoughupdates.util.*; @@ -27,6 +30,7 @@ import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.gui.inventory.GuiChest; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.gui.inventory.GuiEditSign; +import net.minecraft.client.gui.inventory.GuiInventory; import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.player.EntityPlayer; @@ -41,6 +45,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTUtil; import net.minecraft.util.*; +import net.minecraftforge.client.ClientCommandHandler; import net.minecraftforge.client.event.*; import net.minecraftforge.event.entity.player.EntityInteractEvent; import net.minecraftforge.event.entity.player.ItemTooltipEvent; @@ -204,7 +209,6 @@ public class NEUEventListener { CrystalOverlay.tick(); DwarvenMinesTextures.tick(); FairySouls.tick(); - MiningStuff.tick(); XPInformation.getInstance().tick(); ProfileApiSyncer.getInstance().tick(); DamageCommas.tick(); @@ -734,6 +738,8 @@ public class NEUEventListener { } } + public static boolean drawingGuiScreen = false; + /** * Sets hoverInv and focusInv variables, representing whether the NEUOverlay should render behind the inventory when * (hoverInv == true) and whether mouse/kbd inputs shouldn't be sent to NEUOverlay (focusInv == true). @@ -756,10 +762,10 @@ public class NEUEventListener { if(event.gui instanceof GuiContainer) { try { - int xSize = (int) Utils.getField(GuiContainer.class, event.gui, "xSize", "field_146999_f"); - int ySize = (int) Utils.getField(GuiContainer.class, event.gui, "ySize", "field_147000_g"); - int guiLeft = (int) Utils.getField(GuiContainer.class, event.gui, "guiLeft", "field_147003_i"); - int guiTop = (int) Utils.getField(GuiContainer.class, event.gui, "guiTop", "field_147009_r"); + int xSize = ((GuiContainerAccessor)event.gui).getXSize(); + int ySize = ((GuiContainerAccessor)event.gui).getYSize(); + int guiLeft = ((GuiContainerAccessor)event.gui).getGuiLeft(); + int guiTop = ((GuiContainerAccessor)event.gui).getGuiTop(); hoverInv = event.getMouseX() > guiLeft && event.getMouseX() < guiLeft + xSize && event.getMouseY() > guiTop && event.getMouseY() < guiTop + ySize; @@ -797,10 +803,16 @@ public class NEUEventListener { } } } + + drawingGuiScreen = true; } + private boolean doInventoryButtons = false; + @SubscribeEvent public void onGuiScreenDrawPre(GuiScreenEvent.DrawScreenEvent.Pre event) { + doInventoryButtons = false; + if(AuctionSearchOverlay.shouldReplace()) { AuctionSearchOverlay.render(); event.setCanceled(true); @@ -839,6 +851,49 @@ public class NEUEventListener { } } } + + if(CalendarOverlay.isEnabled() || event.isCanceled()) return; + if(NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && shouldRenderOverlay(event.gui) + && event.gui instanceof GuiContainer) { + doInventoryButtons = true; + + int zOffset = 50; + + GlStateManager.translate(0, 0, zOffset); + + int xSize = ((GuiContainerAccessor)event.gui).getXSize(); + int ySize = ((GuiContainerAccessor)event.gui).getYSize(); + int guiLeft = ((GuiContainerAccessor)event.gui).getGuiLeft(); + int guiTop = ((GuiContainerAccessor)event.gui).getGuiTop(); + + for(NEUConfig.InventoryButton button : NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons) { + if(!button.isActive()) continue; + if(button.playerInvOnly && !(event.gui instanceof GuiInventory)) continue; + + int x = guiLeft+button.x; + int y = guiTop+button.y; + if(button.anchorRight) { + x += xSize; + } + if(button.anchorBottom) { + y += ySize; + } + + GlStateManager.color(1, 1, 1, 1f); + + GlStateManager.enableDepth(); + GlStateManager.enableAlpha(); + Minecraft.getMinecraft().getTextureManager().bindTexture(EDITOR); + Utils.drawTexturedRect(x, y, 18, 18, + button.backgroundIndex*18/256f, (button.backgroundIndex*18+18)/256f, + 18/256f, 36/256f, GL11.GL_NEAREST); + + if(button.icon != null && !button.icon.trim().isEmpty()) { + GuiInvButtonEditor.renderIcon(button.icon, x+1, y+1); + } + } + GlStateManager.translate(0, 0, -zOffset); + } } private static boolean shouldRenderOverlay(Gui gui) { @@ -854,6 +909,11 @@ public class NEUEventListener { return validGui; } + private static final ResourceLocation EDITOR = new ResourceLocation("notenoughupdates:invbuttons/editor.png"); + private NEUConfig.InventoryButton buttonHovered = null; + private long buttonHoveredMillis = 0; + public static boolean disableCraftingText = false; + /** * Will draw the NEUOverlay over the inventory if focusInv == false. (z-translation of 300 is so that NEUOverlay * will draw over Items in the inventory (which render at a z value of about 250)) @@ -861,6 +921,9 @@ public class NEUEventListener { */ @SubscribeEvent public void onGuiScreenDrawPost(GuiScreenEvent.DrawScreenEvent.Post event) { + drawingGuiScreen = false; + disableCraftingText = false; + if(!(TradeWindow.tradeWindowActive() || event.gui instanceof CustomAHGui || neu.manager.auctionManager.customAH.isRenderOverAuctionView())) { if(shouldRenderOverlay(event.gui) && neu.isOnSkyblock()) { @@ -870,7 +933,6 @@ public class NEUEventListener { neu.overlay.render(hoverInv && focusInv); GL11.glTranslatef(0, 0, -300); } - neu.overlay.renderOverlay(); GlStateManager.popMatrix(); } } @@ -881,6 +943,56 @@ public class NEUEventListener { AccessoryBagOverlay.renderOverlay(); } } + + boolean hoveringButton = false; + if(!doInventoryButtons) return; + if(NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && shouldRenderOverlay(event.gui) && + event.gui instanceof GuiContainer) { + int xSize = ((GuiContainerAccessor)event.gui).getXSize(); + int ySize = ((GuiContainerAccessor)event.gui).getYSize(); + int guiLeft = ((GuiContainerAccessor)event.gui).getGuiLeft(); + int guiTop = ((GuiContainerAccessor)event.gui).getGuiTop(); + + for(NEUConfig.InventoryButton button : NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons) { + if(!button.isActive()) continue; + if(button.playerInvOnly && !(event.gui instanceof GuiInventory)) continue; + + int x = guiLeft+button.x; + int y = guiTop+button.y; + if(button.anchorRight) { + x += xSize; + } + if(button.anchorBottom) { + y += ySize; + } + + if(x-guiLeft >= 85 && x-guiLeft <= 115 && y-guiTop >= 4 && y-guiTop <= 25) { + disableCraftingText = true; + } + + if(event.mouseX >= x && event.mouseX <= x+18 && + event.mouseY >= y && event.mouseY <= y+18) { + hoveringButton = true; + long currentTime = System.currentTimeMillis(); + + if(buttonHovered != button) { + buttonHoveredMillis = currentTime; + buttonHovered = button; + } + + if(currentTime - buttonHoveredMillis > 600) { + String command = button.command.trim(); + if(!command.startsWith("/")) { + command = "/" + command; + } + + Utils.drawHoveringText(Lists.newArrayList("\u00a77"+command), event.mouseX, event.mouseY, + event.gui.width, event.gui.height, -1, Minecraft.getMinecraft().fontRendererObj); + } + } + } + } + if(!hoveringButton) buttonHovered = null; } private void renderDungeonChestOverlay(GuiScreen gui) { @@ -888,10 +1000,10 @@ public class NEUEventListener { if(gui instanceof GuiChest && neu.config.dungeons.profitDisplayLoc != 2) { try { - int xSize = (int) Utils.getField(GuiContainer.class, gui, "xSize", "field_146999_f"); - int ySize = (int) Utils.getField(GuiContainer.class, gui, "ySize", "field_147000_g"); - int guiLeft = (int) Utils.getField(GuiContainer.class, gui, "guiLeft", "field_147003_i"); - int guiTop = (int) Utils.getField(GuiContainer.class, gui, "guiTop", "field_147009_r"); + int xSize = ((GuiContainerAccessor)gui).getXSize(); + int ySize = ((GuiContainerAccessor)gui).getYSize(); + int guiLeft = ((GuiContainerAccessor)gui).getGuiLeft(); + int guiTop = ((GuiContainerAccessor)gui).getGuiTop(); GuiChest eventGui = (GuiChest) gui; ContainerChest cc = (ContainerChest) eventGui.inventorySlots; @@ -1083,7 +1195,7 @@ public class NEUEventListener { * Will also cancel the event if if NEUOverlay#mouseInput returns true. * @param event */ - @SubscribeEvent + @SubscribeEvent(priority = EventPriority.LOW) public void onGuiScreenMouse(GuiScreenEvent.MouseInputEvent.Pre event) { if(!event.isCanceled()) { Utils.scrollTooltip(Mouse.getEventDWheel()); @@ -1121,6 +1233,53 @@ public class NEUEventListener { } } } + if(event.isCanceled()) return; + if(!doInventoryButtons) return; + if(NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && shouldRenderOverlay(event.gui) && Mouse.getEventButton() >= 0 + && event.gui instanceof GuiContainer) { + int xSize = ((GuiContainerAccessor)event.gui).getXSize(); + int ySize = ((GuiContainerAccessor)event.gui).getYSize(); + int guiLeft = ((GuiContainerAccessor)event.gui).getGuiLeft(); + int guiTop = ((GuiContainerAccessor)event.gui).getGuiTop(); + + final ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft()); + final int scaledWidth = scaledresolution.getScaledWidth(); + final int scaledHeight = scaledresolution.getScaledHeight(); + int mouseX = Mouse.getX() * scaledWidth / Minecraft.getMinecraft().displayWidth; + int mouseY = scaledHeight - Mouse.getY() * scaledHeight / Minecraft.getMinecraft().displayHeight - 1; + + for(NEUConfig.InventoryButton button : NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons) { + if(!button.isActive()) continue; + if(button.playerInvOnly && !(event.gui instanceof GuiInventory)) continue; + + int x = guiLeft+button.x; + int y = guiTop+button.y; + if(button.anchorRight) { + x += xSize; + } + if(button.anchorBottom) { + y += ySize; + } + + if(mouseX >= x && mouseX <= x+18 && mouseY >= y && mouseY <= y+18) { + if(Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null) { + int clickType = NotEnoughUpdates.INSTANCE.config.inventoryButtons.clickType; + if((clickType == 0 && Mouse.getEventButtonState()) || (clickType == 1 && !Mouse.getEventButtonState())) { + String command = button.command.trim(); + if(!command.startsWith("/")) { + command = "/" + command; + } + if(ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, command) == 0) { + NotEnoughUpdates.INSTANCE.sendChatMessage(command); + } + } + } else { + event.setCanceled(true); + } + return; + } + } + } } ScheduledExecutorService ses = Executors.newScheduledThreadPool(1); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java index 061d6774..4f392ae8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java @@ -17,6 +17,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.*; import net.minecraft.network.play.client.C0DPacketCloseWindow; import net.minecraft.util.ResourceLocation; +import org.apache.commons.io.FileUtils; import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.Display; @@ -26,6 +27,8 @@ import java.net.URL; import java.net.URLConnection; import java.nio.charset.StandardCharsets; import java.util.*; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -57,10 +60,10 @@ public class NEUManager { private String currentProfileBackup = ""; public final HypixelApi hypixelApi = new HypixelApi(); - private ResourceLocation wkZip = new ResourceLocation("notenoughupdates:wkhtmltox.zip"); private Map itemstackCache = new HashMap<>(); - //private static final String AUCTIONS_PRICE_URL = "https://moulberry.github.io/files/auc_avg_jsons/average_3day.json.gz"; + private ExecutorService repoLoaderES = Executors.newSingleThreadExecutor(); + private static final String GIT_COMMITS_URL = "https://api.github.com/repos/Moulberry/NotEnoughUpdates-REPO/commits/master"; private HashMap> usagesMap = new HashMap<>(); @@ -88,15 +91,6 @@ public class NEUManager { if(itemRenameJson == null) { itemRenameJson = new JsonObject(); } - - File wkShell = new File(configLocation, "wkhtmltox/bin/wkhtmltoimage"); - if(!wkShell.exists()) { - try { - InputStream is = Minecraft.getMinecraft().getResourceManager().getResource(wkZip).getInputStream(); - unzip(is, configLocation); - } catch (IOException e) { - } - } } public void setCurrentProfile(String currentProfile) { @@ -163,7 +157,7 @@ public class NEUManager { }*/ - Thread thread = new Thread(() -> { + repoLoaderES.submit(() -> { JDialog dialog = null; try { if(NotEnoughUpdates.INSTANCE.config.hidden.autoupdate) { @@ -211,12 +205,23 @@ public class NEUManager { } catch (IOException e) { return; } + + URL url = new URL(dlUrl); URLConnection urlConnection = url.openConnection(); urlConnection.setConnectTimeout(15000); - urlConnection.setReadTimeout(20000); - try (BufferedInputStream inStream = new BufferedInputStream(urlConnection.getInputStream()); - FileOutputStream fileOutputStream = new FileOutputStream(itemsZip)) { + urlConnection.setReadTimeout(30000); + + try(InputStream is = urlConnection.getInputStream()) { + FileUtils.copyInputStreamToFile(is, itemsZip); + } catch (IOException e) { + dialog.dispose(); + e.printStackTrace(); + System.err.println("Failed to download NEU Repo! Please report this issue to the mod creator"); + return; + } + /*try (BufferedInputStream inStream = new BufferedInputStream(urlConnection.getInputStream()); + FileOutputStream fileOutputStream = new FileOutputStream(itemsZip)) { byte dataBuffer[] = new byte[1024]; int bytesRead; while ((bytesRead = inStream.read(dataBuffer, 0, 1024)) != -1) { @@ -225,7 +230,7 @@ public class NEUManager { } catch (IOException e) { dialog.dispose(); return; - } + }*/ pane.setMessage("Unzipping NEU Master Archive."); dialog.pack(); @@ -242,6 +247,8 @@ public class NEUManager { } catch (IOException e) { } } + + Constants.reload(); } } catch(Exception e) { e.printStackTrace(); @@ -249,31 +256,40 @@ public class NEUManager { if(dialog != null) dialog.dispose(); } + System.err.println("First load"); + File items = new File(repoLocation, "items"); if(items.exists()) { File[] itemFiles = new File(repoLocation, "items").listFiles(); if(itemFiles != null) { for(File f : itemFiles) { String internalname = f.getName().substring(0, f.getName().length()-5); - if(!getItemInformation().keySet().contains(internalname)) { - loadItem(internalname); + synchronized(itemMap) { + if(!itemMap.keySet().contains(internalname)) { + loadItem(internalname); + } } } } } }); + System.err.println("Second load"); + File items = new File(repoLocation, "items"); if(items.exists()) { File[] itemFiles = new File(repoLocation, "items").listFiles(); if(itemFiles != null) { for(File f : itemFiles) { String internalname = f.getName().substring(0, f.getName().length()-5); - loadItem(internalname); + synchronized(itemMap) { + if(!itemMap.keySet().contains(internalname)) { + loadItem(internalname); + } + } } } } - thread.start(); } /** @@ -301,56 +317,69 @@ public class NEUManager { itemMap.put(internalName, json); if(json.has("recipe")) { - JsonObject recipe = json.get("recipe").getAsJsonObject(); - - String[] x = {"1","2","3"}; - String[] y = {"A","B","C"}; - for(int i=0; i<9; i++) { - String name = y[i/3]+x[i%3]; - String itemS = recipe.get(name).getAsString(); - if(itemS != null && itemS.split(":").length == 2) { - itemS = itemS.split(":")[0]; - } + synchronized(usagesMap) { + JsonObject recipe = json.get("recipe").getAsJsonObject(); + + String[] x = {"1","2","3"}; + String[] y = {"A","B","C"}; + for(int i=0; i<9; i++) { + String name = y[i/3]+x[i%3]; + String itemS = recipe.get(name).getAsString(); + if(itemS != null && itemS.split(":").length == 2) { + itemS = itemS.split(":")[0]; + } - if(!usagesMap.containsKey(itemS)) { - usagesMap.put(itemS, new HashSet<>()); + if(!usagesMap.containsKey(itemS)) { + usagesMap.put(itemS, new HashSet<>()); + } + usagesMap.get(itemS).add(internalName); } - usagesMap.get(itemS).add(internalName); } } if(json.has("displayname")) { - int wordIndex=0; - for(String str : json.get("displayname").getAsString().split(" ")) { - str = clean(str); - if(!titleWordMap.containsKey(str)) { - titleWordMap.put(str, new HashMap<>()); - } - if(!titleWordMap.get(str).containsKey(internalName)) { - titleWordMap.get(str).put(internalName, new ArrayList<>()); + synchronized(titleWordMap) { + int wordIndex=0; + for(String str : json.get("displayname").getAsString().split(" ")) { + str = clean(str); + if(!titleWordMap.containsKey(str)) { + titleWordMap.put(str, new HashMap<>()); + } + if(!titleWordMap.get(str).containsKey(internalName)) { + titleWordMap.get(str).put(internalName, new ArrayList<>()); + } + titleWordMap.get(str).get(internalName).add(wordIndex); + wordIndex++; } - titleWordMap.get(str).get(internalName).add(wordIndex); - wordIndex++; } } if(json.has("lore")) { - int wordIndex=0; - for(JsonElement element : json.get("lore").getAsJsonArray()) { - for(String str : element.getAsString().split(" ")) { - str = clean(str); - if(!loreWordMap.containsKey(str)) { - loreWordMap.put(str, new HashMap<>()); - } - if(!loreWordMap.get(str).containsKey(internalName)) { - loreWordMap.get(str).put(internalName, new ArrayList<>()); + synchronized(loreWordMap) { + int wordIndex=0; + for(JsonElement element : json.get("lore").getAsJsonArray()) { + for(String str : element.getAsString().split(" ")) { + str = clean(str); + if(!loreWordMap.containsKey(str)) { + loreWordMap.put(str, new HashMap<>()); + } + if(!loreWordMap.get(str).containsKey(internalName)) { + loreWordMap.get(str).put(internalName, new ArrayList<>()); + } + loreWordMap.get(str).get(internalName).add(wordIndex); + wordIndex++; } - loreWordMap.get(str).get(internalName).add(wordIndex); - wordIndex++; } } } } catch(Exception e) { + synchronized(loreWordMap) { + System.out.println("loreWordMap is : " + loreWordMap); + } + synchronized(titleWordMap) { + System.out.println("titleWordMap is : " + titleWordMap); + } + System.out.println("internalName is : " + internalName); e.printStackTrace(); } } @@ -1037,7 +1066,7 @@ public class NEUManager { /** * Modified from https://www.journaldev.com/960/java-unzip-file-example */ - private static void unzip(InputStream src, File dest) { + public static void unzip(InputStream src, File dest) { //buffer for read and write data to file byte[] buffer = new byte[1024]; try { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index 689a98f1..d11d21fa 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -64,6 +64,8 @@ import static io.github.moulberry.notenoughupdates.util.GuiTextures.*; public class NEUOverlay extends Gui { private static final ResourceLocation SUPERGEHEIMNISVERMOGEN = new ResourceLocation("notenoughupdates:supersecretassets/bald.png"); + private static final ResourceLocation SEARCH_BAR = new ResourceLocation("notenoughupdates:search_bar.png"); + private static final ResourceLocation SEARCH_BAR_GOLD = new ResourceLocation("notenoughupdates:search_bar_gold.png"); private NEUManager manager; @@ -116,12 +118,15 @@ public class NEUOverlay extends Gui { private LerpingInteger itemPaneTabOffset = new LerpingInteger(20, 50); private LerpingFloat infoPaneOffsetFactor = new LerpingFloat(0); - private boolean searchMode = false; + public boolean searchMode = false; private long millisLastLeftClick = 0; private long millisLastMouseMove = 0; private int lastMouseX = 0; private int lastMouseY = 0; + public static final int overlayColourDark = new Color(0, 0, 0, 120).getRGB(); + public static final int overlayColourLight = new Color(255, 255, 255, 120).getRGB(); + boolean mouseDown = false; private boolean redrawItems = false; @@ -199,14 +204,51 @@ public class NEUOverlay extends Gui { FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; int paddingUnscaled = getPaddingUnscaled(); - //Search bar background - drawRect((int)x, (int)y, - (int)x + getWidth(), (int)y + getHeight(), - searchMode ? Color.YELLOW.getRGB() : Color.WHITE.getRGB()); + GlStateManager.color(1, 1, 1, 1); + if(searchMode) { + Minecraft.getMinecraft().getTextureManager().bindTexture(SEARCH_BAR_GOLD); + } else { + Minecraft.getMinecraft().getTextureManager().bindTexture(SEARCH_BAR); + } + + int w = getWidth(); + int h = getHeight(); + + for(int yIndex=0; yIndex<=2; yIndex++) { + for(int xIndex=0; xIndex<=2; xIndex++) { + float uMin = 0; + float uMax = 4/20f; + int partX = (int)x; + int partW = 4; + if(xIndex == 1) { + partX += 4; + uMin = 4/20f; + uMax = 16/20f; + partW = w-8; + } else if(xIndex == 2) { + partX += w-4; + uMin = 16/20f; + uMax = 20/20f; + } - drawRect((int)x + paddingUnscaled, (int)y + paddingUnscaled, - (int)x - paddingUnscaled + getWidth(), (int)y - paddingUnscaled + getHeight(), - Color.BLACK.getRGB()); + float vMin = 0; + float vMax = 4/20f; + int partY = (int)y; + int partH = 4; + if(yIndex == 1) { + partY += 4; + vMin = 4/20f; + vMax = 16/20f; + partH = h-8; + } else if(yIndex == 2) { + partY += h-4; + vMin = 16/20f; + vMax = 20/20f; + } + + Utils.drawTexturedRect(partX, partY, partW, partH, uMin, uMax, vMin, vMax, GL11.GL_NEAREST); + } + } //Search bar text fr.drawString(textField.getText(), (int)x + 5, @@ -791,6 +833,10 @@ public class NEUOverlay extends Gui { return paddingUnscaled; } + public GuiTextField getTextField() { + return textField; + } + /** * Returns searchBarXSize, scaled by 0.8 if gui scale == AUTO. */ @@ -1521,52 +1567,6 @@ public class NEUOverlay extends Gui { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); } - /** - * Renders black squares over the inventory to indicate items that do not match a specific search. (When searchMode - * is enabled) - */ - public void renderOverlay() { - int width = Utils.peekGuiScale().getScaledWidth(); - int height = Utils.peekGuiScale().getScaledHeight(); - int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; - int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; - - if(searchMode && textField.getText().length() > 0) { - if(Minecraft.getMinecraft().currentScreen instanceof GuiContainer) { - GuiContainer inv = (GuiContainer) Minecraft.getMinecraft().currentScreen; - int guiLeftI = (int)Utils.getField(GuiContainer.class, inv, "guiLeft", "field_147003_i"); - int guiTopI = (int)Utils.getField(GuiContainer.class, inv, "guiTop", "field_147009_r"); - - GL11.glTranslatef(0, 0, 260); - int overlay = new Color(0, 0, 0, 100).getRGB(); - for(Slot slot : inv.inventorySlots.inventorySlots) { - boolean matches = false; - for(String search : textField.getText().split("\\|")) { - matches |= slot.getStack() != null && manager.doesStackMatchSearch(slot.getStack(), search.trim()); - } - if(!matches) { - drawRect(guiLeftI+slot.xDisplayPosition, guiTopI+slot.yDisplayPosition, - guiLeftI+slot.xDisplayPosition+16, guiTopI+slot.yDisplayPosition+16, - overlay); - } - } - if(Utils.getSlotUnderMouse(inv) != null) { - ItemStack stack = Utils.getSlotUnderMouse(inv).getStack(); - //Minecraft.getMinecraft().currentScreen.renderToolTip(stack, mouseX, mouseY); - Class[] params = new Class[]{ItemStack.class, int.class, int.class}; - Method renderToolTip = Utils.getMethod(GuiScreen.class, params, "renderToolTip", "func_146285_a"); - if(renderToolTip != null) { - renderToolTip.setAccessible(true); - try { - renderToolTip.invoke(Minecraft.getMinecraft().currentScreen, stack, mouseX, mouseY); - } catch(Exception e) {} - } - } - GL11.glTranslatef(0, 0, -260); - } - } - } - Shader blurShaderHorz = null; Framebuffer blurOutputHorz = null; Shader blurShaderVert = null; @@ -1729,13 +1729,15 @@ public class NEUOverlay extends Gui { //Atomic reference used so that below lambda doesn't complain about non-effectively-final variable AtomicReference tooltipToDisplay = new AtomicReference<>(null); if(itemPaneOffsetFactor.getValue() < 1) { - BackgroundBlur.renderBlurredBackground(NotEnoughUpdates.INSTANCE.config.itemlist.bgBlurFactor, - width, height, - leftSide+getBoxPadding()-5, getBoxPadding()-5, - paneWidth-getBoxPadding()*2+10, height-getBoxPadding()*2+10, true); - Gui.drawRect(leftSide+getBoxPadding()-5, getBoxPadding()-5, - leftSide+getBoxPadding()-5+paneWidth-getBoxPadding()*2+10, - getBoxPadding()-5+height-getBoxPadding()*2+10, 0xc8101010); + if(NotEnoughUpdates.INSTANCE.config.itemlist.bgBlurFactor > 0.5) { + BackgroundBlur.renderBlurredBackground(NotEnoughUpdates.INSTANCE.config.itemlist.bgBlurFactor, + width, height, + leftSide+getBoxPadding()-5, getBoxPadding()-5, + paneWidth-getBoxPadding()*2+10, height-getBoxPadding()*2+10, true); + Gui.drawRect(leftSide+getBoxPadding()-5, getBoxPadding()-5, + leftSide+getBoxPadding()-5+paneWidth-getBoxPadding()*2+10, + getBoxPadding()-5+height-getBoxPadding()*2+10, 0xc8101010); + } drawRect(leftSide+getBoxPadding()-5, getBoxPadding()-5, leftSide+paneWidth-getBoxPadding()+5, height-getBoxPadding()+5, bg.getRGB()); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index 59c821b0..2da79f84 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -18,10 +18,7 @@ import io.github.moulberry.notenoughupdates.gamemodes.GuiGamemodes; import io.github.moulberry.notenoughupdates.gamemodes.SBGamemodes; import io.github.moulberry.notenoughupdates.infopanes.CollectionLogInfoPane; import io.github.moulberry.notenoughupdates.miscfeatures.*; -import io.github.moulberry.notenoughupdates.miscgui.CalendarOverlay; -import io.github.moulberry.notenoughupdates.miscgui.GuiEnchantColour; -import io.github.moulberry.notenoughupdates.miscgui.HelpGUI; -import io.github.moulberry.notenoughupdates.miscgui.NEUOverlayPlacements; +import io.github.moulberry.notenoughupdates.miscgui.*; import io.github.moulberry.notenoughupdates.options.NEUConfig; import io.github.moulberry.notenoughupdates.options.NEUConfigEditor; import io.github.moulberry.notenoughupdates.overlays.FuelBar; @@ -35,6 +32,7 @@ import io.github.moulberry.notenoughupdates.util.Utils; import io.github.moulberry.notenoughupdates.util.XPInformation; import net.minecraft.block.material.MapColor; import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.gui.inventory.GuiInventory; @@ -123,6 +121,32 @@ public class NotEnoughUpdates { } }); + SimpleCommand nullzeeSphereCommand = new SimpleCommand("neuzeesphere", new SimpleCommand.ProcessCommandRunnable() { + public void processCommand(ICommandSender sender, String[] args) { + if(args.length != 1) { + sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+"Usage: /neuzeesphere [on/off] or /neuzeesphere (radius) or /neuzeesphere setCenter")); + return; + } + if(args[0].equalsIgnoreCase("on")) { + NullzeeSphere.enabled = true; + } else if(args[0].equalsIgnoreCase("off")) { + NullzeeSphere.enabled = false; + } else if(args[0].equalsIgnoreCase("setCenter")) { + EntityPlayerSP p = ((EntityPlayerSP)sender); + NullzeeSphere.centerPos = new BlockPos(p.posX, p.posY, p.posZ); + NullzeeSphere.overlayVBO = null; + } else { + try { + float radius = Float.parseFloat(args[0]); + NullzeeSphere.size = radius; + NullzeeSphere.overlayVBO = null; + } catch(Exception e) { + sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+"Can't parse radius: " + args[0])); + } + } + } + }); + SimpleCommand itemRenameCommand = new SimpleCommand("neurename", new SimpleCommand.ProcessCommandRunnable() { public void processCommand(ICommandSender sender, String[] args) { if(args.length == 0) { @@ -215,6 +239,12 @@ public class NotEnoughUpdates { } }); + SimpleCommand buttonsCommand = new SimpleCommand("neubuttons", new SimpleCommand.ProcessCommandRunnable() { + public void processCommand(ICommandSender sender, String[] args) { + openGui = new GuiInvButtonEditor(); + } + }); + SimpleCommand enchantColourCommand = new SimpleCommand("neuec", new SimpleCommand.ProcessCommandRunnable() { public void processCommand(ICommandSender sender, String[] args) { openGui = new GuiEnchantColour(); @@ -250,6 +280,13 @@ public class NotEnoughUpdates { } } Constants.reload(); + + configFile = new File(neuDir, "configNew.json"); + if(configFile.exists()) { + try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8))) { + config = gson.fromJson(reader, NEUConfig.class); + } catch(Exception e) { } + } } }); @@ -690,7 +727,14 @@ public class NotEnoughUpdates { Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+devFailStrings[devFailIndex++])); return; } - if(args.length == 1 && args[0].equalsIgnoreCase("dev")) NotEnoughUpdates.INSTANCE.config.hidden.dev = true; + if(args.length == 1 && args[0].equalsIgnoreCase("dev")) { + NotEnoughUpdates.INSTANCE.config.hidden.dev = true; + return; + } + if(args.length == 1 && args[0].equalsIgnoreCase("saveconfig")) { + saveConfig(); + return; + } Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN+"Executing dubious code")); /*Minecraft.getMinecraft().thePlayer.rotationYaw = 0; Minecraft.getMinecraft().thePlayer.rotationPitch = 0; @@ -991,15 +1035,18 @@ public class NotEnoughUpdates { MinecraftForge.EVENT_BUS.register(XPInformation.getInstance()); MinecraftForge.EVENT_BUS.register(OverlayManager.petInfoOverlay); MinecraftForge.EVENT_BUS.register(OverlayManager.timersOverlay); + MinecraftForge.EVENT_BUS.register(new NullzeeSphere()); if(Minecraft.getMinecraft().getResourceManager() instanceof IReloadableResourceManager) { ((IReloadableResourceManager)Minecraft.getMinecraft().getResourceManager()).registerReloadListener(CustomSkulls.getInstance()); } ClientCommandHandler.instance.registerCommand(collectionLogCommand); + ClientCommandHandler.instance.registerCommand(nullzeeSphereCommand); ClientCommandHandler.instance.registerCommand(cosmeticsCommand); ClientCommandHandler.instance.registerCommand(linksCommand); ClientCommandHandler.instance.registerCommand(gamemodesCommand); + ClientCommandHandler.instance.registerCommand(buttonsCommand); ClientCommandHandler.instance.registerCommand(resetRepoCommand); ClientCommandHandler.instance.registerCommand(reloadRepoCommand); ClientCommandHandler.instance.registerCommand(itemRenameCommand); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementTextField.java b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementTextField.java index b2f947d6..111803e8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementTextField.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementTextField.java @@ -2,6 +2,7 @@ package io.github.moulberry.notenoughupdates.core; import io.github.moulberry.notenoughupdates.core.util.StringUtils; import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils; +import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiScreen; @@ -462,14 +463,21 @@ public class GuiElementTextField { String selectedText = textField.getSelectedText(); if(!selectedText.isEmpty()) { + System.out.println("Start"); int leftIndex = Math.min(textField.getCursorPosition()+prependText.length(), textField.getSelectionEnd()+prependText.length()); int rightIndex = Math.max(textField.getCursorPosition()+prependText.length(), textField.getSelectionEnd()+prependText.length()); float texX = 0; int texY = 0; boolean sectionSignPrev = false; + boolean ignoreNext = false; boolean bold = false; for(int i=0; i= leftIndex && i < rightIndex) { @@ -497,6 +509,7 @@ public class GuiElementTextField { //String c2 = bold ? EnumChatFormatting.BOLD.toString() : "" + c; + System.out.println("Adding len for char:"+c+":"+Integer.toHexString(c)); int len = Minecraft.getMinecraft().fontRendererObj.getStringWidth(String.valueOf(c)); if(bold) len++; if(i >= leftIndex && i < rightIndex) { 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 963b91c3..21f6baaf 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java @@ -48,8 +48,11 @@ public class CapeManager { public JsonObject lastJsonSync = null; private String[] capes = new String[]{"patreon1", "patreon2", "fade", "contrib", "nullzee", - "gravy", "space", "mcworld", "lava", "packshq", "mbstaff", "thebakery", "negative", "void", "ironmoon", "krusty", "furf", "soldier", "dsm" }; - public Boolean[] specialCapes = new Boolean[]{ true, true, false, true, true, true, false, false, false, true, true, true, false, false, true, false, true, true, true }; + "gravy", "space", "mcworld", "lava", "packshq", "mbstaff", "thebakery", "negative", + "void", "ironmoon", "krusty", "furf", "soldier", "dsm", "zera", "tunnel", "alexxoffi", "parallax", "jakethybro", "planets" }; + public Boolean[] specialCapes = new Boolean[]{ true, true, false, true, true, + true, false, false, false, true, true, true, false, + false, true, false, true, true, true, true, false, true, true, true, false }; public static CapeManager getInstance() { return INSTANCE; 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 b01365d3..06bc6db4 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeNode.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeNode.java @@ -31,6 +31,10 @@ public class CapeNode { public Vector3f sideNormal = null; public boolean fixed = false; + public static final int DRAW_MASK_FRONT = 0b1; + public static final int DRAW_MASK_BACK = 0b10; + public static final int DRAW_MASK_SIDES = 0b100; + public HashMap neighbors = new HashMap<>(); public float texU = 0; @@ -279,6 +283,10 @@ public class CapeNode { } public void renderNode() { + renderNode(DRAW_MASK_FRONT | DRAW_MASK_BACK | DRAW_MASK_SIDES); + } + + public void renderNode(int mask) { CapeNode nodeLeft = getNeighbor(new NEUCape.Offset(NEUCape.Direction.LEFT, 1)); CapeNode nodeUp = getNeighbor(new NEUCape.Offset(NEUCape.Direction.UP, 1)); CapeNode nodeDown = getNeighbor(new NEUCape.Offset(NEUCape.Direction.DOWN, 1)); @@ -290,36 +298,42 @@ public class CapeNode { if(nodeDown != null && nodeRight != null && nodeDownRight != null) { //Back - worldrenderer.begin(GL11.GL_TRIANGLE_STRIP, DefaultVertexFormats.POSITION_TEX_NORMAL); - for(CapeNode node : new CapeNode[]{this, nodeDown, nodeRight, nodeDownRight}) { - Vector3f nodeNorm = node.normal(); - worldrenderer.pos(node.renderPosition.x, node.renderPosition.y, node.renderPosition.z) - .tex(1-node.texU, node.texV) - .normal(-nodeNorm.x, -nodeNorm.y, -nodeNorm.z).endVertex(); + if((mask & DRAW_MASK_BACK) != 0) { + worldrenderer.begin(GL11.GL_TRIANGLE_STRIP, DefaultVertexFormats.POSITION_TEX_NORMAL); + for(CapeNode node : new CapeNode[]{this, nodeDown, nodeRight, nodeDownRight}) { + Vector3f nodeNorm = node.normal(); + worldrenderer.pos(node.renderPosition.x, node.renderPosition.y, node.renderPosition.z) + .tex(1-node.texU, node.texV) + .normal(-nodeNorm.x, -nodeNorm.y, -nodeNorm.z).endVertex(); + } + tessellator.draw(); } - tessellator.draw(); //Front (Offset by normal) - worldrenderer.begin(GL11.GL_TRIANGLE_STRIP, DefaultVertexFormats.POSITION_TEX_NORMAL); - for(CapeNode node : new CapeNode[]{this, nodeDown, nodeRight, nodeDownRight}) { - Vector3f nodeNorm = node.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(); + if((mask & DRAW_MASK_FRONT) != 0) { + worldrenderer.begin(GL11.GL_TRIANGLE_STRIP, DefaultVertexFormats.POSITION_TEX_NORMAL); + for(CapeNode node : new CapeNode[]{nodeDownRight, nodeDown, nodeRight, this}) { + Vector3f nodeNorm = node.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(); + } + tessellator.draw(); } - tessellator.draw(); } - if(nodeLeft == null || nodeRight == null) { - //Render left/right edge - if(nodeDown != null) { - renderEdge(nodeDown, true); + if((mask & DRAW_MASK_SIDES) != 0) { + if(nodeLeft == null || nodeRight == null) { + //Render left/right edge + if(nodeDown != null) { + renderEdge(nodeDown, true); + } } - } - if(nodeUp == null || nodeDown == null) { - //Render up/down edge - if(nodeRight != null) { - renderEdge(nodeRight, false); + if(nodeUp == null || nodeDown == null) { + //Render up/down edge + if(nodeRight != null) { + renderEdge(nodeRight, false); + } } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java index d0651075..164dfeb8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java @@ -269,7 +269,7 @@ public class GuiCosmetics extends GuiScreen { if(mouseY > guiTop+sizeY+5 && mouseY < guiTop+sizeY+25) { if(System.currentTimeMillis() - lastCapeEquip > 20*1000) { CapeManager.INSTANCE.setCape(Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""), - null, true); + wantToEquipCape, true); lastCapeEquip = System.currentTimeMillis(); 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 b2d220c8..163b14dd 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java @@ -1,7 +1,9 @@ package io.github.moulberry.notenoughupdates.cosmetics; import io.github.moulberry.notenoughupdates.core.util.lerp.LerpUtils; +import io.github.moulberry.notenoughupdates.util.ReverseWorldRenderer; import io.github.moulberry.notenoughupdates.util.TexLoc; +import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; @@ -9,6 +11,8 @@ import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.client.renderer.vertex.VertexFormat; +import net.minecraft.client.renderer.vertex.VertexFormatElement; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -16,6 +20,7 @@ import net.minecraft.potion.Potion; import net.minecraft.util.BlockPos; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Vec3; import net.minecraft.world.gen.NoiseGeneratorSimplex; import net.minecraftforge.client.event.RenderPlayerEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @@ -27,6 +32,7 @@ import org.lwjgl.opengl.*; import org.lwjgl.util.vector.Vector2f; import org.lwjgl.util.vector.Vector3f; +import java.nio.ByteBuffer; import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.security.Key; @@ -45,7 +51,7 @@ public class NEUCape { private static int ANIM_MODE_PINGPONG = 1; private int animMode = ANIM_MODE_LOOP; - private List> nodes = null; + private CapeNode[] nodes = null; private Random random = new Random(); @@ -60,7 +66,7 @@ public class NEUCape { public static final int HORZ_NODES = 6; public static final int VERT_NODES = 22; - public static float targetDist = 1/20f; + public static float targetDist = 1 / 20f; private EntityPlayer currentPlayer; private boolean keepCurrentPlayer = false; @@ -93,11 +99,15 @@ public class NEUCape { shaderName = "negative"; } else if(capeName.equalsIgnoreCase("void")) { shaderName = "void"; + } else if(capeName.equalsIgnoreCase("tunnel")) { + shaderName = "tunnel"; + } else if(capeName.equalsIgnoreCase("planets")) { + shaderName = "planets"; } else { shaderName = "shiny_cape"; } - ResourceLocation staticCapeTex = new ResourceLocation("notenoughupdates:capes/"+capeName+".png"); + ResourceLocation staticCapeTex = new ResourceLocation(