Skip to content

Commit

Permalink
Hopefully Fixed Hotswap Crashes + Version Bump
Browse files Browse the repository at this point in the history
  • Loading branch information
hammy275 committed Jan 14, 2024
1 parent 4127487 commit 66dc744
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions common/src/main/java/net/blf02/vrapi/client/VRDataGrabber.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ public static VRPlayer getVRPlayer(PlayerType type) {

try {
Object vrPlayerRaw = VRPlayer_GET.invoke(null); // Get our "VRPlayer" from Vivecraft}
// In case we switch out of VR after the !inVR() check
if (vrPlayerRaw == null) {
return null;
}
Object vrDataRaw;
// Get the "VRData" from Vivecraft
switch (type) {
Expand All @@ -134,6 +138,11 @@ public static VRPlayer getVRPlayer(PlayerType type) {
default -> vrDataRaw = VRPlayer_vrdata_world_post.get(vrPlayerRaw); // Covers POST and null
}

// In case we switch out of VR after the !inVR() check
if (vrDataRaw == null) {
return null;
}


Object hmdDevicePoseRaw = VRData_hmd.get(vrDataRaw); // Get the VRDevicePose for the HMD
Object c0DevicePoseRaw = VRData_c0.get(vrDataRaw);
Expand Down Expand Up @@ -173,6 +182,9 @@ public static VRPlayer getVRPlayer(PlayerType type) {
// We shouldn't error here, as we know these fields and methods exist due to getField() and getMethod()
// combined with having access to Vivecraft's codebase on GitHub
throw new RuntimeException("Could not obtain data from Vivecraft! Something has gone horribly wrong.");
} catch (NullPointerException ignored) {
// In case something returns null after the inVR() check due to hotswap.
return null;
}
}

Expand Down
2 changes: 1 addition & 1 deletion common/src/main/java/net/blf02/vrapi/common/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
public class Constants {

// Version {major, minor, patch}
public static final int[] version = new int[]{3, 0, 6};
public static final int[] version = new int[]{3, 0, 7};

// Debugging
public static final boolean doDebugging = false;
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ minecraft_version=1.19.2
enabled_platforms=quilt,fabric,forge

archives_base_name=vrapi
mod_version=3.0.6
mod_version=3.0.7
maven_group=net.blf02.vrapi

architectury_version=6.2.43
Expand Down

0 comments on commit 66dc744

Please sign in to comment.