From f10046f075efd7e17336a7b4629d446283b5c953 Mon Sep 17 00:00:00 2001 From: syeyoung Date: Thu, 5 Aug 2021 12:35:15 +0900 Subject: - Remove GlStateManager.pushAttrib, which causes .... a lot of problems = Black screen hopefully fixed? - Mechanic Browser Rewrite --- .../syeyoung/dungeonsguide/utils/GlStateUtils.java | 69 ++++++++++++++++++++++ .../syeyoung/dungeonsguide/utils/RenderUtils.java | 24 ++++---- 2 files changed, 81 insertions(+), 12 deletions(-) create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/utils/GlStateUtils.java (limited to 'src/main/java/kr/syeyoung/dungeonsguide/utils') diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/GlStateUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/GlStateUtils.java new file mode 100644 index 00000000..2737be9d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/GlStateUtils.java @@ -0,0 +1,69 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.utils; + +import com.sun.org.apache.xpath.internal.operations.Bool; +import net.minecraft.client.renderer.GlStateManager; + +import java.lang.reflect.Field; +import java.util.*; + +public class GlStateUtils { + public static Map dumpStates() { + Map primitiveDump = new LinkedHashMap<>(); + try { + recursivelyDump(primitiveDump, "GlStateManager", null, GlStateManager.class); + } catch (IllegalAccessException e) { + e.printStackTrace(); + primitiveDump.put("$ERROR", true); + } + return primitiveDump; + } + + public static void printDump(Map dump) { + for (Map.Entry stringObjectEntry : dump.entrySet()) { + System.out.println(stringObjectEntry+": "+stringObjectEntry.getValue()); + } + } + + public static void compareDump(Map dump1, Map dump2) { + Set set = new HashSet<>(); + set.addAll(dump1.keySet()); + set.addAll(dump2.keySet()); + + for (String s : set) { + Object obj1 = dump1.get(s); + Object obj2 = dump2.get(s); + if (!Objects.equals(obj1, obj2)) System.out.println(s+": Prev {"+obj1+"} New {"+obj2+"}"); + } + } + + public static void recursivelyDump(Map primitiveDump, String objPath, Object obj, Class clazz) throws IllegalAccessException { + primitiveDump.put(objPath+".$class", clazz.getName()); + for (Field declaredField : clazz.getDeclaredFields()) { + declaredField.setAccessible(true); + Object fieldData = declaredField.get(obj); + if (fieldData.getClass().getName().startsWith("java.lang")) { + primitiveDump.put(objPath+"."+declaredField.getName(), fieldData); + } else { + recursivelyDump(primitiveDump, objPath+"."+declaredField.getName(), fieldData, fieldData.getClass()); + } + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java index 685b8489..736d8ef2 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java @@ -373,7 +373,7 @@ public class RenderUtils { double playerZ = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks; //because of the way 3D rendering is done, all coordinates are relative to the camera. This "resets" the "0,0,0" position to the location that is (0,0,0) in the world. - GlStateManager.pushAttrib(); + GlStateManager.pushMatrix(); GlStateManager.translate(-playerX, -playerY, -playerZ); GlStateManager.disableTexture2D(); @@ -436,7 +436,7 @@ public class RenderUtils { GlStateManager.enableTexture2D(); GlStateManager.enableCull(); - GlStateManager.popAttrib(); + GlStateManager.popMatrix(); } @@ -578,7 +578,7 @@ public class RenderUtils { double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks); GlStateManager.pushMatrix(); - GlStateManager.pushAttrib(); + GlStateManager.translate(-x_fix, -y_fix, -z_fix); GlStateManager.disableLighting(); @@ -638,7 +638,7 @@ public class RenderUtils { GlStateManager.disableBlend(); GlStateManager.enableLighting(); GlStateManager.popMatrix(); - GlStateManager.popAttrib(); + //... @@ -653,7 +653,7 @@ public class RenderUtils { double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks); GlStateManager.pushMatrix(); - GlStateManager.pushAttrib(); + GlStateManager.translate(-x_fix, -y_fix, -z_fix); GlStateManager.disableLighting(); @@ -731,7 +731,7 @@ public class RenderUtils { GlStateManager.disableBlend(); GlStateManager.enableLighting(); GlStateManager.popMatrix(); - GlStateManager.popAttrib(); + } public static void highlightBox(Entity entity, AxisAlignedBB axisAlignedBB, Color c, float partialTicks, boolean depth) { @@ -742,7 +742,7 @@ public class RenderUtils { double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks); GlStateManager.pushMatrix(); - GlStateManager.pushAttrib(); + GlStateManager.translate(-x_fix, -y_fix, -z_fix); GlStateManager.disableLighting(); @@ -819,7 +819,7 @@ public class RenderUtils { GlStateManager.disableBlend(); GlStateManager.enableLighting(); GlStateManager.popMatrix(); - GlStateManager.popAttrib(); + } public static void highlightBox(Entity entity, Color c, float partialTicks, boolean depth) { Entity viewing_from = Minecraft.getMinecraft().getRenderViewEntity(); @@ -829,7 +829,7 @@ public class RenderUtils { double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks); GlStateManager.pushMatrix(); - GlStateManager.pushAttrib(); + GlStateManager.translate(-x_fix, -y_fix, -z_fix); GlStateManager.disableLighting(); @@ -905,7 +905,7 @@ public class RenderUtils { GlStateManager.disableBlend(); GlStateManager.enableLighting(); GlStateManager.popMatrix(); - GlStateManager.popAttrib(); + //... @@ -920,7 +920,7 @@ public class RenderUtils { double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks); GlStateManager.pushMatrix(); - GlStateManager.pushAttrib(); + GlStateManager.translate(-x_fix, -y_fix, -z_fix); GlStateManager.disableLighting(); @@ -999,7 +999,7 @@ public class RenderUtils { GlStateManager.disableBlend(); GlStateManager.enableLighting(); GlStateManager.popMatrix(); - GlStateManager.popAttrib(); + //... -- cgit