From 8499a98beeb556c16987fc375dbd7d05d6c27ab4 Mon Sep 17 00:00:00 2001 From: Moulberry Date: Mon, 20 Jul 2020 05:12:05 +1000 Subject: some profile viewer stuffs --- .../moulberry/notenoughupdates/util/Utils.java | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index 57b89a0a..66400c00 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -1,5 +1,9 @@ package io.github.moulberry.notenoughupdates.util; +import com.google.common.base.Splitter; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; import com.mojang.authlib.Agent; import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication; @@ -376,6 +380,50 @@ public class Utils { drawHoveringText(textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth, font, true); } + public static JsonObject getConstant(String constant) { + File repo = NotEnoughUpdates.INSTANCE.manager.repoLocation; + if(repo.exists()) { + File jsonFile = new File(repo, "constants/"+constant+".json"); + try { + return NotEnoughUpdates.INSTANCE.manager.getJsonFromFile(jsonFile); + } catch (Exception ignored) { + } + } + System.out.println(constant + " = null"); + return null; + } + + public static float getElementAsFloat(JsonElement element, float def) { + if(element == null) return def; + if(!element.isJsonPrimitive()) return def; + JsonPrimitive prim = element.getAsJsonPrimitive(); + if(!prim.isNumber()) return def; + return prim.getAsFloat(); + } + + public static String getElementAsString(JsonElement element, String def) { + if(element == null) return def; + if(!element.isJsonPrimitive()) return def; + JsonPrimitive prim = element.getAsJsonPrimitive(); + if(!prim.isString()) return def; + return prim.getAsString(); + } + + public static Splitter PATH_SPLITTER = Splitter.on(".").omitEmptyStrings().limit(2); + public static JsonElement getElement(JsonElement element, String path) { + List path_split = PATH_SPLITTER.splitToList(path); + if(element instanceof JsonObject) { + JsonElement e = element.getAsJsonObject().get(path_split.get(0)); + if(path_split.size() > 1) { + return getElement(e, path_split.get(1)); + } else { + return e; + } + } else { + return element; + } + } + public static ChatStyle createClickStyle(ClickEvent.Action action, String value) { ChatStyle style = new ChatStyle(); style.setChatClickEvent(new ClickEvent(action, value)); -- cgit From d04771c7ef5cdab9554aa6aef506a39c8e2bd3d4 Mon Sep 17 00:00:00 2001 From: Moulberry Date: Wed, 22 Jul 2020 03:54:59 +1000 Subject: less scuffed profile viewer :) --- .../moulberry/notenoughupdates/util/Utils.java | 89 ++++++++++++++++++++++ 1 file changed, 89 insertions(+) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index 66400c00..5fe96aae 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -13,13 +13,18 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.client.audio.SoundHandler; import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.client.resources.model.IBakedModel; import net.minecraft.event.ClickEvent; import net.minecraft.event.HoverEvent; import net.minecraft.inventory.Slot; @@ -33,6 +38,7 @@ import net.minecraft.util.*; import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL14; +import org.lwjgl.util.glu.Project; import javax.swing.*; import java.awt.*; @@ -89,6 +95,80 @@ public class Utils { RenderHelper.disableStandardItemLighting(); } + private static final EnumChatFormatting[] rainbow = new EnumChatFormatting[]{ + EnumChatFormatting.RED, + EnumChatFormatting.GOLD, + EnumChatFormatting.YELLOW, + EnumChatFormatting.GREEN, + EnumChatFormatting.AQUA, + EnumChatFormatting.LIGHT_PURPLE, + EnumChatFormatting.DARK_PURPLE + }; + + public static String chromaString(String str) { + long currentTimeMillis = System.currentTimeMillis(); + + StringBuilder rainbowText = new StringBuilder(); + for(int i=0; i clazz, Class[] params, String... methodNames) { for(String methodName : methodNames) { try { @@ -281,6 +361,15 @@ public class Utils { drawStringScaled(str, fr, x, y-fontHeight/2, shadow, colour, factor); } + public static void drawStringCenteredYScaledMaxWidth(String str, FontRenderer fr, float x, float y, boolean shadow, int len, int colour) { + int strLen = fr.getStringWidth(str); + float factor = len/(float)strLen; + factor = Math.min(1, factor); + float fontHeight = 8*factor; + + drawStringScaled(str, fr, x, y-fontHeight/2, shadow, colour, factor); + } + public static int renderStringTrimWidth(String str, FontRenderer fr, boolean shadow, int x, int y, int len, int colour, int maxLines) { return renderStringTrimWidth(str, fr, shadow, x, y, len, colour, maxLines, 1); } -- cgit 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/util/Utils.java | 127 +++++++++++++++------ 1 file changed, 94 insertions(+), 33 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index 5fe96aae..144db9da 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -1,6 +1,7 @@ package io.github.moulberry.notenoughupdates.util; import com.google.common.base.Splitter; +import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; @@ -82,7 +83,7 @@ public class Utils { RenderHelper.disableStandardItemLighting(); } - public static void drawItemStack(ItemStack stack, int x, int y) { + public static void drawItemStackWithText(ItemStack stack, int x, int y, String text) { if(stack == null)return; RenderItem itemRender = Minecraft.getMinecraft().getRenderItem(); @@ -90,11 +91,17 @@ public class Utils { RenderHelper.enableGUIStandardItemLighting(); itemRender.zLevel = -145; //Negates the z-offset of the below method. itemRender.renderItemAndEffectIntoGUI(stack, x, y); - itemRender.renderItemOverlays(Minecraft.getMinecraft().fontRendererObj, stack, x, y); + itemRender.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRendererObj, stack, x, y, text); itemRender.zLevel = 0; RenderHelper.disableStandardItemLighting(); } + public static void drawItemStack(ItemStack stack, int x, int y) { + if(stack == null)return; + + drawItemStackWithText(stack, x, y, null); + } + private static final EnumChatFormatting[] rainbow = new EnumChatFormatting[]{ EnumChatFormatting.RED, EnumChatFormatting.GOLD, @@ -228,6 +235,33 @@ public class Utils { return str.substring(0, 1).toUpperCase() + str.substring(1).toLowerCase(); } + private static String[] rarityArr = new String[] { + "COMMON", "UNCOMMON", "RARE", "EPIC", "LEGENDARY", "MYTHIC", "SPECIAL", "VERY SPECIAL", + }; + public static int checkItemType(JsonArray lore, boolean contains, String... typeMatches) { + for(int i=lore.size()-1; i>=0; i--) { + String line = lore.get(i).getAsString(); + for(String rarity : rarityArr) { + for(int j=0; j= 0) { + currentColour = colIndex; + } else { + currentColour = 0; + } + } else if("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(c) >= 0){ + if(currentColour > 0) { + mostCommon[currentColour]++; + } + } + } + int mostCommonCount = 0; + for(int index=0; index mostCommonCount) { + mostCommonCount = mostCommon[index]; + currentColour = index; + } + } + + int colourInt = Minecraft.getMinecraft().fontRendererObj.getColorCode("0123456789abcdef".charAt(currentColour)); + return new Color(colourInt).darker(); + } + public static void drawHoveringText(List textLines, final int mouseX, final int mouseY, final int screenWidth, final int screenHeight, final int maxTextWidth, FontRenderer font, boolean coloured) { if (!textLines.isEmpty()) { @@ -639,36 +729,7 @@ public class Utils { if(NotEnoughUpdates.INSTANCE.manager.config.tooltipBorderColours.value && coloured) { if(textLines.size() > 0) { String first = textLines.get(0); - int lastColourCode = -99; - int currentColour = 0; - int[] mostCommon = new int[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; - for(int i=0; i= 0) { - currentColour = colIndex; - } else { - currentColour = 0; - } - } else if("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(c) >= 0){ - if(currentColour > 0) { - mostCommon[currentColour]++; - } - } - } - int mostCommonCount = 0; - for(int index=0; index mostCommonCount) { - mostCommonCount = mostCommon[index]; - currentColour = index; - } - } - - int colourInt = font.getColorCode("0123456789abcdef".charAt(currentColour)); - borderColorStart = new Color(colourInt).darker().getRGB() & 0x00FFFFFF | + borderColorStart = getPrimaryColour(first).getRGB() & 0x00FFFFFF | ((NotEnoughUpdates.INSTANCE.manager.config.tooltipBorderOpacity.value.intValue()) << 24); } } -- cgit From 0c23f52d2be811d74a3b6ef598dd9de7ccb763ab Mon Sep 17 00:00:00 2001 From: Moulberry Date: Mon, 17 Aug 2020 00:13:03 +1000 Subject: 1.1.3 --- src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java | 1 + 1 file changed, 1 insertion(+) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index 144db9da..73c15a7b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -619,6 +619,7 @@ public class Utils { return new Color(colourInt).darker(); } + //private static List public static void drawHoveringText(List textLines, final int mouseX, final int mouseY, final int screenWidth, final int screenHeight, final int maxTextWidth, FontRenderer font, boolean coloured) { if (!textLines.isEmpty()) { -- cgit From ea1391e0c6f0db863bbb61511eb6e9acb57a5968 Mon Sep 17 00:00:00 2001 From: Moulberry Date: Wed, 19 Aug 2020 12:16:12 +1000 Subject: 1.1.5 --- .../moulberry/notenoughupdates/util/Utils.java | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index 73c15a7b..428a43b2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -619,7 +619,12 @@ public class Utils { return new Color(colourInt).darker(); } - //private static List + public static void scrollTooltip(int dY) { + scrollY.setTarget(scrollY.getTarget()+dY/10f); + scrollY.resetTimer(); + } + + private static LerpingFloat scrollY = new LerpingFloat(0, 100); public static void drawHoveringText(List textLines, final int mouseX, final int mouseY, final int screenWidth, final int screenHeight, final int maxTextWidth, FontRenderer font, boolean coloured) { if (!textLines.isEmpty()) { @@ -713,9 +718,24 @@ public class Utils { } } + //Scrollable tooltips + if(tooltipHeight + 6 > screenHeight) { + if(scrollY.getTarget() < 0) { + scrollY.setTarget(0); + scrollY.resetTimer(); + } else if(screenHeight - tooltipHeight - 12 + (int)scrollY.getTarget() > 0) { + scrollY.setTarget(-screenHeight + tooltipHeight + 12); + scrollY.resetTimer(); + } + } else { + scrollY.setValue(0); + scrollY.resetTimer(); + } + scrollY.tick(); + if (tooltipY + tooltipHeight + 6 > screenHeight) { - tooltipY = screenHeight - tooltipHeight - 6; + tooltipY = screenHeight - tooltipHeight - 6 + (int)scrollY.getValue(); } final int zLevel = 300; -- cgit From 65ae0aa5a0319b6ead2dd6ed07c53a7e7291a23d Mon Sep 17 00:00:00 2001 From: Moulberry Date: Thu, 20 Aug 2020 03:15:09 +1000 Subject: 1.1.5-2 --- .../java/io/github/moulberry/notenoughupdates/util/Utils.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index 428a43b2..9445514f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -125,6 +125,17 @@ public class Utils { return rainbowText.toString(); } + private static char[] c = new char[]{'k', 'm', 'b', 't'}; + public static String shortNumberFormat(double n, int iteration) { + double d = ((long) n / 100) / 10.0; + boolean isRound = (d * 10) %10 == 0; + return (d < 1000? + ((d > 99.9 || isRound || (!isRound && d > 9.99)? + (int) d * 10 / 10 : d + "" + ) + "" + c[iteration]) + : shortNumberFormat(d, iteration+1)); + } + public static void drawItemStackLinear(ItemStack stack, int x, int y) { if(stack == null)return; -- cgit From a5f669c4ec0692efd0e532d23156ea260718c0ee Mon Sep 17 00:00:00 2001 From: Moulberry Date: Sat, 29 Aug 2020 02:32:19 +1000 Subject: 1.2.3 --- src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index 9445514f..7ce180b9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -97,7 +97,7 @@ public class Utils { } public static void drawItemStack(ItemStack stack, int x, int y) { - if(stack == null)return; + if(stack == null) return; drawItemStackWithText(stack, x, y, null); } @@ -361,7 +361,8 @@ public class Utils { public static void drawStringF(String str, FontRenderer fr, float x, float y, boolean shadow, int colour) { GL11.glTranslatef(x, y, 0); - fr.drawString(str, x, y, colour, shadow); + fr.drawString(str, 0, 0, colour, shadow); + GL11.glTranslatef(-x, -y, 0); } public static void drawStringScaledMaxWidth(String str, FontRenderer fr, float x, float y, boolean shadow, int len, int colour) { -- cgit From 3f86e881074dc4220aab23cae69f002c62f0b25a Mon Sep 17 00:00:00 2001 From: Moulberry Date: Sun, 25 Oct 2020 09:39:40 +1100 Subject: 1.4.5 --- .../moulberry/notenoughupdates/util/Utils.java | 95 ++++++++++++++++++++-- 1 file changed, 87 insertions(+), 8 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index 7ce180b9..d8df52e7 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -16,10 +16,7 @@ import net.minecraft.client.audio.SoundHandler; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.*; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.texture.DynamicTexture; @@ -36,6 +33,8 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; import net.minecraft.server.MinecraftServer; import net.minecraft.util.*; +import net.minecraftforge.fml.common.Loader; +import org.lwjgl.BufferUtils; import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL14; @@ -48,16 +47,21 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.net.Proxy; +import java.nio.FloatBuffer; import java.nio.file.Files; -import java.util.ArrayList; +import java.util.*; import java.util.List; -import java.util.UUID; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Utils { private static boolean hasEffectOverride = false; + private static LinkedList guiScales = new LinkedList<>(); + private static ScaledResolution lastScale = new ScaledResolution(Minecraft.getMinecraft()); + //Labymod compatibility + private static FloatBuffer projectionMatrixOld = BufferUtils.createFloatBuffer(16); + private static FloatBuffer modelviewMatrixOld = BufferUtils.createFloatBuffer(16); public static ArrayList createList(T... values) { ArrayList list = new ArrayList<>(); @@ -65,6 +69,67 @@ public class Utils { return list; } + public static void resetGuiScale() { + guiScales.clear(); + } + + public static ScaledResolution peekGuiScale() { + return lastScale; + } + + public static ScaledResolution pushGuiScale(int scale) { + if(guiScales.size() == 0) { + if(Loader.isModLoaded("labymod")) { + GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projectionMatrixOld); + GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelviewMatrixOld); + } + } + + if(scale < 0) { + if(guiScales.size() > 0) { + guiScales.pop(); + } + } else { + if(scale == 0) { + guiScales.push(Minecraft.getMinecraft().gameSettings.guiScale); + } else { + guiScales.push(scale); + } + } + + int newScale = guiScales.size() > 0 ? Math.max(1, Math.min(4, guiScales.peek())) : Minecraft.getMinecraft().gameSettings.guiScale; + if(newScale == 0) newScale = Minecraft.getMinecraft().gameSettings.guiScale; + + int oldScale = Minecraft.getMinecraft().gameSettings.guiScale; + Minecraft.getMinecraft().gameSettings.guiScale = newScale; + ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft()); + Minecraft.getMinecraft().gameSettings.guiScale = oldScale; + + if(guiScales.size() > 0) { + GlStateManager.viewport(0, 0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight); + GlStateManager.matrixMode(GL11.GL_PROJECTION); + GlStateManager.loadIdentity(); + GlStateManager.ortho(0.0D, + scaledresolution.getScaledWidth_double(), + scaledresolution.getScaledHeight_double(), 0.0D, 1000.0D, 3000.0D); + GlStateManager.matrixMode(GL11.GL_MODELVIEW); + GlStateManager.loadIdentity(); + GlStateManager.translate(0.0F, 0.0F, -2000.0F); + } else { + if(Loader.isModLoaded("labymod") && projectionMatrixOld.limit() > 0 && modelviewMatrixOld.limit() > 0) { + GlStateManager.matrixMode(GL11.GL_PROJECTION); + GL11.glLoadMatrix(projectionMatrixOld); + GlStateManager.matrixMode(GL11.GL_MODELVIEW); + GL11.glLoadMatrix(modelviewMatrixOld); + } else { + Minecraft.getMinecraft().entityRenderer.setupOverlayRendering(); + } + } + + lastScale = scaledresolution; + return scaledresolution; + } + public static boolean getHasEffectOverride() { return hasEffectOverride; } @@ -113,14 +178,28 @@ public class Utils { }; public static String chromaString(String str) { + return chromaString(str, 0, false); + } + + private static long startTime = 0; + public static String chromaString(String str, float offset, boolean bold) { + str = cleanColour(str); + long currentTimeMillis = System.currentTimeMillis(); + if(startTime == 0) startTime = currentTimeMillis; StringBuilder rainbowText = new StringBuilder(); + int len = 0; for(int i=0; i Date: Sun, 25 Oct 2020 10:20:59 +1100 Subject: 1.4.6 --- .../java/io/github/moulberry/notenoughupdates/util/Utils.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index d8df52e7..04bad54f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -122,7 +122,14 @@ public class Utils { GlStateManager.matrixMode(GL11.GL_MODELVIEW); GL11.glLoadMatrix(modelviewMatrixOld); } else { - Minecraft.getMinecraft().entityRenderer.setupOverlayRendering(); + GlStateManager.matrixMode(GL11.GL_PROJECTION); + GlStateManager.loadIdentity(); + GlStateManager.ortho(0.0D, + scaledresolution.getScaledWidth_double(), + scaledresolution.getScaledHeight_double(), 0.0D, 1000.0D, 3000.0D); + GlStateManager.matrixMode(GL11.GL_MODELVIEW); + GlStateManager.loadIdentity(); + GlStateManager.translate(0.0F, 0.0F, -2000.0F); } } -- cgit From 431d4a5eca207aa6f86a90e3c4e1912885f115eb Mon Sep 17 00:00:00 2001 From: Moulberry Date: Sat, 31 Oct 2020 21:49:14 +1100 Subject: 1.4.9 --- .../moulberry/notenoughupdates/util/Utils.java | 85 ++++++++++++++++++++++ 1 file changed, 85 insertions(+) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index 04bad54f..f732779c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -420,6 +420,33 @@ public class Utils { GlStateManager.disableBlend(); } + public static void drawTexturedRectNoBlend(float x, float y, float width, float height, float uMin, float uMax, float vMin, float vMax, int filter) { + GlStateManager.enableTexture2D(); + + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, filter); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, filter); + + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); + worldrenderer + .pos(x, y+height, 0.0D) + .tex(uMin, vMax).endVertex(); + worldrenderer + .pos(x+width, y+height, 0.0D) + .tex(uMax, vMax).endVertex(); + worldrenderer + .pos(x+width, y, 0.0D) + .tex(uMax, vMin).endVertex(); + worldrenderer + .pos(x, y, 0.0D) + .tex(uMin, vMin).endVertex(); + tessellator.draw(); + + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); + } + public static ItemStack createItemStack(Item item, String displayname, String... lore) { return createItemStack(item, displayname, 0, lore); } @@ -620,6 +647,34 @@ public class Utils { GlStateManager.enableTexture2D(); } + public static void drawGradientRectHorz(int left, int top, int right, int bottom, int startColor, int endColor) { + float f = (float)(startColor >> 24 & 255) / 255.0F; + float f1 = (float)(startColor >> 16 & 255) / 255.0F; + float f2 = (float)(startColor >> 8 & 255) / 255.0F; + float f3 = (float)(startColor & 255) / 255.0F; + float f4 = (float)(endColor >> 24 & 255) / 255.0F; + float f5 = (float)(endColor >> 16 & 255) / 255.0F; + float f6 = (float)(endColor >> 8 & 255) / 255.0F; + float f7 = (float)(endColor & 255) / 255.0F; + GlStateManager.disableTexture2D(); + GlStateManager.enableBlend(); + GlStateManager.disableAlpha(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.shadeModel(7425); + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR); + worldrenderer.pos((double)right, (double)top, 0).color(f5, f6, f7, f4).endVertex(); + worldrenderer.pos((double)left, (double)top, 0).color(f1, f2, f3, f).endVertex(); + worldrenderer.pos((double)left, (double)bottom, 0).color(f1, f2, f3, f).endVertex(); + worldrenderer.pos((double)right, (double)bottom, 0).color(f5, f6, f7, f4).endVertex(); + tessellator.draw(); + GlStateManager.shadeModel(7424); + GlStateManager.disableBlend(); + GlStateManager.enableAlpha(); + GlStateManager.enableTexture2D(); + } + public static void drawHoveringText(List textLines, final int mouseX, final int mouseY, final int screenWidth, final int screenHeight, final int maxTextWidth, FontRenderer font) { drawHoveringText(textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth, font, true); } @@ -910,4 +965,34 @@ public class Utils { GlStateManager.enableTexture2D(); } + public static void drawRectNoBlend(int left, int top, int right, int bottom, int color) { + if (left < right) { + int i = left; + left = right; + right = i; + } + + if (top < bottom) { + int j = top; + top = bottom; + bottom = j; + } + + float f3 = (float)(color >> 24 & 255) / 255.0F; + float f = (float)(color >> 16 & 255) / 255.0F; + float f1 = (float)(color >> 8 & 255) / 255.0F; + float f2 = (float)(color & 255) / 255.0F; + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + GlStateManager.disableTexture2D(); + GlStateManager.color(f, f1, f2, f3); + worldrenderer.begin(7, DefaultVertexFormats.POSITION); + worldrenderer.pos((double)left, (double)bottom, 0.0D).endVertex(); + worldrenderer.pos((double)right, (double)bottom, 0.0D).endVertex(); + worldrenderer.pos((double)right, (double)top, 0.0D).endVertex(); + worldrenderer.pos((double)left, (double)top, 0.0D).endVertex(); + tessellator.draw(); + GlStateManager.enableTexture2D(); + } + } -- cgit From f89c363dda53046d832089d94f04695ce60d3ae6 Mon Sep 17 00:00:00 2001 From: Moulberry Date: Wed, 4 Nov 2020 05:36:16 +1100 Subject: fine 1.5.3 --- src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index f732779c..e2faa5aa 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -31,6 +31,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; +import net.minecraft.potion.Potion; import net.minecraft.server.MinecraftServer; import net.minecraft.util.*; import net.minecraftforge.fml.common.Loader; @@ -57,6 +58,7 @@ import java.util.regex.Pattern; public class Utils { private static boolean hasEffectOverride = false; + public static boolean disableCustomDungColours = false; private static LinkedList guiScales = new LinkedList<>(); private static ScaledResolution lastScale = new ScaledResolution(Minecraft.getMinecraft()); //Labymod compatibility @@ -144,6 +146,7 @@ public class Utils { public static void drawItemStackWithoutGlint(ItemStack stack, int x, int y) { RenderItem itemRender = Minecraft.getMinecraft().getRenderItem(); + disableCustomDungColours = true; RenderHelper.enableGUIStandardItemLighting(); itemRender.zLevel = -145; //Negates the z-offset of the below method. hasEffectOverride = true; @@ -153,6 +156,7 @@ public class Utils { hasEffectOverride = false; itemRender.zLevel = 0; RenderHelper.disableStandardItemLighting(); + disableCustomDungColours = false; } public static void drawItemStackWithText(ItemStack stack, int x, int y, String text) { @@ -160,12 +164,14 @@ public class Utils { RenderItem itemRender = Minecraft.getMinecraft().getRenderItem(); + disableCustomDungColours = true; RenderHelper.enableGUIStandardItemLighting(); itemRender.zLevel = -145; //Negates the z-offset of the below method. itemRender.renderItemAndEffectIntoGUI(stack, x, y); itemRender.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRendererObj, stack, x, y, text); itemRender.zLevel = 0; RenderHelper.disableStandardItemLighting(); + disableCustomDungColours = false; } public static void drawItemStack(ItemStack stack, int x, int y) { -- cgit