mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-25 04:04:25 +00:00
Support 1.20.2. (#266)
This commit is contained in:
1 parent
d5ae6226ae
commit
b8ca913848
27 files changed
+830
-446
No files matched your search
@@ -1,11 +1,17 @@
|
||||
package customskinloader.utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.authlib.yggdrasil.response.MinecraftTexturesPayload;
|
||||
import customskinloader.CustomSkinLoader;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class TextureUtil {
|
||||
/**
|
||||
* Save and get fake url of base64 texture
|
||||
@@ -30,4 +36,42 @@ public class TextureUtil {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Some of the classes in Authlib used after Minecraft 23w31a were changed to record classes,
|
||||
// resulting in changes to method names, so reflection is used here to be compatible with these changes.
|
||||
private final static Field VALUE_FIELD;
|
||||
private final static Field TEXTURES_FIELD;
|
||||
|
||||
static {
|
||||
try {
|
||||
VALUE_FIELD = Property.class.getDeclaredField("value");
|
||||
VALUE_FIELD.setAccessible(true);
|
||||
TEXTURES_FIELD = MinecraftTexturesPayload.class.getDeclaredField("textures");
|
||||
TEXTURES_FIELD.setAccessible(true);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getPropertyValue(Property property) {
|
||||
try {
|
||||
return (String) VALUE_FIELD.get(property);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> getMinecraftTexturesPayloadTextures(MinecraftTexturesPayload payload) {
|
||||
try {
|
||||
return (Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>) TEXTURES_FIELD.get(payload);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String fromUUID(UUID value) {
|
||||
return value.toString().replace("-", "");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user