diff options
author | syeyoung <cyong06@naver.com> | 2021-08-05 12:35:15 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-08-05 12:46:35 +0900 |
commit | f10046f075efd7e17336a7b4629d446283b5c953 (patch) | |
tree | 09949c1dbf309c66fbfbde6765b0da4a8ebbdf7b /src/main/java/kr/syeyoung/dungeonsguide/utils | |
parent | 468463272411cec70554aed1c96a60beea38f14a (diff) | |
download | Skyblock-Dungeons-Guide-f10046f075efd7e17336a7b4629d446283b5c953.tar.gz Skyblock-Dungeons-Guide-f10046f075efd7e17336a7b4629d446283b5c953.tar.bz2 Skyblock-Dungeons-Guide-f10046f075efd7e17336a7b4629d446283b5c953.zip |
- Remove GlStateManager.pushAttrib, which causes .... a lot of problems
= Black screen hopefully fixed?
- Mechanic Browser Rewrite
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/utils')
-rw-r--r-- | src/main/java/kr/syeyoung/dungeonsguide/utils/GlStateUtils.java | 69 | ||||
-rwxr-xr-x | src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java | 24 |
2 files changed, 81 insertions, 12 deletions
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 <https://www.gnu.org/licenses/>. + */ + +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<String, Object> dumpStates() { + Map<String, Object> 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<String, Object> dump) { + for (Map.Entry<String, Object> stringObjectEntry : dump.entrySet()) { + System.out.println(stringObjectEntry+": "+stringObjectEntry.getValue()); + } + } + + public static void compareDump(Map<String, Object> dump1, Map<String,Object> dump2) { + Set<String> 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<String, Object> 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(); + //... |