Skip to content

Commit 95d75e8

Browse files
committed
Cleanup, hopefully make it compatible on 1.18 and above
1 parent 15503de commit 95d75e8

File tree

7 files changed

+36
-24
lines changed

7 files changed

+36
-24
lines changed

src/main/java/dev/xirreal/Activity.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,23 @@ public class Activity extends Structure {
99
public int type;
1010
public String description;
1111

12+
public String getType() {
13+
return switch (type) {
14+
case ActivityType.NGFX_INJECTION_ACTIVITY_UNKNOWN -> "NGFX_INJECTION_ACTIVITY_UNKNOWN";
15+
case ActivityType.NGFX_INJECTION_ACTIVITY_FRAME_DEBUGGER -> "NGFX_INJECTION_ACTIVITY_FRAME_DEBUGGER";
16+
case ActivityType.NGFX_INJECTION_ACTIVITY_GENERATE_CPP_CAPTURE -> "NGFX_INJECTION_ACTIVITY_GENERATE_CPP_CAPTURE";
17+
case ActivityType.NGFX_INJECTION_ACTIVITY_GPU_TRACE -> "NGFX_INJECTION_ACTIVITY_GPU_TRACE";
18+
case ActivityType.NGFX_INJECTION_ACTIVITY_PYLON_CAPTURE -> "NGFX_INJECTION_ACTIVITY_PYLON_CAPTURE";
19+
default -> "Unknown Activity";
20+
};
21+
}
1222

13-
public static interface ActivityType {
23+
public interface ActivityType {
1424
int NGFX_INJECTION_ACTIVITY_UNKNOWN = 0;
15-
1625
int NGFX_INJECTION_ACTIVITY_FRAME_DEBUGGER = 1;
1726
int NGFX_INJECTION_ACTIVITY_GENERATE_CPP_CAPTURE = 3;
1827
int NGFX_INJECTION_ACTIVITY_GPU_TRACE = 4;
1928
int NGFX_INJECTION_ACTIVITY_PYLON_CAPTURE = 5;
20-
2129
}
2230

2331
@Override

src/main/java/dev/xirreal/Installation.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,23 @@ public class Installation extends Structure {
1212
public short versionPatch;
1313
public String installationPath;
1414

15-
public static String getSKU(Installation installation) {
16-
return switch (installation.sku) {
17-
case 0 -> "NGFX_NSIGHT_SKU_UNKNOWN";
18-
case 1 -> "NGFX_NSIGHT_SKU_PUBLIC";
19-
case 2 -> "NGFX_NSIGHT_SKU_PRO";
20-
case 3 -> "NGFX_NSIGHT_SKU_INTERNAL";
21-
default -> "Unknown";
15+
public String getSku() {
16+
return switch (sku) {
17+
case SkuType.NGFX_NSIGHT_SKU_UNKNOWN -> "NGFX_NSIGHT_SKU_UNKNOWN";
18+
case SkuType.NGFX_NSIGHT_SKU_PUBLIC -> "NGFX_NSIGHT_SKU_PUBLIC";
19+
case SkuType.NGFX_NSIGHT_SKU_PRO -> "NGFX_NSIGHT_SKU_PRO";
20+
case SkuType.NGFX_NSIGHT_SKU_INTERNAL -> "NGFX_NSIGHT_SKU_INTERNAL";
21+
default -> "Unknown SKU";
2222
};
2323
}
2424

25+
public interface SkuType {
26+
int NGFX_NSIGHT_SKU_UNKNOWN = 0;
27+
int NGFX_NSIGHT_SKU_PUBLIC = 1;
28+
int NGFX_NSIGHT_SKU_PRO = 2;
29+
int NGFX_NSIGHT_SKU_INTERNAL = 3;
30+
}
31+
2532
@Override
2633
protected List<String> getFieldOrder() {
2734
return Arrays.asList("sku", "versionMajor", "versionMinor", "versionPatch", "installationPath");

src/main/java/dev/xirreal/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void onInitialize() {
7676
LOGGER.error("Frame debugger is not available for this installation");
7777
return;
7878
}
79-
79+
LOGGER.info("Found activity " + activity.getType() + ": "+ activity.description);
8080
Result result = ngfx.Inject(newestInstallation, activity);
8181
LOGGER.info("Injection result: " + result);
8282
} catch (Exception e) {

src/main/java/dev/xirreal/NGFX.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
package dev.xirreal;
22

33
import com.sun.jna.Native;
4-
import com.sun.jna.Structure;
54
import com.sun.jna.ptr.IntByReference;
6-
import com.sun.jna.ptr.PointerByReference;
75

6+
import java.io.File;
87
import java.io.IOException;
98
import java.util.List;
109

1110
public class NGFX implements NativeNGFX {
1211
private final NativeNGFX _native;
1312

1413
public NGFX(final String dllPath) throws IOException {
15-
if(!new java.io.File(dllPath).exists()) {
14+
if(!new File(dllPath).exists()) {
1615
throw new IOException("DLL not found: " + dllPath);
1716
}
1817

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
package dev.xirreal;
22

33
import com.sun.jna.Library;
4-
import com.sun.jna.Structure;
54
import com.sun.jna.ptr.IntByReference;
6-
import com.sun.jna.ptr.PointerByReference;
75

86
public interface NativeNGFX extends Library {
9-
public int NGFX_Injection_EnumerateInstallations(IntByReference pCount, Installation[] pInstallations);
10-
public int NGFX_Injection_EnumerateActivities(Installation pInstallation, IntByReference pCount, Activity[] pActivities);
11-
public int NGFX_Injection_InjectToProcess(Installation pInstallation, Activity pActivity);
7+
int NGFX_Injection_EnumerateInstallations(IntByReference pCount, Installation[] pInstallations);
8+
int NGFX_Injection_EnumerateActivities(Installation pInstallation, IntByReference pCount, Activity[] pActivities);
9+
int NGFX_Injection_InjectToProcess(Installation pInstallation, Activity pActivity);
1210
}

src/main/java/dev/xirreal/Result.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package dev.xirreal;
22

33
public class Result {
4-
int code = 0;
5-
String message = "";
4+
int code;
5+
String message;
66

77
public Result(int code) {
88
this.code = code;

src/main/resources/fabric.mod.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"contact": {
1111
"sources": "https://github.com/xirreal/nsight-loader"
1212
},
13-
"license": "MIT",
13+
"license": "MIT & NVIDIA license",
1414
"icon": "assets/nsight-loader/icon.png",
1515
"environment": "*",
1616
"entrypoints": {
@@ -20,7 +20,7 @@
2020
},
2121
"depends": {
2222
"fabricloader": ">=0.15.10",
23-
"minecraft": "~1.20.4",
24-
"java": ">=21"
23+
"minecraft": "^1.18.2",
24+
"java": ">=17"
2525
}
2626
}

0 commit comments

Comments
 (0)