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

fix 1.20.2 can not view skin #226

Closed
wants to merge 4 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
public class YggdrasilKeyTransformUnit implements TransformUnit {

public static final List<PublicKey> PUBLIC_KEYS = new CopyOnWriteArrayList<>();
private boolean isSignature = false;

static {
PUBLIC_KEYS.add(loadMojangPublicKey());
Expand Down Expand Up @@ -139,6 +140,9 @@ public Optional<ClassVisitor> transform(ClassLoader classLoader, String classNam
return Optional.of(new ClassVisitor(ASM9, writer) {
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
if ("signature".equals(name)) {
xmdhs marked this conversation as resolved.
Show resolved Hide resolved
isSignature = true;
}
if ("isSignatureValid".equals(name) && "(Ljava/security/PublicKey;)Z".equals(desc)) {
ctx.markModified();

Expand Down Expand Up @@ -170,9 +174,9 @@ public MethodVisitor visitMethod(int access, String name, String desc, String si
MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
mv.visitCode();
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(INVOKEVIRTUAL, "com/mojang/authlib/properties/Property", "getValue", "()Ljava/lang/String;", false);
mv.visitMethodInsn(INVOKEVIRTUAL, "com/mojang/authlib/properties/Property", isSignature ? "value" : "getValue", "()Ljava/lang/String;", false);
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(INVOKEVIRTUAL, "com/mojang/authlib/properties/Property", "getSignature", "()Ljava/lang/String;", false);
mv.visitMethodInsn(INVOKEVIRTUAL, "com/mojang/authlib/properties/Property", isSignature ? "signature" : "getSignature", "()Ljava/lang/String;", false);
ctx.invokeCallback(mv, YggdrasilKeyTransformUnit.class, "verifyPropertySignature");
mv.visitInsn(IRETURN);
mv.visitMaxs(-1, -1);
Expand Down