Skip to content

Commit

Permalink
Merge branch 'Nolij:dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysdh540 authored Feb 4, 2024
2 parents 4ec6065 + 3b243db commit a612a4c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- made jar smaller (thanks @rdh)
- made jar smaller (thanks @rdh)
- fixed zoom scrolling on LexForge 20.2+
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ org.gradle.parallel=true
org.gradle.caching=true
org.gradle.configuration-cache=false

mod_version = 0.13.1-dev.1
mod_version = 0.13.1-dev.2
maven_group = dev.nolij
archives_base_name = zume
mod_name = Zume
Expand Down
34 changes: 32 additions & 2 deletions lexforge/src/main/java/dev/nolij/zume/lexforge/LexZume.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import net.minecraftforge.fml.loading.FMLPaths;

import java.io.File;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Method;

@Mod(Zume.MOD_ID)
@OnlyIn(Dist.CLIENT)
Expand Down Expand Up @@ -85,9 +88,36 @@ private void calculateFOV(ViewportEvent.ComputeFov event) {
}
}

private static final MethodHandle getScrollDelta;

static {
final MethodHandles.Lookup lookup = MethodHandles.lookup();
Method method;
try {
method = InputEvent.MouseScrollingEvent.class.getMethod("getScrollDelta");
} catch (NoSuchMethodException ignored) {
try {
//noinspection JavaReflectionMemberAccess
method = InputEvent.MouseScrollingEvent.class.getMethod("getDeltaY");
} catch (NoSuchMethodException e) {
throw new AssertionError(e);
}
}
try {
getScrollDelta = lookup.unreflect(method);
} catch (IllegalAccessException e) {
throw new AssertionError(e);
}
}

private void onMouseScroll(InputEvent.MouseScrollingEvent event) {
final int scrollAmount = (int) event.getScrollDelta();
if (scrollAmount != 0 &&
final int scrollAmount;
try {
scrollAmount = (int) (double) getScrollDelta.invokeExact(event);
} catch (Throwable e) {
throw new AssertionError(e);
}
if (scrollAmount != 0 &&
Zume.interceptScroll(scrollAmount)) {
event.setCanceled(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public String getModId() {
public Function<Screen, ? extends Screen> getConfigScreenFactory() {
return (parent) -> {
try {
return new ModernZumeConfigScreen((Text) LITERALTEXT_INIT.invoke(""), parent, true);
return new ModernZumeConfigScreen((Text) LITERALTEXT_INIT.invokeExact(""), parent, true);
} catch (Throwable e) {
Zume.LOGGER.error("Error opening config screen: ", e);
return null;
Expand Down

0 comments on commit a612a4c

Please sign in to comment.