diff --git a/src/main/java/grondag/canvas/compat/ClassInspector.java b/src/main/java/grondag/canvas/compat/ClassInspector.java new file mode 100644 index 000000000..f53f10f68 --- /dev/null +++ b/src/main/java/grondag/canvas/compat/ClassInspector.java @@ -0,0 +1,33 @@ +package grondag.canvas.compat; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +import net.minecraft.client.render.WorldRenderer; + +import grondag.canvas.CanvasMod; + +public class ClassInspector { + public static void inspect() { + final Class clazz = WorldRenderer.class; + + CanvasMod.LOG.info(""); + CanvasMod.LOG.info("WorldRenderer Class Summary - For Developer Use"); + CanvasMod.LOG.info("============================================="); + CanvasMod.LOG.info(""); + CanvasMod.LOG.info("FIELDS"); + + for(final Field f : clazz.getDeclaredFields()) { + CanvasMod.LOG.info(f.toGenericString()); + } + + CanvasMod.LOG.info(""); + CanvasMod.LOG.info("METHODS"); + + for(final Method m : clazz.getDeclaredMethods()) { + CanvasMod.LOG.info(m.toGenericString()); + } + + CanvasMod.LOG.info(""); + } +} diff --git a/src/main/java/grondag/canvas/compat/CsbHolder.java b/src/main/java/grondag/canvas/compat/CsbHolder.java new file mode 100644 index 000000000..c707aefdb --- /dev/null +++ b/src/main/java/grondag/canvas/compat/CsbHolder.java @@ -0,0 +1,70 @@ +//package grondag.canvas.compat; +// +//import java.lang.invoke.MethodHandle; +//import java.lang.invoke.MethodHandles; +//import java.lang.reflect.Method; +// +//import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +// +//import net.minecraft.client.render.Camera; +//import net.minecraft.client.render.GameRenderer; +//import net.minecraft.client.render.LightmapTextureManager; +//import net.minecraft.client.render.VertexConsumerProvider; +//import net.minecraft.client.render.WorldRenderer; +//import net.minecraft.client.util.math.MatrixStack; +//import net.minecraft.util.math.Matrix4f; +//import net.minecraft.util.math.Vec3d; +//import net.minecraft.util.profiler.Profiler; +// +//import net.fabricmc.loader.api.FabricLoader; +// +//import grondag.canvas.CanvasMod; +// +// TODO: On hold until have response to CSB #20 + +//public class CsbHolder { +// private static boolean warnRender = true; +// +// public static CsbRender handler = (MatrixStack matrices, float delta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f matrix4f, CallbackInfo ci) -> {}; +// +// static { +// if (FabricLoader.getInstance().isModLoaded("dynocaps")) { +// +// final MethodHandles.Lookup lookup = MethodHandles.lookup(); +// +// try { +// final Class clazz = WorldRenderer.class; +// +// Method render = null; +// +// final Method render = clazz.getDeclaredMethod("handler$zeh000$renderWorldBorder", MatrixStack.class, float.class, long.class, boolean.class, Camera.class, GameRenderer.class, LightmapTextureManager.class, Matrix4f.class, CallbackInfo.class); +// final MethodHandle renderHandler = lookup.unreflect(render); +// +// handler = (profiler, matrixStack, immediate, camPos) -> { +// try { +// profiler.swap("dynocaps"); +// renderHandler.invokeExact(matrixStack, immediate, 1, camPos); +// } catch (final Throwable e) { +// if (warnRender) { +// CanvasMod.LOG.warn("Unable to call DynoCaps BoxRenderer.render hook due to exception:", e); +// CanvasMod.LOG.warn("Subsequent errors will be suppressed"); +// warnRender = false; +// } +// } +// }; +// +// CanvasMod.LOG.info("Found DynoCaps - compatibility hook enabled"); +// } catch (final Exception e) { +// CanvasMod.LOG.warn("Unable to find DynoCaps render hook due to exception:", e); +// } +// } +// } +// +// public interface CsbRender { +// void render(MatrixStack matrices, float delta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f matrix4f, CallbackInfo ci); +// } +// +// +// private void net.minecraft.class_761.handler$zeh000$renderWorldBorder(net.minecraft.class_4587,float,long,boolean,net.minecraft.class_4184,net.minecraft.class_757,net.minecraft.class_765,net.minecraft.class_1159,org.spongepowered.asm.mixin.injection.callback.CallbackInfo) +// +//} diff --git a/src/main/java/grondag/canvas/render/CanvasWorldRenderer.java b/src/main/java/grondag/canvas/render/CanvasWorldRenderer.java index 3535bd2a3..ead1d1c94 100644 --- a/src/main/java/grondag/canvas/render/CanvasWorldRenderer.java +++ b/src/main/java/grondag/canvas/render/CanvasWorldRenderer.java @@ -1066,6 +1066,8 @@ public void reload() { renderRegionStorage.clear(); terrainOccluder.invalidate(); visibleRegionCount = 0; + + //ClassInspector.inspect(); } @Override