Skip to content

Commit

Permalink
fix NeoForge 20.6 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
Nolij committed Jun 11, 2024
1 parent 9f3da72 commit 349de9e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions neoforge/src/main/java/dev/nolij/zume/neoforge/NeoZume.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,20 @@ private void onMouseScroll(InputEvent.MouseScrollingEvent event) {
}
}

@SuppressWarnings("DataFlowIssue")
private static final MethodHandle GET_DISTANCE =
METHOD_HANDLE_HELPER.getMethodOrNull(CalculateDetachedCameraDistanceEvent.class, "getDistance")
.asType(MethodType.methodType(double.class, CalculateDetachedCameraDistanceEvent.class));

@SuppressWarnings("DataFlowIssue")
private static final MethodHandle SET_DISTANCE = MethodHandleHelper.firstNonNull(
METHOD_HANDLE_HELPER.getMethodOrNull(CalculateDetachedCameraDistanceEvent.class, "setDistance", float.class),
METHOD_HANDLE_HELPER.getMethodOrNull(CalculateDetachedCameraDistanceEvent.class, "setDistance", double.class)
).asType(MethodType.methodType(void.class, CalculateDetachedCameraDistanceEvent.class, float.class));
).asType(MethodType.methodType(void.class, CalculateDetachedCameraDistanceEvent.class, double.class));

private void calculateDetachedCameraDistance(CalculateDetachedCameraDistanceEvent event) {
try {
SET_DISTANCE.invokeExact(event, (float) Zume.thirdPersonCameraHook(event.getDistance()));
SET_DISTANCE.invokeExact(event, (double) Zume.thirdPersonCameraHook((double) GET_DISTANCE.invokeExact(event)));
} catch (Throwable e) {
throw new AssertionError(e);
}
Expand Down

0 comments on commit 349de9e

Please sign in to comment.