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/GlStateUtils.java | |
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/GlStateUtils.java')
-rw-r--r-- | src/main/java/kr/syeyoung/dungeonsguide/utils/GlStateUtils.java | 69 |
1 files changed, 69 insertions, 0 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()); + } + } + } +} |