diff --git a/common/src/main/java/net/blf02/vrapi/client/VRDataGrabber.java b/common/src/main/java/net/blf02/vrapi/client/VRDataGrabber.java index 6a01b13..95dc6c7 100644 --- a/common/src/main/java/net/blf02/vrapi/client/VRDataGrabber.java +++ b/common/src/main/java/net/blf02/vrapi/client/VRDataGrabber.java @@ -63,12 +63,24 @@ public static void init() { Matrix4f_toFloatBuffer = getMethod(ReflectionConstants.Matrix4f, "toFloatBuffer"); - Minecraft_vr = getField(Minecraft.class, "vr"); - Minecraft_vr_Instance = Minecraft_vr.get(Minecraft.getInstance()); + Object vrHolder; + + try { + Minecraft_vr = getField(Minecraft.class, "vr"); + vrHolder = Minecraft.getInstance(); + } catch (RuntimeException e) { + Class ClientDataHolder = Class.forName(ReflectionConstants.VIVECRAFT_PACKAGE + ".ClientDataHolder"); + Method getCDHInstance = getMethod(ClientDataHolder, "getInstance"); + Object cdhInstance = getCDHInstance.invoke(null); + Minecraft_vr = getField(ClientDataHolder, "vr"); + vrHolder = cdhInstance; + } + + Minecraft_vr_Instance = Minecraft_vr.get(vrHolder); MCVR_triggerHapticPulse = getMethod(ReflectionConstants.MCVR, "triggerHapticPulse", ReflectionConstants.ControllerType, float.class, float.class, float.class, float.class); - } catch (IllegalAccessException e) { + } catch (IllegalAccessException | ClassNotFoundException | InvocationTargetException e) { VRAPIMod.LOGGER.log(Level.SEVERE, "Error: " + e.getMessage()); throw new RuntimeException("Fatal error! Could not get! Please report this, along with the error message above!"); } diff --git a/common/src/main/java/net/blf02/vrapi/common/Constants.java b/common/src/main/java/net/blf02/vrapi/common/Constants.java index 68799cb..5c89231 100644 --- a/common/src/main/java/net/blf02/vrapi/common/Constants.java +++ b/common/src/main/java/net/blf02/vrapi/common/Constants.java @@ -6,7 +6,7 @@ public class Constants { public static final int[] version = new int[]{2, 0, 0}; // Debugging - public static final boolean doDebugging = true; + public static final boolean doDebugging = false; public static String getVersion() { return version[0] + "." + version[1] + "." + version[2];