Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minecraft 1.21 #2549

Merged
merged 10 commits into from
Jun 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix proxy method matching
octylFractal committed Jun 15, 2024
commit f5875b89249bf2ad598b60ac1f1a294bdb450795
Original file line number Diff line number Diff line change
@@ -128,7 +128,9 @@ private static void addMethodHandleToTable(
MethodHandle spreader = methodHandle.asSpreader(
1, Object[].class, methodHandle.type().parameterCount() - 1
);
table.put(methodName, methodHandle.type(), spreader);
// We drop the first argument, which is our receiver
// We also drop the return type, which is not important
table.put(methodName, methodHandle.type().dropParameterTypes(0, 1).changeReturnType(void.class), spreader);
}

private static final Table<String, MethodType, MethodHandle> METHOD_MAP;
@@ -221,7 +223,8 @@ private static void addMethodHandleToTable(
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
MethodHandle delegate = METHOD_MAP.get(
method.getName(), MethodType.methodType(method.getReturnType(), method.getParameterTypes())
// ignore return type, we only need the parameter types
method.getName(), MethodType.methodType(void.class, method.getParameterTypes())
);
if (delegate != null) {
return delegate.invoke(this, args);