Skip to content

Commit

Permalink
do it more cleanly
Browse files Browse the repository at this point in the history
  • Loading branch information
Nolij committed Jun 11, 2024
1 parent 349de9e commit c947971
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions neoforge/src/main/java/dev/nolij/zume/neoforge/NeoZume.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,11 @@ 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));
private static final MethodHandle GET_DISTANCE = METHOD_HANDLE_HELPER.getMethodOrNull(
CalculateDetachedCameraDistanceEvent.class,
"getDistance",
MethodType.methodType(double.class, CalculateDetachedCameraDistanceEvent.class)
);

@SuppressWarnings("DataFlowIssue")
private static final MethodHandle SET_DISTANCE = MethodHandleHelper.firstNonNull(
Expand All @@ -200,6 +201,7 @@ private void onMouseScroll(InputEvent.MouseScrollingEvent event) {

private void calculateDetachedCameraDistance(CalculateDetachedCameraDistanceEvent event) {
try {
//noinspection DataFlowIssue
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 c947971

Please sign in to comment.