From f0293a74282cece3aa8a2a328559889d6e187209 Mon Sep 17 00:00:00 2001 From: Moulberry Date: Sun, 26 Jul 2020 12:12:25 +1000 Subject: 1.11.7 --- .../moulberry/notenoughupdates/CustomItems.java | 8 + .../notenoughupdates/GuiEnchantColour.java | 222 ++++ .../moulberry/notenoughupdates/ItemRarityHalo.java | 251 ++++ .../moulberry/notenoughupdates/NEUManager.java | 19 +- .../moulberry/notenoughupdates/NEUOverlay.java | 13 +- .../notenoughupdates/NotEnoughUpdates.java | 166 ++- .../notenoughupdates/auction/APIManager.java | 20 +- .../notenoughupdates/auction/CustomAH.java | 20 +- .../infopanes/CollectionLogInfoPane.java | 17 +- .../itemeditor/GuiElementTextField.java | 49 +- .../mixins/MixinInventoryEffectRenderer.java | 1 + .../notenoughupdates/mixins/MixinRenderItem.java | 53 + .../notenoughupdates/options/Options.java | 29 +- .../profileviewer/GuiProfileViewer.java | 1253 ++++++++++++++++++-- .../notenoughupdates/profileviewer/Panorama.java | 4 - .../profileviewer/PlayerStats.java | 37 +- .../profileviewer/ProfileViewer.java | 472 +++++++- .../questing/SBScoreboardData.java | 6 +- .../notenoughupdates/util/HypixelApi.java | 1 - .../moulberry/notenoughupdates/util/Utils.java | 127 +- 20 files changed, 2446 insertions(+), 322 deletions(-) create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/GuiEnchantColour.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/ItemRarityHalo.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderItem.java (limited to 'src/main/java/io') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/CustomItems.java b/src/main/java/io/github/moulberry/notenoughupdates/CustomItems.java index 4328eaf4..58eaab72 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/CustomItems.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/CustomItems.java @@ -48,6 +48,14 @@ public class CustomItems { "incursions on the server, some of which I, a player on this Minecraft", "anarchy server in Minecraft, have participated in. One of this server's", "most infamous Minecraft players on the oldest Minecraft"); + public static JsonObject LEOCTHL = create("LEOCTHL", "dragon_egg", "--- Stats below may not be entirely accurate ---", + "17 legendary dragon pets", + "24 epic dragon pets", + "18 epic golem pets", + "12 legendary golem pets", + "39 legendary phoenix pets", + "", + "get flexed"); /** * SHAAAAAAAAAAAAAAAAAAME diff --git a/src/main/java/io/github/moulberry/notenoughupdates/GuiEnchantColour.java b/src/main/java/io/github/moulberry/notenoughupdates/GuiEnchantColour.java new file mode 100644 index 00000000..98b08fd8 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/GuiEnchantColour.java @@ -0,0 +1,222 @@ +package io.github.moulberry.notenoughupdates; + +import com.google.common.base.Splitter; +import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class GuiEnchantColour extends GuiScreen { + + public static final ResourceLocation custom_ench_colour = new ResourceLocation("notenoughupdates:custom_ench_colour.png"); + + private int guiLeft; + private int guiTop; + private final int xSize = 176; + private int ySize = 0; + + private List getEnchantColours() { + return NotEnoughUpdates.INSTANCE.manager.config.enchantColours.value; + } + + public static final Splitter splitter = Splitter.on(":").limit(4); + + private HashMap comparators = new HashMap<>(); + private List guiElementTextFields = new ArrayList<>(); + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + List enchantColours = getEnchantColours(); + + ySize = 53+25*enchantColours.size(); + guiLeft = (width-xSize)/2; + guiTop = (height-ySize)/2; + + NotEnoughUpdates.INSTANCE.manager.loadConfig(); + + Minecraft.getMinecraft().getTextureManager().bindTexture(custom_ench_colour); + Utils.drawTexturedRect(guiLeft, guiTop, xSize, 21, 0, 1, 0, 21/78f, GL11.GL_NEAREST); + Utils.drawTexturedRect(guiLeft, guiTop+ySize-32, xSize, 32, 0, 1, 46/78f, 1, GL11.GL_NEAREST); + + fontRendererObj.drawString("Ench Name", guiLeft+10, guiTop+7, 4210752); + fontRendererObj.drawString("CMP", guiLeft+71, guiTop+7, 4210752); + fontRendererObj.drawString("LVL", guiLeft+96, guiTop+7, 4210752); + fontRendererObj.drawString("COL", guiLeft+121, guiTop+7, 4210752); + fontRendererObj.drawString("DEL", guiLeft+146, guiTop+7, 4210752); + + Utils.drawStringCentered("Add Ench Colour", fontRendererObj, guiLeft+xSize/2, guiTop+ySize-20, false, 4210752); + + int yIndex = 0; + for(String str : enchantColours) { + Minecraft.getMinecraft().getTextureManager().bindTexture(custom_ench_colour); + GlStateManager.color(1, 1, 1, 1); + Utils.drawTexturedRect(guiLeft, guiTop+21+yIndex*25, xSize, 25, 0, 1, 21/78f, 46/78f, GL11.GL_NEAREST); + + List colourOps = splitter.splitToList(str); + String enchantName = getColourOpIndex(colourOps, 0); + String comparator = getColourOpIndex(colourOps, 1); + String comparison = getColourOpIndex(colourOps, 2); + String colourCode = getColourOpIndex(colourOps, 3); + + if(colourCode.length() > 1) colourCode = String.valueOf(colourCode.toLowerCase().charAt(0)); + if(comparator.length() > 1) comparator = String.valueOf(comparator.toLowerCase().charAt(0)); + + Utils.drawStringCentered(comparator, fontRendererObj, guiLeft+81, guiTop+33+25*yIndex, false, 4210752); + + if(guiElementTextFields.size() <= yIndex) { + guiElementTextFields.add(new GuiElementTextField[3]); + } + if(guiElementTextFields.get(yIndex)[0] == null) { + guiElementTextFields.get(yIndex)[0] = new GuiElementTextField(enchantName, GuiElementTextField.SCALE_TEXT); + guiElementTextFields.get(yIndex)[0].setSize(56, 20); + } + if(guiElementTextFields.get(yIndex)[1] == null) { + guiElementTextFields.get(yIndex)[1] = new GuiElementTextField(comparison, + GuiElementTextField.SCALE_TEXT|GuiElementTextField.NUM_ONLY|GuiElementTextField.NO_SPACE); + guiElementTextFields.get(yIndex)[1].setSize(20, 20); + } + if(guiElementTextFields.get(yIndex)[2] == null) { + guiElementTextFields.get(yIndex)[2] = new GuiElementTextField(colourCode, GuiElementTextField.SCALE_TEXT); + guiElementTextFields.get(yIndex)[2].setSize(20, 20); + } + guiElementTextFields.get(yIndex)[0].setText(enchantName); + guiElementTextFields.get(yIndex)[1].setText(comparison); + comparators.put(yIndex, comparator); + guiElementTextFields.get(yIndex)[2].setText(colourCode); + + guiElementTextFields.get(yIndex)[0].render(guiLeft+10, guiTop+23+25*yIndex); + guiElementTextFields.get(yIndex)[1].render(guiLeft+96, guiTop+23+25*yIndex); + guiElementTextFields.get(yIndex)[2].render(guiLeft+121, guiTop+23+25*yIndex); + + yIndex++; + } + } + + @Override + protected void keyTyped(char typedChar, int keyCode) throws IOException { + super.keyTyped(typedChar, keyCode); + for(int yIndex=0; yIndex NotEnoughUpdates.INSTANCE.manager.config.enchantColours.value.size()) { + addOffset = NotEnoughUpdates.INSTANCE.manager.config.enchantColours.value.size()-yIndex; + } + System.out.println(addOffset); + NotEnoughUpdates.INSTANCE.manager.config.enchantColours.value.add(yIndex+addOffset, + getEnchantOpString(guiElementTextFields.get(yIndex), comparators.get(yIndex))); + NotEnoughUpdates.INSTANCE.manager.saveConfig(); + if(addOffset != 0) { + GuiElementTextField[] guiElementTextFieldArray = guiElementTextFields.remove(yIndex); + guiElementTextFields.add(yIndex+addOffset, guiElementTextFieldArray); + } + return; + } + } + } + } + + public String getEnchantOpString(GuiElementTextField[] tfs, String comparator) { + StringBuilder enchantOp = new StringBuilder(); + enchantOp.append(tfs[0].getText()); + enchantOp.append(":"); + enchantOp.append(comparator); + enchantOp.append(":"); + enchantOp.append(tfs[1].getText()); + enchantOp.append(":"); + enchantOp.append(tfs[2].getText()); + return enchantOp.toString(); + } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { + super.mouseClicked(mouseX, mouseY, mouseButton); + for(int yIndex=0; yIndex x && mouseX < x+guiElementTextFields.get(yIndex)[i].getWidth()) { + if(mouseY > guiTop+23+25*yIndex && mouseY < guiTop+23+25*yIndex+20) { + guiElementTextFields.get(yIndex)[i].mouseClicked(mouseX, mouseY, mouseButton); + if(mouseButton == 1) { + NotEnoughUpdates.INSTANCE.manager.config.enchantColours.value.remove(yIndex); + NotEnoughUpdates.INSTANCE.manager.config.enchantColours.value.add(yIndex, + getEnchantOpString(guiElementTextFields.get(yIndex), comparators.get(yIndex))); + NotEnoughUpdates.INSTANCE.manager.saveConfig(); + } + continue; + } + } + guiElementTextFields.get(yIndex)[i].otherComponentClick(); + } + comparators.computeIfAbsent(yIndex, k->">"); + if(mouseY > guiTop+23+25*yIndex && mouseY < guiTop+23+25*yIndex+20) { + if(mouseX > guiLeft+71 && mouseX < guiLeft+71+20) { + switch (comparators.get(yIndex)) { + case ">": + comparators.put(yIndex, "="); break; + case "=": + comparators.put(yIndex, "<"); break; + default: + comparators.put(yIndex, ">"); break; + } + NotEnoughUpdates.INSTANCE.manager.config.enchantColours.value.remove(yIndex); + NotEnoughUpdates.INSTANCE.manager.config.enchantColours.value.add(yIndex, + getEnchantOpString(guiElementTextFields.get(yIndex), comparators.get(yIndex))); + NotEnoughUpdates.INSTANCE.manager.saveConfig(); + } else if(mouseX > guiLeft+146 && mouseX < guiLeft+146+20) { + NotEnoughUpdates.INSTANCE.manager.config.enchantColours.value.remove(yIndex); + guiElementTextFields.remove(yIndex); + comparators.remove(yIndex); + NotEnoughUpdates.INSTANCE.manager.saveConfig(); + } + } + } + if(mouseX >= guiLeft+42 && mouseX <= guiLeft+42+88) { + if(mouseY >= guiTop+ySize-30 && mouseY <= guiTop+ySize-10) { + NotEnoughUpdates.INSTANCE.manager.config.enchantColours.value.add("[a-zA-Z ]+:>:5:9"); + NotEnoughUpdates.INSTANCE.manager.saveConfig(); + } + } + } + + public static String getColourOpIndex(List colourOps, int index) { + if(colourOps.size() > index) { + return colourOps.get(index); + } else { + switch(index) { + case 0: + return "[a-zA-Z ]+"; + case 1: + return ">"; + case 2: + return "5"; + case 3: + return "9"; + } + } + return null; + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/ItemRarityHalo.java b/src/main/java/io/github/moulberry/notenoughupdates/ItemRarityHalo.java new file mode 100644 index 00000000..2c70ec1e --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/ItemRarityHalo.java @@ -0,0 +1,251 @@ +package io.github.moulberry.notenoughupdates; + +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.*; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.texture.TextureUtil; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.client.shader.Framebuffer; +import net.minecraft.client.shader.Shader; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Matrix4f; +import org.lwjgl.BufferUtils; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; +import org.lwjgl.opengl.GL30; +import org.lwjgl.opengl.GL45; + +import java.awt.*; +import java.nio.ByteBuffer; +import java.nio.IntBuffer; +import java.util.HashMap; + +public class ItemRarityHalo { + + public static Framebuffer itemFramebuffer1 = null; + public static Framebuffer itemFramebuffer2 = null; + public static HashMap itemHaloTexMap = new HashMap<>(); + public static Matrix4f projectionMatrix = null; + + public static Shader colourShader = null; + public static Shader blurShaderHorz = null; + public static Shader blurShaderVert = null; + + private static int oldScaledResolution = 0; + + public static void onItemRender(ItemStack stack, int x, int y) { + if(x == 0 && y == 0) return; + + if(!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return; + NotEnoughUpdates neu = NotEnoughUpdates.INSTANCE; + if(!neu.isOnSkyblock()) return; + if(neu.manager.config.itemHighlightOpacity.value <= 1) return; + if(neu.manager.getInternalNameForItem(stack) == null) return; + + ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft()); + int size = 16*scaledresolution.getScaleFactor(); + + if(projectionMatrix == null) { + projectionMatrix = Utils.createProjectionMatrix(size, size); + } + + itemFramebuffer1 = checkFramebufferSizes(itemFramebuffer1, size, size); + itemFramebuffer2 = checkFramebufferSizes(itemFramebuffer2, size, size); + + try { + if(colourShader == null) { + colourShader = new Shader(new NEUResourceManager(Minecraft.getMinecraft().getResourceManager()), + "setrgbtoalpha", itemFramebuffer1, itemFramebuffer2); + upload(colourShader, size, size); + } + + if(blurShaderHorz == null) { + blurShaderHorz = new Shader(new NEUResourceManager(Minecraft.getMinecraft().getResourceManager()), + "blur", itemFramebuffer2, itemFramebuffer1); + blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0); + blurShaderHorz.getShaderManager().getShaderUniform("Radius").set(5f); + blurShaderHorz.getShaderManager().getShaderUniform("AlphaMult").set(2f); + upload(blurShaderHorz, size, size); + } + + if(blurShaderVert == null) { + blurShaderVert = new Shader(new NEUResourceManager(Minecraft.getMinecraft().getResourceManager()), + "blur", itemFramebuffer1, itemFramebuffer2); + blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1); + blurShaderVert.getShaderManager().getShaderUniform("Radius").set(5f); + blurShaderVert.getShaderManager().getShaderUniform("AlphaMult").set(2f); + upload(blurShaderVert, size, size); + } + } catch(Exception e) { return; } + + if(oldScaledResolution != scaledresolution.getScaleFactor()) { + resetItemHaloCache(); + oldScaledResolution = scaledresolution.getScaleFactor(); + } + + int currentBuffer = GL11.glGetInteger(GL30.GL_FRAMEBUFFER_BINDING); + IntBuffer currentViewport = BufferUtils.createIntBuffer(16); + GL11.glGetInteger(GL11.GL_VIEWPORT, currentViewport); + try { + if(!itemHaloTexMap.containsKey(stack)) { + int texture1 = TextureUtil.glGenTextures(); + int texture2 = TextureUtil.glGenTextures(); + + GlStateManager.bindTexture(texture1); + GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, size, size, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, ((ByteBuffer)null)); + itemFramebuffer1.bindFramebuffer(false); + OpenGlHelper.glFramebufferTexture2D(OpenGlHelper.GL_FRAMEBUFFER, OpenGlHelper.GL_COLOR_ATTACHMENT0, 3553, texture1, 0); + + GlStateManager.bindTexture(texture2); + GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, size, size, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, ((ByteBuffer)null)); + itemFramebuffer2.bindFramebuffer(false); + OpenGlHelper.glFramebufferTexture2D(OpenGlHelper.GL_FRAMEBUFFER, OpenGlHelper.GL_COLOR_ATTACHMENT0, 3553, texture2, 0); + + itemFramebuffer1.framebufferClear(); + itemFramebuffer2.framebufferClear(); + + GlStateManager.pushMatrix(); { + GlStateManager.matrixMode(5889); + GlStateManager.loadIdentity(); + GlStateManager.ortho(0.0D, size, size, 0.0D, 1000.0D, 3000.0D); + GlStateManager.matrixMode(5888); + GlStateManager.loadIdentity(); + GlStateManager.translate(0.0F, 0.0F, -2000.0F); + + GL11.glScalef(scaledresolution.getScaleFactor(), scaledresolution.getScaleFactor(), 1); + + itemFramebuffer1.bindFramebuffer(true); + + RenderItem itemRender = Minecraft.getMinecraft().getRenderItem(); + RenderHelper.enableGUIStandardItemLighting(); + float zLevel = itemRender.zLevel; + itemRender.zLevel = -145; //Negates the z-offset of the below method. + itemRender.renderItemAndEffectIntoGUI(stack, 0, 0); + itemRender.zLevel = zLevel; + RenderHelper.disableStandardItemLighting(); + } GlStateManager.popMatrix(); + + GlStateManager.pushMatrix(); { + GL45.glTextureBarrier(); GL11.glFlush(); GL11.glFinish(); + executeShader(colourShader); + //GL45.glTextureBarrier(); GL11.glFlush(); GL11.glFinish(); + //executeShader(blurShaderHorz); + //GL45.glTextureBarrier(); GL11.glFlush(); GL11.glFinish(); + //executeShader(blurShaderVert); + //GL45.glTextureBarrier(); GL11.glFlush(); GL11.glFinish(); + } GlStateManager.popMatrix(); + + GlStateManager.matrixMode(5889); + GlStateManager.loadIdentity(); + GlStateManager.ortho(0.0D, scaledresolution.getScaledWidth_double(), scaledresolution.getScaledHeight_double(), 0.0D, 1000.0D, 3000.0D); + GlStateManager.matrixMode(5888); + + OpenGlHelper.glBindFramebuffer(OpenGlHelper.GL_FRAMEBUFFER, currentBuffer); + GlStateManager.viewport(currentViewport.get(), currentViewport.get(), currentViewport.get(), currentViewport.get()); + + //TextureUtil.deleteTexture(texture1); + itemHaloTexMap.put(stack, texture2); + } + + OpenGlHelper.glBindFramebuffer(OpenGlHelper.GL_FRAMEBUFFER, currentBuffer); + GlStateManager.viewport(currentViewport.get(), currentViewport.get(), currentViewport.get(), currentViewport.get()); + + GlStateManager.bindTexture(itemHaloTexMap.get(stack)); + Color color = Utils.getPrimaryColour(stack.getDisplayName()); + GlStateManager.color(color.getRed()/255f, color.getGreen()/255f, color.getBlue()/255f, + NotEnoughUpdates.INSTANCE.manager.config.itemHighlightOpacity.value.floatValue()/255f); + Utils.drawTexturedRect(x, y, 16, 16, + 0, 1, 1, 0, GL11.GL_NEAREST); + GlStateManager.bindTexture(0); + } catch(Exception e) { + e.printStackTrace(); + OpenGlHelper.glBindFramebuffer(OpenGlHelper.GL_FRAMEBUFFER, currentBuffer); + GlStateManager.viewport(currentViewport.get(), currentViewport.get(), currentViewport.get(), currentViewport.get()); + } + } + + 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 static void resetItemHaloCache() { + ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft()); + int size = 16*scaledresolution.getScaleFactor(); + + for(int tex : itemHaloTexMap.values()) { + TextureUtil.deleteTexture(tex); + } + itemHaloTexMap.clear(); + + if(NotEnoughUpdates.INSTANCE.isOnSkyblock()) { + projectionMatrix = Utils.createProjectionMatrix(size, size); + upload(colourShader, size, size); + upload(blurShaderHorz, size, size); + upload(blurShaderVert, size, size); + } + } + + private static void upload(Shader shader, int width, int height) { + if(shader == null) return; + shader.getShaderManager().getShaderUniformOrDefault("ProjMat").set(projectionMatrix); + shader.getShaderManager().getShaderUniformOrDefault("InSize").set(width, height); + shader.getShaderManager().getShaderUniformOrDefault("OutSize").set(width, height); + shader.getShaderManager().getShaderUniformOrDefault("ScreenSize").set((float)width, (float)height); + } + + private static void executeShader(Shader shader) { + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.disableBlend(); + GlStateManager.disableDepth(); + GlStateManager.disableAlpha(); + GlStateManager.disableFog(); + GlStateManager.disableLighting(); + GlStateManager.disableColorMaterial(); + GlStateManager.enableTexture2D(); + GlStateManager.bindTexture(0); + + float f = (float)shader.framebufferOut.framebufferTextureWidth; + float f1 = (float)shader.framebufferOut.framebufferTextureHeight; + GlStateManager.viewport(0, 0, (int)f, (int)f1); + + shader.getShaderManager().useShader(); + shader.getShaderManager().addSamplerTexture("DiffuseSampler", shader.framebufferIn); + + shader.framebufferOut.framebufferClear(); + shader.framebufferOut.bindFramebuffer(false); + + GlStateManager.depthMask(false); + + GlStateManager.enableAlpha(); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR); + worldrenderer.pos(0.0D, (double)f1, 500.0D).color(255, 255, 255, 255).endVertex(); + worldrenderer.pos((double)f, (double)f1, 500.0D).color(255, 255, 255, 255).endVertex(); + worldrenderer.pos((double)f, 0.0D, 500.0D).color(255, 255, 255, 255).endVertex(); + worldrenderer.pos(0.0D, 0.0D, 500.0D).color(255, 255, 255, 255).endVertex(); + tessellator.draw(); + + GlStateManager.depthMask(true); + + shader.getShaderManager().endShader(); + + shader.framebufferOut.unbindFramebuffer(); + shader.framebufferIn.unbindFramebufferTexture(); + } + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java index b879c383..680094af 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java @@ -23,6 +23,8 @@ import java.io.*; import java.net.URL; import java.nio.charset.StandardCharsets; import java.util.*; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import java.util.zip.GZIPInputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -226,24 +228,29 @@ public class NEUManager { /** * Downloads and sets auctionPricesJson from the URL specified by AUCTIONS_PRICE_URL. */ + private ExecutorService es = Executors.newCachedThreadPool(); public void updatePrices() { if(System.currentTimeMillis() - auctionLastUpdate > 1000*60*120) { //2 hours craftCost.clear(); System.out.println("[NEU] UPDATING PRICE INFORMATION"); auctionLastUpdate = System.currentTimeMillis(); - try(Reader inReader = new InputStreamReader(new GZIPInputStream(new URL(AUCTIONS_PRICE_URL).openStream()))) { - auctionPricesJson = gson.fromJson(inReader, JsonObject.class); - } catch (IOException e) { - e.printStackTrace(); - } + es.submit(() -> { + try(Reader inReader = new InputStreamReader(new GZIPInputStream(new URL(AUCTIONS_PRICE_URL).openStream()))) { + auctionPricesJson = gson.fromJson(inReader, JsonObject.class); + } catch (IOException e) { + e.printStackTrace(); + } + }); } } public boolean hasAuctionInfo(String internalname) { + if(auctionPricesJson == null) return false; return auctionPricesJson.has("item_data") && auctionPricesJson.get("item_data").getAsJsonObject().has(internalname); } public boolean hasBazaarInfo(String internalname) { + if(auctionPricesJson == null) return false; return auctionPricesJson.has("bazaar") && auctionPricesJson.get("bazaar").getAsJsonObject().has(internalname); } @@ -276,7 +283,7 @@ public class NEUManager { if(info == null || !info.has("price")) { return 0; } - if(!auctionPricesJson.has("ench_prices") || !auctionPricesJson.has("ench_maximums")) { + if(auctionPricesJson == null || !auctionPricesJson.has("ench_prices") || !auctionPricesJson.has("ench_maximums")) { return 0; } JsonObject ench_prices = auctionPricesJson.getAsJsonObject("ench_prices"); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index 25b27cc5..7db8875d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -1053,7 +1053,7 @@ public class NEUOverlay extends Gui { } else if(getSortMode() == SORT_MODE_MOB) { return internalname.matches(mobRegex); } else if(getSortMode() == SORT_MODE_PET) { - return internalname.matches(petRegex); + return internalname.matches(petRegex) && item.get("displayname").getAsString().contains("["); } else if(getSortMode() == SORT_MODE_TOOL) { return checkItemType(item.get("lore").getAsJsonArray(), "SWORD", "BOW", "AXE", "PICKAXE", "FISHING ROD", "WAND", "SHOVEL", "HOE") >= 0; @@ -1099,6 +1099,9 @@ public class NEUOverlay extends Gui { case "thirtyvirus": searchedItems.add(manager.getItemInformation().get("SPIKED_BAIT")); break; + case "leocthl": + searchedItems.add(CustomItems.LEOCTHL); + break; } } @@ -1482,16 +1485,16 @@ public class NEUOverlay extends Gui { if(blurShaderHorz == null) { try { - blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur", - Minecraft.getMinecraft().getFramebuffer(), blurOutputHorz); + blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), + "blur", Minecraft.getMinecraft().getFramebuffer(), blurOutputHorz); blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0); blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height)); } catch(Exception e) { } } if(blurShaderVert == null) { try { - blurShaderVert = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur", - blurOutputHorz, blurOutputVert); + blurShaderVert = new Shader(Minecraft.getMinecraft().getResourceManager(), + "blur", blurOutputHorz, blurOutputVert); blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1); blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height)); } catch(Exception e) { } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index 734f7ca1..efd38c55 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -11,6 +11,7 @@ import io.github.moulberry.notenoughupdates.commands.SimpleCommand; import io.github.moulberry.notenoughupdates.cosmetics.CapeManager; import io.github.moulberry.notenoughupdates.infopanes.CollectionLogInfoPane; import io.github.moulberry.notenoughupdates.infopanes.CosmeticsInfoPane; +import io.github.moulberry.notenoughupdates.mixins.MixinRenderItem; import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer; import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer; import io.github.moulberry.notenoughupdates.questing.GuiQuestLine; @@ -24,6 +25,8 @@ import net.minecraft.client.gui.inventory.*; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.settings.KeyBinding; +import net.minecraft.client.shader.Framebuffer; +import net.minecraft.client.shader.Shader; import net.minecraft.command.ICommandSender; import net.minecraft.event.ClickEvent; import net.minecraft.init.Blocks; @@ -37,6 +40,7 @@ import net.minecraft.scoreboard.ScoreObjective; import net.minecraft.scoreboard.Scoreboard; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.Matrix4f; import net.minecraft.util.Session; import net.minecraftforge.client.ClientCommandHandler; import net.minecraftforge.client.event.*; @@ -61,10 +65,13 @@ import java.lang.reflect.Modifier; import java.net.Proxy; import java.text.NumberFormat; import java.util.*; +import java.util.List; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import static io.github.moulberry.notenoughupdates.GuiTextures.*; @@ -127,10 +134,20 @@ public class NotEnoughUpdates { } }); + SimpleCommand enchantColourCommand = new SimpleCommand("neuec", new SimpleCommand.ProcessCommandRunnable() { + public void processCommand(ICommandSender sender, String[] args) { + openGui = new GuiEnchantColour(); + } + }); + private static ProfileViewer profileViewer; SimpleCommand viewProfileCommand = new SimpleCommand("neuprofile", new SimpleCommand.ProcessCommandRunnable() { public void processCommand(ICommandSender sender, String[] args) { + /*if(!OpenGlHelper.isFramebufferEnabled()) { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + + "This feature requires FBOs to work. Try disabling Optifine's 'Fast Render'.")); + } else*/ if(args.length != 1) { Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "idiot.")); @@ -210,6 +227,7 @@ public class NotEnoughUpdates { ClientCommandHandler.instance.registerCommand(linksCommand); ClientCommandHandler.instance.registerCommand(viewProfileCommand); ClientCommandHandler.instance.registerCommand(overlayPlacementsCommand); + ClientCommandHandler.instance.registerCommand(enchantColourCommand); //ClientCommandHandler.instance.registerCommand(questingCommand); ClientCommandHandler.instance.registerCommand(neuAhCommand); @@ -383,28 +401,39 @@ public class NotEnoughUpdates { * 2)Adds unique items to the collection log */ private HashMap newItemAddMap = new HashMap<>(); + private long lastLongUpdate = 0; @SubscribeEvent public void onTick(TickEvent.ClientTickEvent event) { + boolean longUpdate = false; + long currentTime = System.currentTimeMillis(); + if(currentTime - lastLongUpdate > 1000) { + longUpdate = true; + lastLongUpdate = currentTime; + } if(openGui != null) { Minecraft.getMinecraft().displayGuiScreen(openGui); openGui = null; } - if(hasSkyblockScoreboard()) { - manager.auctionManager.tick(); - if(!joinedSB && manager.config.showUpdateMsg.value) { - if(displayUpdateMessageIfOutOfDate()) { - joinedSB = false; + if(longUpdate) { + updateSkyblockScoreboard(); + if(hasSkyblockScoreboard()) { + manager.auctionManager.tick(); + if(!joinedSB && manager.config.showUpdateMsg.value) { + if(displayUpdateMessageIfOutOfDate()) { + joinedSB = false; + } } + SBScoreboardData.getInstance().tick(); + //GuiQuestLine.questLine.tick(); } - SBScoreboardData.getInstance().tick(); - //GuiQuestLine.questLine.tick(); + //ItemRarityHalo.resetItemHaloCache(); } - if(currChatMessage != null && System.currentTimeMillis() - lastChatMessage > CHAT_MSG_COOLDOWN) { - lastChatMessage = System.currentTimeMillis(); + if(currChatMessage != null && currentTime - lastChatMessage > CHAT_MSG_COOLDOWN) { + lastChatMessage = currentTime; Minecraft.getMinecraft().thePlayer.sendChatMessage(currChatMessage); currChatMessage = null; } - if(hasSkyblockScoreboard() && manager.getCurrentProfile() != null && manager.getCurrentProfile().length() > 0) { + if(longUpdate && hasSkyblockScoreboard() && manager.getCurrentProfile() != null && manager.getCurrentProfile().length() > 0) { HashSet newItem = new HashSet<>(); if(Minecraft.getMinecraft().currentScreen instanceof GuiContainer && !(Minecraft.getMinecraft().currentScreen instanceof GuiCrafting)) { @@ -512,7 +541,8 @@ public class NotEnoughUpdates { String containerName = container.getLowerChestInventory().getDisplayName().getUnformattedText(); manager.auctionManager.customAH.setRenderOverAuctionView(containerName.trim().equals("Auction View") || - containerName.trim().equals("BIN Auction View") || containerName.trim().equals("Confirm Bid")); + containerName.trim().equals("BIN Auction View") || containerName.trim().equals("Confirm Bid") || + containerName.trim().equals("Confirm Purchase")); } //OPEN @@ -682,7 +712,7 @@ public class NotEnoughUpdates { */ @SubscribeEvent public void onGuiBackgroundDraw(GuiScreenEvent.BackgroundDrawnEvent event) { - if((event.gui instanceof GuiContainer || event.gui instanceof CustomAHGui) && isOnSkyblock()) { + if((event.gui instanceof GuiContainer || event.gui instanceof CustomAHGui || event.gui instanceof GuiItemRecipe) && isOnSkyblock()) { ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft()); int width = scaledresolution.getScaledWidth(); @@ -749,7 +779,7 @@ public class NotEnoughUpdates { @SubscribeEvent public void onGuiScreenDrawPost(GuiScreenEvent.DrawScreenEvent.Post event) { if(!(event.gui instanceof CustomAHGui || manager.auctionManager.customAH.isRenderOverAuctionView())) { - if(event.gui instanceof GuiContainer && isOnSkyblock()) { + if((event.gui instanceof GuiContainer || event.gui instanceof GuiItemRecipe) && isOnSkyblock()) { renderDungeonChestOverlay(event.gui); @@ -1003,6 +1033,103 @@ public class NotEnoughUpdates { }*/ } + @SubscribeEvent(priority = EventPriority.LOW) + public void onItemTooltipLow(ItemTooltipEvent event) { + //NotEnoughUpdates.INSTANCE.manager.config.enchantColours.value + int index = 0; + List newTooltip = new ArrayList<>(); + for(String line : event.toolTip) { + for(String op : NotEnoughUpdates.INSTANCE.manager.config.enchantColours.value) { + List colourOps = GuiEnchantColour.splitter.splitToList(op); + String enchantName = GuiEnchantColour.getColourOpIndex(colourOps, 0); + String comparator = GuiEnchantColour.getColourOpIndex(colourOps, 1); + String comparison = GuiEnchantColour.getColourOpIndex(colourOps, 2); + String colourCode = GuiEnchantColour.getColourOpIndex(colourOps, 3); + + if(enchantName.length() == 0) continue; + if(comparator.length() == 0) continue; + if(comparison.length() == 0) continue; + if(colourCode.length() == 0) continue; + + if(enchantName.contains("(") || enchantName.contains(")")) continue; + + int comparatorI = ">=<".indexOf(comparator.charAt(0)); + + int levelToFind = -1; + try { + levelToFind = Integer.parseInt(comparison); + } catch(Exception e) { continue; } + + if(comparatorI < 0) continue; + if("0123456789abcdefz".indexOf(colourCode.charAt(0)) < 0) continue; + + //item_lore = item_lore.replaceAll("\\u00A79("+lvl4Max+" IV)", EnumChatFormatting.DARK_PURPLE+"$1"); + //9([a-zA-Z ]+?) ([0-9]+|(I|II|III|IV|V|VI|VII|VIII|IX|X))(,|$) + Pattern pattern; + try { + String prefix = "\u00A79"; + if(enchantName.startsWith("ULT_")) prefix = "\u00A7l\u00A7d"; + pattern = Pattern.compile(prefix+"("+enchantName+") ([0-9]+|(I|II|III|IV|V|VI|VII|VIII|IX|X))(,|$)"); + } catch(Exception e) {continue;} //malformed regex + Matcher matcher = pattern.matcher(line); + int matchCount = 0; + while(matcher.find() && matchCount < 5) { + matchCount++; + int level = -1; + String levelStr = matcher.group(2); + if(levelStr == null) continue; + try { + level = Integer.parseInt(levelStr); + } catch(Exception e) { + switch(levelStr) { + case "I": + level = 1; break; + case "II": + level = 2; break; + case "III": + level = 3; break; + case "IV": + level = 4; break; + case "V": + level = 5; break; + case "VI": + level = 6; break; + case "VII": + level = 7; break; + case "VIII": + level = 8; break; + case "IX": + level = 9; break; + case "X": + level = 10; break; + } + } + boolean matches = false; + if(level > 0) { + switch(comparator) { + case ">": + matches = level > levelToFind; break; + case "=": + matches = level == levelToFind; break; + case "<": + matches = level < levelToFind; break; + } + } + if(matches) { + if(!colourCode.equals("z")) { + line = line.replaceAll("\\u00A79"+matcher.group(1), "\u00A7"+colourCode+matcher.group(1)); + } else { + line = line.replaceAll("\\u00A79"+matcher.group(1), Utils.chromaString(matcher.group(1))); + } + } + } + } + newTooltip.add(line); + } + event.toolTip.clear(); + event.toolTip.addAll(newTooltip); + } + /** * This makes it so that holding LCONTROL while hovering over an item with NBT will show the NBT of the item. * @param event @@ -1103,13 +1230,19 @@ public class NotEnoughUpdates { } } - //Stolen from Biscut's SkyblockAddons public boolean isOnSkyblock() { if(!manager.config.onlyShowOnSkyblock.value) return true; return hasSkyblockScoreboard(); } + private boolean hasSkyblockScoreboard; + public boolean hasSkyblockScoreboard() { + return hasSkyblockScoreboard; + } + + //Stolen from Biscut's SkyblockAddons + private void updateSkyblockScoreboard() { Minecraft mc = Minecraft.getMinecraft(); if (mc != null && mc.theWorld != null) { @@ -1119,12 +1252,13 @@ public class NotEnoughUpdates { String objectiveName = sidebarObjective.getDisplayName().replaceAll("(?i)\\u00A7.", ""); for (String skyblock : SKYBLOCK_IN_ALL_LANGUAGES) { if (objectiveName.startsWith(skyblock)) { - return true; + hasSkyblockScoreboard = true; + return; } } } } - return false; + hasSkyblockScoreboard = false; } } 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 53cc4639..4d30cf3e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java @@ -40,6 +40,8 @@ public class APIManager { private JsonArray playerInformation = null; + public HashMap aucUpdates = new HashMap<>(); + public TreeMap>> extrasToAucIdMap = new TreeMap<>(); private long lastPageUpdate = 0; @@ -141,20 +143,21 @@ public class APIManager { public void tick() { customAH.tick(); - if(System.currentTimeMillis() - lastPageUpdate > 5*1000) { + long currentTime = System.currentTimeMillis(); + if(currentTime - lastPageUpdate > 5*1000) { lastPageUpdate = System.currentTimeMillis(); updatePageTick(); ahNotification(); } - if(System.currentTimeMillis() - lastProfileUpdate > 10*1000) { + if(currentTime - lastProfileUpdate > 10*1000) { lastProfileUpdate = System.currentTimeMillis(); updateProfiles(Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", "")); } - if(System.currentTimeMillis() - lastCleanup > 120*1000) { + if(currentTime - lastCleanup > 120*1000) { lastCleanup = System.currentTimeMillis(); cleanup(); } - if(System.currentTimeMillis() - lastCustomAHSearch > 60*1000) { + if(currentTime - lastCustomAHSearch > 60*1000) { lastCustomAHSearch = System.currentTimeMillis(); if(Minecraft.getMinecraft().currentScreen instanceof CustomAHGui || customAH.isRenderOverAuctionView()) { customAH.updateSearch(); @@ -415,11 +418,12 @@ public class APIManager { String rarity = auction.get("tier").getAsString(); JsonArray bids = auction.get("bids").getAsJsonArray(); - for(String lvl4Max : lvl4Maxes) { - item_lore = item_lore.replaceAll("\\u00A79("+lvl4Max+" IV)", EnumChatFormatting.DARK_PURPLE+"$1"); + { + Auction old = auctionMap.get(auctionUuid); + if(old != null && old.highest_bid_amount != highest_bid_amount) { + aucUpdates.put(page, aucUpdates.computeIfAbsent(page, k->0)+1); + } } - item_lore = item_lore.replaceAll("\\u00A79([A-Za-z ]+ VI)", EnumChatFormatting.DARK_PURPLE+"$1"); - item_lore = item_lore.replaceAll("\\u00A79([A-Za-z ]+ VII)", EnumChatFormatting.RED+"$1"); try { NBTTagCompound item_tag; 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 77fa8425..2bbabd64 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java @@ -182,10 +182,12 @@ public class CustomAH extends Gui { } public void tick() { - if(shouldUpdateSearch) updateSearch(); - if(shouldSortItems) { - sortItems(); - shouldSortItems = false; + if(Minecraft.getMinecraft().currentScreen instanceof CustomAHGui || renderOverAuctionView) { + if(shouldUpdateSearch) updateSearch(); + if(shouldSortItems) { + sortItems(); + shouldSortItems = false; + } } } @@ -530,8 +532,7 @@ public class CustomAH extends Gui { } catch(NullPointerException e) { //i cant be bothered } } - } else if(containerName.trim().equals("Confirm Bid")) { - + } else if(containerName.trim().equals("Confirm Bid") || containerName.trim().equals("Confirm Purchase")) { Minecraft.getMinecraft().getTextureManager().bindTexture(auction_accept); this.drawTexturedModalRect(auctionViewLeft, guiTop, 0, 0, 78, 172); @@ -878,6 +879,11 @@ public class CustomAH extends Gui { lore.add("ID Tagged Auctions: " + manager.auctionManager.internalnameTaggedAuctions); lore.add("Total Tags: " + manager.auctionManager.totalTags); lore.add("Tagged Auctions: " + manager.auctionManager.taggedAuctions); + lore.add("AucUpdates(0): " + manager.auctionManager.aucUpdates.computeIfAbsent(0, k->0)); + lore.add("AucUpdates(1): " + manager.auctionManager.aucUpdates.computeIfAbsent(1, k->0)); + lore.add("AucUpdates(20): " + manager.auctionManager.aucUpdates.computeIfAbsent(20, k->0)); + lore.add("AucUpdates(Last-1): " + manager.auctionManager.aucUpdates.computeIfAbsent(manager.auctionManager.aucUpdates.size()-2, k->0)); + lore.add("AucUpdates(Last): " + manager.auctionManager.aucUpdates.computeIfAbsent(manager.auctionManager.aucUpdates.size()-1, k->0)); lore.add(""); lore.add(EnumChatFormatting.AQUA + "Right-Click to copy current aucid to clipboard!"); lore.add(EnumChatFormatting.YELLOW + "Click to refresh!"); @@ -1371,7 +1377,7 @@ public class CustomAH extends Gui { Utils.playPressSound(); } } - } else if(containerName.trim().equals("Confirm Bid")) { + } else if(containerName.trim().equals("Confirm Bid") || containerName.trim().equals("Confirm Purchase")) { if(mouseX > guiLeft+getXSize()+4+31 && mouseX < guiLeft+getXSize()+4+31+16) { if(mouseY > guiTop+31 && mouseY < guiTop+31+16) { if(currentAucId != null) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/CollectionLogInfoPane.java b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/CollectionLogInfoPane.java index 5f9e6af1..e4c524f2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/CollectionLogInfoPane.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/CollectionLogInfoPane.java @@ -241,19 +241,6 @@ public class CollectionLogInfoPane extends ScrollableInfoPane { } } - private Matrix4f createProjectionMatrix(int width, int height) { - Matrix4f projMatrix = new Matrix4f(); - projMatrix.setIdentity(); - projMatrix.m00 = 2.0F / (float)width; - projMatrix.m11 = 2.0F / (float)(-height); - projMatrix.m22 = -0.0020001999F; - projMatrix.m33 = 1.0F; - projMatrix.m03 = -1.0F; - projMatrix.m13 = 1.0F; - projMatrix.m23 = -1.0001999F; - return projMatrix; - } - public int getCurrentAcquiredCount() { if(getAcquiredItems() == null) return 0; if(!getAcquiredItems().containsKey(manager.getCurrentProfile())) return 0; @@ -268,7 +255,7 @@ public class CollectionLogInfoPane extends ScrollableInfoPane { if(itemFramebuffer != null && grayscaleShader != null && (itemFramebuffer.framebufferWidth != width || itemFramebuffer.framebufferHeight != height)) { - grayscaleShader.setProjectionMatrix(createProjectionMatrix( + grayscaleShader.setProjectionMatrix(Utils.createProjectionMatrix( width*scaledresolution.getScaleFactor(), height*scaledresolution.getScaleFactor())); } @@ -300,7 +287,7 @@ public class CollectionLogInfoPane extends ScrollableInfoPane { grayscaleShader = new Shader(new NEUResourceManager(Minecraft.getMinecraft().getResourceManager()), "grayscale", itemFramebuffer, itemFramebufferGrayscale); - grayscaleShader.setProjectionMatrix(createProjectionMatrix( + grayscaleShader.setProjectionMatrix(Utils.createProjectionMatrix( width*scaledresolution.getScaleFactor(), height*scaledresolution.getScaleFactor())); } catch(Exception e) { return; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java b/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java index 3c939589..23f4ad0b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java @@ -54,7 +54,9 @@ public class GuiElementTextField extends GuiElement { } public void setText(String text) { - textField.setText(text); + if(textField.getText() == null || !textField.getText().equals(text)) { + textField.setText(text); + } } public void setSize(int searchBarXSize, int searchBarYSize) { @@ -300,6 +302,7 @@ public class GuiElementTextField extends GuiElement { if((options & FORCE_CAPS) != 0) typedChar = Character.toUpperCase(typedChar); if((options & NO_SPACE) != 0 && typedChar == ' ') return; + textField.setFocused(true); textField.textboxKeyTyped(typedChar, keyCode); if((options & COLOUR) != 0) { @@ -378,11 +381,18 @@ public class GuiElementTextField extends GuiElement { textNoColor = matcher.replaceFirst("\u00B6"+code); } + int xStartOffset = 5; + float scale = 1; String[] texts = text.split("\n"); for(int yOffI = 0; yOffI < texts.length; yOffI++) { int yOff = yOffI*extraSize; if(isScaling() && Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI])>searchBarXSize-10) { + scale = (searchBarXSize-2)/(float)Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI]); + if(scale > 1) scale=1; + float newLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI])*scale; + xStartOffset = (int)((searchBarXSize-newLen)/2f); + Utils.drawStringCenteredScaledMaxWidth(texts[yOffI], Minecraft.getMinecraft().fontRendererObj, x+searchBarXSize/2f, y+searchBarYSize/2f+yOff, false, searchBarXSize-2, Color.WHITE.getRGB()); @@ -390,7 +400,6 @@ public class GuiElementTextField extends GuiElement { Minecraft.getMinecraft().fontRendererObj.drawString(Utils.trimToWidth(texts[yOffI], searchBarXSize-10), x + 5, y+(searchBarYSize-8)/2+yOff, Color.WHITE.getRGB()); } - } if(focus && System.currentTimeMillis()%1000>500) { @@ -406,22 +415,20 @@ public class GuiElementTextField extends GuiElement { if(split.length <= numLinesBeforeCursor || split.length == 0) { textBeforeCursorWidth = 0; } else { - textBeforeCursorWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(split[split.length-1]); + textBeforeCursorWidth = (int)(Minecraft.getMinecraft().fontRendererObj.getStringWidth(split[split.length-1])*scale); } - drawRect(x + 5 + textBeforeCursorWidth, + drawRect(x + xStartOffset + textBeforeCursorWidth, y+(searchBarYSize-8)/2-1 + yOff, - x + 5 + textBeforeCursorWidth+1, + x + xStartOffset + textBeforeCursorWidth+1, y+(searchBarYSize-8)/2+9 + yOff, Color.WHITE.getRGB()); } String selectedText = textField.getSelectedText(); if(!selectedText.isEmpty()) { - int leftIndex = textField.getCursorPosition() < textField.getSelectionEnd() ? - textField.getCursorPosition() : textField.getSelectionEnd(); - int rightIndex = textField.getCursorPosition() > textField.getSelectionEnd() ? - textField.getCursorPosition() : textField.getSelectionEnd(); + int leftIndex = Math.min(textField.getCursorPosition(), textField.getSelectionEnd()); + int rightIndex = Math.max(textField.getCursorPosition(), textField.getSelectionEnd()); - int texX = 0; + float texX = 0; int texY = 0; boolean sectionSignPrev = false; boolean bold = false; @@ -440,9 +447,9 @@ public class GuiElementTextField extends GuiElement { if(c == '\n') { if(i >= leftIndex && i < rightIndex) { - drawRect(x + 5 + texX, + drawRect(x + xStartOffset + (int)texX, y+(searchBarYSize-8)/2-1 + texY, - x + 5 + texX + 3, + x + xStartOffset + (int)texX + 3, y+(searchBarYSize-8)/2+9 + texY, Color.LIGHT_GRAY.getRGB()); } @@ -456,22 +463,22 @@ public class GuiElementTextField extends GuiElement { int len = Minecraft.getMinecraft().fontRendererObj.getStringWidth(String.valueOf(c)); if(bold) len++; if(i >= leftIndex && i < rightIndex) { - drawRect(x + 5 + texX, + drawRect(x + xStartOffset + (int)texX, y+(searchBarYSize-8)/2-1 + texY, - x + 5 + texX + len, + x + xStartOffset + (int)(texX + len*scale), y+(searchBarYSize-8)/2+9 + texY, Color.LIGHT_GRAY.getRGB()); - Minecraft.getMinecraft().fontRendererObj.drawString(String.valueOf(c), - x + 5 + texX, - y+(searchBarYSize-8)/2 + texY, Color.BLACK.getRGB()); + Utils.drawStringScaled(String.valueOf(c), Minecraft.getMinecraft().fontRendererObj, + x + xStartOffset + texX, + y+searchBarYSize/2f-scale*8/2f + texY, false, Color.BLACK.getRGB(), scale); if(bold) { - Minecraft.getMinecraft().fontRendererObj.drawString(String.valueOf(c), - x + 5 + texX +1, - y+(searchBarYSize-8)/2 + texY, Color.BLACK.getRGB()); + Utils.drawStringScaled(String.valueOf(c), Minecraft.getMinecraft().fontRendererObj, + x + xStartOffset + texX + 1, + y+searchBarYSize/2f-scale*8/2f + texY, false, Color.BLACK.getRGB(), scale); } } - texX += len; + texX += len*scale; } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinInventoryEffectRenderer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinInventoryEffectRenderer.java index 51c85b19..00fdc873 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinInventoryEffectRenderer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinInventoryEffectRenderer.java @@ -4,6 +4,7 @@ import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import net.minecraft.client.renderer.InventoryEffectRenderer; 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; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderItem.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderItem.java new file mode 100644 index 00000000..67f0f7dc --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderItem.java @@ -0,0 +1,53 @@ +package io.github.moulberry.notenoughupdates.mixins; + +import io.github.moulberry.notenoughupdates.ItemRarityHalo; +import io.github.moulberry.notenoughupdates.NEUResourceManager; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.client.resources.model.IBakedModel; +import net.minecraft.client.shader.Framebuffer; +import net.minecraft.client.shader.Shader; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Matrix4f; +import org.lwjgl.BufferUtils; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; +import org.lwjgl.opengl.GL30; +import org.lwjgl.util.vector.Vector4f; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import javax.vecmath.Vector3f; +import java.awt.*; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.util.HashMap; + +@Mixin({RenderItem.class}) +public abstract class MixinRenderItem { + + //Lnet/minecraft/client/renderer/entity/RenderItem;renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/resources/model/IBakedModel;)V + @Inject(method="Lnet/minecraft/client/renderer/entity/RenderItem;renderItemIntoGUI(Lnet/minecraft/item/ItemStack;II)V", + at=@At("HEAD"), cancellable = true) + public void renderItemIntoGUI(ItemStack stack, int x, int y, CallbackInfo ci) { + if(x == 0 && y == 0 || true) return; + ItemRarityHalo.onItemRender(stack, x, y); + + if(Keyboard.isKeyDown(Keyboard.KEY_H)) ci.cancel(); + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java b/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java index 1c8a6e07..8cd82568 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java @@ -1,6 +1,7 @@ package io.github.moulberry.notenoughupdates.options; import com.google.gson.*; +import io.github.moulberry.notenough