mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-25 04:04:25 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5ebee1f1e0 | ||
|
|
1eb8db550f | ||
|
|
52a232f982 | ||
|
|
eeebc30b58 | ||
|
|
46bccadca2 | ||
|
|
d7f207177c | ||
|
|
339e30247a | ||
|
|
ba8d86789d | ||
|
|
a9f19cfc8d | ||
|
|
8b1400ef0d | ||
|
|
82c2e80e76 | ||
|
|
8146773354 | ||
|
|
5ac6aa1865 | ||
|
|
dab8e3dd22 | ||
|
|
fdceb08a2c | ||
|
|
ad846f37a2 | ||
|
|
b8ce13606b | ||
|
|
2fbd3965e0 | ||
|
|
a714670b9a | ||
|
|
c5460624e3 | ||
|
|
9f63a770c3 | ||
|
|
4d234762d2 | ||
|
|
730b565c59 | ||
|
|
4d12d70bf0 | ||
|
|
42adcb5b27 | ||
|
|
77ddcc8bf5 | ||
|
|
d46adaac5e | ||
|
|
a6666b53a1 | ||
|
|
958860ecce | ||
|
|
6fab945eb1 | ||
|
|
e19b9d860f | ||
|
|
7adb0f9ef7 | ||
|
|
1bb130bb87 | ||
|
|
779e25f837 | ||
|
|
3a2d8f9caf | ||
|
|
0c91fb3975 | ||
|
|
290cbb63d8 | ||
|
|
100e661ac5 | ||
|
|
c490631f2c | ||
|
|
c519d09be4 | ||
|
|
e5a31ae49e | ||
|
|
68615ba724 | ||
|
|
10e57fe349 | ||
|
|
9f70ad0159 | ||
|
|
0d5538a110 | ||
|
|
27efbbfeb0 | ||
|
|
7fad8c602d | ||
|
|
29a0952bc4 | ||
|
|
b7107b7172 | ||
|
|
2adbc25f69 | ||
|
|
3bee9281ec | ||
|
|
917f9f650b | ||
|
|
edf6e241e4 | ||
|
|
d2c65f00c9 | ||
|
|
95ee345441 | ||
|
|
3ade4867d4 | ||
|
|
2d1951774d | ||
|
|
cc3616a074 | ||
|
|
42c48c5c2e | ||
|
|
030daf12a2 | ||
|
|
88763d64ef | ||
|
|
4f2b5edf84 | ||
|
|
cbe07b9003 | ||
|
|
b2867a0dbf | ||
|
|
65dacd8527 | ||
|
|
d2d425e96e | ||
|
|
0762e3e339 | ||
|
|
4cb1e348bb | ||
|
|
7bbfd19bfd | ||
|
|
be8b80bd55 | ||
|
|
47de6d3a89 | ||
|
|
f78a3b2565 | ||
|
|
016249c6ca | ||
|
|
860edd2e1a | ||
|
|
3e6e444857 | ||
|
|
d67b7c6296 | ||
|
|
94f6044c9a | ||
|
|
6b3531964e | ||
|
|
fbd06f147a | ||
|
|
e3020dad00 | ||
|
|
49fb976a2c | ||
|
|
78bc4b5f7e | ||
|
|
7a3dc4f9c2 | ||
|
|
2087f7bb94 | ||
|
|
e95edb16ac | ||
|
|
3b07b5ccca | ||
|
|
a3fb3cd770 | ||
|
|
b7b59c0b85 | ||
|
|
db6b54732e | ||
|
|
09e3b81552 | ||
|
|
2f494d295e | ||
|
|
e8e3a72ae7 | ||
|
|
ca8bd4e83d | ||
|
|
d789119c8f | ||
|
|
bfd1b41ecc | ||
|
|
5807acb34a | ||
|
|
f319d535ae | ||
|
|
f669d095b6 | ||
|
|
ca8b0ba185 | ||
|
|
7acef4d987 | ||
|
|
79404f659c | ||
|
|
85c86ff375 | ||
|
|
f4030701ee | ||
|
|
a36eca2a53 | ||
|
|
6ffdf2aafb | ||
|
|
fba9f7ca28 | ||
|
|
2d157e3d5b | ||
|
|
055aef17db | ||
|
|
622e834d26 | ||
|
|
469c8b62a9 | ||
|
|
1558ec819a | ||
|
|
883e7b45fc | ||
|
|
f30d3319b0 | ||
|
|
58276a7a0c | ||
|
|
883fb39380 | ||
|
|
1358a99f51 | ||
|
|
47ea01dc39 | ||
|
|
ee36f2f42a | ||
|
|
5868a39adb | ||
|
|
f7e000cb82 | ||
|
|
c40bb38e20 | ||
|
|
4449ccdd45 | ||
|
|
67e56957e7 | ||
|
|
ea432f2405 | ||
|
|
eee978fc83 | ||
|
|
9698d4098a | ||
|
|
3f779c9028 | ||
|
|
3945599fb4 | ||
|
|
b50e6a934f | ||
|
|
3dbf812f50 | ||
|
|
2bb8da3ff9 | ||
|
|
1371e7685e | ||
|
|
a49fea706d | ||
|
|
32547481e7 | ||
|
|
faff465ace | ||
|
|
e487ab1147 | ||
|
|
e26bc85f46 | ||
|
|
7dc2c45600 | ||
|
|
d6281881a5 | ||
|
|
7cdd582ed4 | ||
|
|
129b50a6c2 | ||
|
|
eaf9c5f48f | ||
|
|
b7e5c59ecf | ||
|
|
05e98d6eee | ||
|
|
f4b7393b44 | ||
|
|
898a4fe7d9 | ||
|
|
5cbfb87d08 | ||
|
|
8cdabb762d | ||
|
|
4369ddf43e | ||
|
|
8a1dca0dd4 | ||
|
|
b533d33f71 | ||
|
|
bfaa97ba04 | ||
|
|
c86790371d | ||
|
|
ed4bf8dbb3 | ||
|
|
b97f838d59 | ||
|
|
79440740ee | ||
|
|
481b0d9df9 | ||
|
|
cdd42d60e3 | ||
|
|
76bf0b5fdf | ||
|
|
f1c1f2f39a | ||
|
|
3c4b1cc4e2 | ||
|
|
e2258b1540 | ||
|
|
d286e419c5 | ||
|
|
28eb5eb376 | ||
|
|
4d34720d1c | ||
|
|
b9456d599f | ||
|
|
0233b7e077 | ||
|
|
a917e67871 | ||
|
|
ea49e7489a | ||
|
|
bcf5dc4cea | ||
|
|
7e522011e7 | ||
|
|
bdead01ef9 | ||
|
|
87a40fc3c7 | ||
|
|
0d60fb328a | ||
|
|
2f141bd565 | ||
|
|
a7f52365ca | ||
|
|
10ec669589 | ||
|
|
f09fe38831 | ||
|
|
953748f2ae | ||
|
|
e63858d561 | ||
|
|
b2d6532709 | ||
|
|
d2db775a17 | ||
|
|
7cf42be31c | ||
|
|
9a85d18f22 | ||
|
|
5d366d1d8c | ||
|
|
8257d6dfd0 | ||
|
|
1c973e633b | ||
|
|
933244a492 | ||
|
|
e719e9cd4e | ||
|
|
25c864b11b | ||
|
|
d60d9d4c36 | ||
|
|
a2698b5b95 | ||
|
|
b14be41789 | ||
|
|
cf4487f4d3 | ||
|
|
23f301c819 | ||
|
|
958023382d | ||
|
|
037ef06379 | ||
|
|
ad8c356c46 | ||
|
|
c9181c411f | ||
|
|
164632c7be | ||
|
|
7af9df3177 | ||
|
|
37960965b4 | ||
|
|
10c0536dbe | ||
|
|
aaf23aa88a | ||
|
|
8bbb9b1ee9 | ||
|
|
8c1cfa330e | ||
|
|
ff83d7f709 | ||
|
|
e05ee65d19 | ||
|
|
9a39e38ba1 | ||
|
|
7a7b9418d3 | ||
|
|
b08122913b | ||
|
|
bbc355365a | ||
|
|
8bccab4f0b | ||
|
|
1d88a98040 | ||
|
|
7314a08268 | ||
|
|
5c12463c94 | ||
|
|
b34a5b3343 | ||
|
|
7654dc583d | ||
|
|
4e78285bbe | ||
|
|
fe8c556e35 | ||
|
|
ffbe66193d | ||
|
|
fccacc6f98 | ||
|
|
e27c3ecd68 | ||
|
|
11d7d53684 | ||
|
|
fa97359eeb | ||
|
|
1540ecfa8d | ||
|
|
b27654dfe9 | ||
|
|
db10725c31 | ||
|
|
946d6901ea | ||
|
|
3054cc6a13 | ||
|
|
8f73eed29d | ||
|
|
a16c4a7b44 | ||
|
|
fcb24315e5 | ||
|
|
47f198b337 | ||
|
|
a38aa9687c | ||
|
|
0857a80ca8 | ||
|
|
704f3a4102 | ||
|
|
4ebce88594 | ||
|
|
8fa3a567ac | ||
|
|
5a29416ee9 | ||
|
|
4142609635 | ||
|
|
1dbfa30ba8 | ||
|
|
199c5d674e | ||
|
|
bebbbb0050 | ||
|
|
03388e3f85 | ||
|
|
103cd4548d | ||
|
|
87aa82647a | ||
|
|
adbde5334d | ||
|
|
6d44d738a8 | ||
|
|
5f0c3b419c | ||
|
|
4fe495d7fa | ||
|
|
ae4eaeb4ba | ||
|
|
f9a36acf8f | ||
|
|
c6ea90867e | ||
|
|
e584c112df | ||
|
|
f59e58a15a | ||
|
|
be06bbb2ab | ||
|
|
7cbc4ac79e | ||
|
|
ce4d0b550a | ||
|
|
17c6bfad5f | ||
|
|
e9926cb292 | ||
|
|
09010f7fe5 | ||
|
|
d8518588f2 | ||
|
|
cd72b9c484 | ||
|
|
ddc11864fb | ||
|
|
46f0167f72 | ||
|
|
35432b9791 | ||
|
|
6207dc49f5 | ||
|
|
2e59f9db7c | ||
|
|
f7b34f6296 | ||
|
|
c1d1528a96 | ||
|
|
d446ef3863 | ||
|
|
c786185b18 | ||
|
|
bcbe2d2813 | ||
|
|
99779ceb90 | ||
|
|
9b0837f313 | ||
|
|
c0edc5c670 | ||
|
|
e4e976dacc | ||
|
|
2007ce5c70 | ||
|
|
b303e43634 | ||
|
|
6225fd5aff | ||
|
|
47d1259562 | ||
|
|
a5c7413f99 | ||
|
|
e702945538 | ||
|
|
0476bf25a8 | ||
|
|
d228ae595b | ||
|
|
1fbd41baa6 | ||
|
|
68d4844b7f | ||
|
|
bc32560433 | ||
|
|
48c3b48bcb | ||
|
|
e576cee191 | ||
|
|
06c3dbb271 | ||
|
|
350904aeaf | ||
|
|
4d469e9d78 |
No files matched your search
@@ -0,0 +1,38 @@
|
|||||||
|
# Java Gradle CircleCI 2.0 configuration file
|
||||||
|
version: 2
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
docker:
|
||||||
|
- image: circleci/openjdk@sha256:7be33522f6f0ca65c2e78b22b1ef3e6739038494c1de1b8fb6d96da400dccf53
|
||||||
|
|
||||||
|
working_directory: ~/repo
|
||||||
|
|
||||||
|
environment:
|
||||||
|
JVM_OPTS: -Xmx3200m
|
||||||
|
TERM: dumb
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
|
||||||
|
- restore_cache:
|
||||||
|
keys:
|
||||||
|
- gradle-cache
|
||||||
|
|
||||||
|
# Gradle Wrapper
|
||||||
|
# - run: sudo chmod +x gradlew
|
||||||
|
# - run: ./gradlew --version
|
||||||
|
# - run: ./gradlew clean build
|
||||||
|
|
||||||
|
# Gradle
|
||||||
|
- run: gradle --version
|
||||||
|
- run: gradle clean build
|
||||||
|
- run: gradle upload
|
||||||
|
- run: gradle publishGprPublicationToGitHubPackagesRepository
|
||||||
|
|
||||||
|
- store_artifacts:
|
||||||
|
path: ./build/libs
|
||||||
|
|
||||||
|
- save_cache:
|
||||||
|
paths:
|
||||||
|
- ~/.gradle
|
||||||
|
key: gradle-cache
|
||||||
+24
-5
@@ -1,12 +1,31 @@
|
|||||||
|
# Java
|
||||||
*.class
|
*.class
|
||||||
|
|
||||||
# Mobile Tools for Java (J2ME)
|
# Mobile Tools for Java (J2ME)
|
||||||
.mtj.tmp/
|
.mtj.tmp/
|
||||||
|
|
||||||
# Package Files #
|
|
||||||
*.jar
|
|
||||||
*.war
|
|
||||||
*.ear
|
|
||||||
|
|
||||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||||
hs_err_pid*
|
hs_err_pid*
|
||||||
|
|
||||||
|
# VSCode
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
# eclipse
|
||||||
|
*/.classpath
|
||||||
|
.classpath
|
||||||
|
*/.project
|
||||||
|
.project
|
||||||
|
.settings/
|
||||||
|
*.launch
|
||||||
|
|
||||||
|
# gradle
|
||||||
|
.gradle/
|
||||||
|
build/
|
||||||
|
gradle/
|
||||||
|
gradlew*
|
||||||
|
run/
|
||||||
|
|
||||||
|
# IDEA
|
||||||
|
.idea/
|
||||||
|
*.iml
|
||||||
|
out/
|
||||||
@@ -1,145 +0,0 @@
|
|||||||
package idv.jlchntoz;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import java.io.*;
|
|
||||||
import java.net.*;
|
|
||||||
import java.util.logging.*;
|
|
||||||
import java.util.regex.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Custom skin loader mod for Minecraft.
|
|
||||||
*
|
|
||||||
* @version 9th Revision 2014.4.15
|
|
||||||
* @author (C) Jeremy Lam [JLChnToZ] 2013 & Alexander Xia [xfl03] 2014
|
|
||||||
*/
|
|
||||||
public class CustomSkinLoader {
|
|
||||||
public final static String DefaultSkinURL = "http://skins.minecraft.net/MinecraftSkins/*.png";
|
|
||||||
public final static String DefaultCloakURL = "http://skins.minecraft.net/MinecraftCloaks/*.png";
|
|
||||||
private final static Pattern newURLPattern = Pattern.compile("^http://skins.minecraft.net/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
|
||||||
oldURLPattern = Pattern.compile("^http://s3.amazonaws.com/Minecraft(Skin|Cloak)s/(.*?).png$");
|
|
||||||
|
|
||||||
private final static Logger logger = Logger
|
|
||||||
.getLogger(CustomSkinLoader.class.getName());
|
|
||||||
|
|
||||||
private static String[] cloakURLs = null, skinURLs = null;
|
|
||||||
|
|
||||||
private HttpURLConnection C = null;
|
|
||||||
|
|
||||||
public InputStream getPlayerSkinStream(String path) {
|
|
||||||
Matcher m = newURLPattern.matcher(path);
|
|
||||||
if (!m.matches())//Is not new url
|
|
||||||
{
|
|
||||||
m = oldURLPattern.matcher(path);//If is old url
|
|
||||||
}
|
|
||||||
if (m.matches()) {
|
|
||||||
if (m.group(1).contains("Skin")) // Skin
|
|
||||||
return getPlayerSkinStream(false, m.group(2));
|
|
||||||
else if (m.group(1).contains("Cloak")) // Cloak
|
|
||||||
return getPlayerSkinStream(true, m.group(2));
|
|
||||||
}
|
|
||||||
return getStream(path, false); // Neither skin nor cloak...
|
|
||||||
}
|
|
||||||
|
|
||||||
public InputStream getPlayerSkinStream(Boolean isCloak, String playerName) {
|
|
||||||
if (skinURLs == null || cloakURLs == null || skinURLs.length <= 0
|
|
||||||
|| cloakURLs.length <= 0)
|
|
||||||
refreshSkinURL(); // If the list is blank or null, try to load
|
|
||||||
// again.
|
|
||||||
for (String l : isCloak ? cloakURLs : skinURLs) {
|
|
||||||
String loc = str_replace("*", playerName, l);
|
|
||||||
logger.log(Level.INFO, "Try to load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
|
||||||
InputStream S = getStream(loc, true);
|
|
||||||
if (S == null)
|
|
||||||
logger.log(Level.INFO, "No " + (isCloak ? "cloak" : "skin")
|
|
||||||
+ " found in " + loc);
|
|
||||||
else
|
|
||||||
return S;
|
|
||||||
}
|
|
||||||
logger.log(Level.INFO, "Try to load skin in default URL instead.");
|
|
||||||
return getStream(str_replace("*", playerName, isCloak ? DefaultCloakURL : DefaultSkinURL), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private InputStream getStream(String URL, Boolean CheckPNG) {
|
|
||||||
try {
|
|
||||||
URL U = new URL(URL);
|
|
||||||
C = (HttpURLConnection) U.openConnection();
|
|
||||||
C.setDoInput(true);
|
|
||||||
C.setDoOutput(false);
|
|
||||||
C.connect();
|
|
||||||
int respcode = C.getResponseCode() / 100;
|
|
||||||
if (respcode != 4 && respcode != 5) { // Successful (?) to get skin.
|
|
||||||
BufferedInputStream IS = new BufferedInputStream(
|
|
||||||
C.getInputStream());
|
|
||||||
if (!CheckPNG) // If no need to check PNG header, just skip it.
|
|
||||||
return IS;
|
|
||||||
IS.mark(0);
|
|
||||||
byte[] ib = new byte[4];
|
|
||||||
IS.read(ib);
|
|
||||||
if (ib[1] == (byte) 'P' && ib[2] == (byte) 'N'
|
|
||||||
&& ib[3] == (byte) 'G') { // Check PNG Header if needed
|
|
||||||
IS.reset();
|
|
||||||
return IS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
|
||||||
logger.log(Level.WARNING, ex.getMessage());
|
|
||||||
} finally {
|
|
||||||
disconnect();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void disconnect() {
|
|
||||||
if (C != null)
|
|
||||||
C.disconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void refreshSkinURL() {
|
|
||||||
try {
|
|
||||||
File mcdir = Minecraft.getMinecraft().mcDataDir;
|
|
||||||
skinURLs = readAllLines(mcdir, "skinurls.txt");
|
|
||||||
cloakURLs = readAllLines(mcdir, "capeurls.txt");
|
|
||||||
} catch (Exception ex) {
|
|
||||||
logger.log(Level.WARNING, ex.getMessage());
|
|
||||||
} finally {
|
|
||||||
logger.log(Level.INFO, "Skin URLs Refreshed. Skin count = "
|
|
||||||
+ skinURLs.length + ", Cloak count = " + cloakURLs.length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String[] readAllLines(File mcdir, String path) {
|
|
||||||
try {
|
|
||||||
File F = new File(mcdir, path);
|
|
||||||
logger.log(Level.INFO, "Config file: " + F.getAbsolutePath());
|
|
||||||
if (!F.exists()) {
|
|
||||||
logger.log(Level.INFO, "Config file not found, create new one.");
|
|
||||||
F.createNewFile();
|
|
||||||
return new String[0];
|
|
||||||
} else if (F.length() <= 0) {
|
|
||||||
logger.log(Level.INFO, "Config file is blank, skipped.");
|
|
||||||
return new String[0];
|
|
||||||
} else {
|
|
||||||
byte[] b = new byte[(int) F.length()];
|
|
||||||
BufferedInputStream S = new BufferedInputStream(
|
|
||||||
new FileInputStream(F));
|
|
||||||
S.read(b);
|
|
||||||
S.close();
|
|
||||||
logger.log(Level.INFO, "Config file loaded.");
|
|
||||||
return str_replace("\r", "\n",
|
|
||||||
str_replace("\r\n", "\n", new String(b))).split("\n");
|
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
|
||||||
logger.log(Level.WARNING, ex.getMessage());
|
|
||||||
return new String[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String str_replace(String search, String replace,
|
|
||||||
String subject) {
|
|
||||||
StringBuffer result = new StringBuffer(subject);
|
|
||||||
int pos;
|
|
||||||
while ((pos = result.indexOf(search)) != -1)
|
|
||||||
result.replace(pos, pos + search.length(), replace);
|
|
||||||
return result.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-112
@@ -1,112 +0,0 @@
|
|||||||
package net.minecraft.client.renderer;
|
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.renderer.texture.SimpleTexture;
|
|
||||||
import net.minecraft.client.renderer.texture.TextureUtil;
|
|
||||||
import net.minecraft.client.resources.IResourceManager;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import idv.jlchntoz.CustomSkinLoader;
|
|
||||||
|
|
||||||
public class ThreadDownloadImageData extends SimpleTexture
|
|
||||||
{
|
|
||||||
private static final Logger logger = LogManager.getLogger();
|
|
||||||
private static final AtomicInteger field_147643_d = new AtomicInteger(0);
|
|
||||||
private final String imageUrl;
|
|
||||||
private final IImageBuffer imageBuffer;
|
|
||||||
private BufferedImage bufferedImage;
|
|
||||||
private Thread imageThread;
|
|
||||||
private boolean textureUploaded;
|
|
||||||
private static final String __OBFID = "CL_00001049";
|
|
||||||
|
|
||||||
public ThreadDownloadImageData(String par1Str, ResourceLocation par2ResourceLocation, IImageBuffer par3IImageBuffer)
|
|
||||||
{
|
|
||||||
super(par2ResourceLocation);
|
|
||||||
this.imageUrl = par1Str;
|
|
||||||
this.imageBuffer = par3IImageBuffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void func_147640_e()
|
|
||||||
{
|
|
||||||
if (!this.textureUploaded)
|
|
||||||
{
|
|
||||||
if (this.bufferedImage != null)
|
|
||||||
{
|
|
||||||
if (this.textureLocation != null)
|
|
||||||
{
|
|
||||||
this.func_147631_c();
|
|
||||||
}
|
|
||||||
|
|
||||||
TextureUtil.uploadTextureImage(super.getGlTextureId(), this.bufferedImage);
|
|
||||||
this.textureUploaded = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getGlTextureId()
|
|
||||||
{
|
|
||||||
this.func_147640_e();
|
|
||||||
return super.getGlTextureId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void func_147641_a(BufferedImage p_147641_1_)
|
|
||||||
{
|
|
||||||
this.bufferedImage = p_147641_1_;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadTexture(IResourceManager par1ResourceManager) throws IOException
|
|
||||||
{
|
|
||||||
if (this.bufferedImage == null && this.textureLocation != null)
|
|
||||||
{
|
|
||||||
super.loadTexture(par1ResourceManager);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.imageThread == null)
|
|
||||||
{
|
|
||||||
this.imageThread = new Thread("Texture Downloader #" + field_147643_d.incrementAndGet())
|
|
||||||
{
|
|
||||||
private static final String __OBFID = "CL_00001050";
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
|
|
||||||
CustomSkinLoader Loader = new CustomSkinLoader();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
BufferedImage var2 = ImageIO.read(Loader.getPlayerSkinStream(ThreadDownloadImageData.this.imageUrl));
|
|
||||||
|
|
||||||
if (ThreadDownloadImageData.this.imageBuffer != null)
|
|
||||||
{
|
|
||||||
var2 = ThreadDownloadImageData.this.imageBuffer.parseUserSkin(var2);
|
|
||||||
}
|
|
||||||
|
|
||||||
ThreadDownloadImageData.this.func_147641_a(var2);
|
|
||||||
}
|
|
||||||
catch (Exception var6)
|
|
||||||
{
|
|
||||||
ThreadDownloadImageData.logger.error("Couldn\'t download http texture", var6);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
this.imageThread.setDaemon(true);
|
|
||||||
this.imageThread.setName("Skin downloader: " + this.imageUrl);
|
|
||||||
this.imageThread.start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isTextureUploaded()
|
|
||||||
{
|
|
||||||
this.func_147640_e();
|
|
||||||
return this.textureUploaded;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,153 @@
|
|||||||
|
/**
|
||||||
|
* Gradle Script for COS
|
||||||
|
* It can be used to upload or download file from Tencent Cloud COS.
|
||||||
|
* COS: https://cloud.tencent.com/document/product/436
|
||||||
|
*/
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.qcloud:cos_api:5.4.6'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
import com.qcloud.cos.COSClient
|
||||||
|
import com.qcloud.cos.ClientConfig
|
||||||
|
import com.qcloud.cos.auth.BasicCOSCredentials
|
||||||
|
import com.qcloud.cos.auth.COSCredentials
|
||||||
|
import com.qcloud.cos.model.PutObjectRequest
|
||||||
|
import com.qcloud.cos.model.GetObjectRequest
|
||||||
|
import com.qcloud.cos.region.Region
|
||||||
|
|
||||||
|
String getMcVersion(String filename) {
|
||||||
|
if (filename.endsWith(".json"))
|
||||||
|
return filename.substring(0, filename.indexOf('-'))
|
||||||
|
return filename.substring(filename.indexOf('_') + 1, filename.indexOf('-'))
|
||||||
|
}
|
||||||
|
|
||||||
|
String getKey(String filename) {
|
||||||
|
String name = filename.substring(0, filename.lastIndexOf('.'))
|
||||||
|
if (name.indexOf('-') == -1) return null
|
||||||
|
if (filename.endsWith(".json"))
|
||||||
|
return String.format(
|
||||||
|
"versions/%s/%s",
|
||||||
|
name,
|
||||||
|
filename
|
||||||
|
)
|
||||||
|
if (filename.endsWith(".jar")) {
|
||||||
|
if (filename.contains("Fabric") || filename.contains("Forge")) {
|
||||||
|
return String.format(
|
||||||
|
"mods/%s",
|
||||||
|
filename
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return String.format(
|
||||||
|
"libraries/customskinloader/%s/%s/%s",
|
||||||
|
name.substring(0, name.indexOf('-')),
|
||||||
|
name.substring(name.indexOf('-') + 1),
|
||||||
|
filename
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return filename
|
||||||
|
}
|
||||||
|
|
||||||
|
ext.bucketName = System.getenv("COS_BUCKET")
|
||||||
|
ext.cosUrl = "https://csl.littleservice.cn/"
|
||||||
|
ext.cosClient0 = null
|
||||||
|
|
||||||
|
COSClient getCosClient() {
|
||||||
|
if (cosClient0 != null) return cosClient0
|
||||||
|
|
||||||
|
COSCredentials cred = new BasicCOSCredentials(System.getenv("COS_SECRET_ID"), System.getenv("COS_SECRET_KEY"))
|
||||||
|
ClientConfig clientConfig = new ClientConfig(new Region("ap-shanghai"))
|
||||||
|
cosClient0 = new COSClient(cred, clientConfig)
|
||||||
|
}
|
||||||
|
|
||||||
|
void uploadFile(String key, File file) {
|
||||||
|
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, key, file)
|
||||||
|
getCosClient().putObject(putObjectRequest)
|
||||||
|
}
|
||||||
|
|
||||||
|
void downloadFile(String key, File file) {
|
||||||
|
GetObjectRequest getObjectRequest = new GetObjectRequest(bucketName, key)
|
||||||
|
getCosClient().getObject(getObjectRequest, file)
|
||||||
|
}
|
||||||
|
|
||||||
|
String toJson(Map<String, Object> map, int d) {
|
||||||
|
StringBuilder sb = new StringBuilder("{\n")
|
||||||
|
Iterator<Map.Entry<String, Object>> it = map.entrySet().iterator()
|
||||||
|
while (it.hasNext()) {
|
||||||
|
Map.Entry<String, Object> e = it.next()
|
||||||
|
String k = e.key
|
||||||
|
String v = null
|
||||||
|
if (e.value instanceof String) {
|
||||||
|
v = "\"" + e.value + "\""
|
||||||
|
} else if (e.value instanceof Map) {
|
||||||
|
v = toJson((Map) e.value, d + 1)
|
||||||
|
}
|
||||||
|
for (int i = 0; i < d * 2; i++) {
|
||||||
|
sb.append(' ')
|
||||||
|
}
|
||||||
|
if (it.hasNext()) {
|
||||||
|
sb.append(String.format("\"%s\" : %s,\n", k, v))
|
||||||
|
} else {
|
||||||
|
sb.append(String.format("\"%s\" : %s\n", k, v))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < (d - 1) * 2; i++) {
|
||||||
|
sb.append(' ')
|
||||||
|
}
|
||||||
|
sb.append("}")
|
||||||
|
return sb.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
String toJson(Map<String, Object> map) {
|
||||||
|
return toJson(map, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
void writeToFile(File f, String s) {
|
||||||
|
FileWriter fw = new FileWriter(f)
|
||||||
|
fw.write(s)
|
||||||
|
fw.flush()
|
||||||
|
fw.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
void uploadArtifacts(String shortVersion) {
|
||||||
|
File dir = rootProject.file("build/libs")
|
||||||
|
if (!dir.isDirectory()) return
|
||||||
|
|
||||||
|
String cslversion = shortVersion.replace(".", "")
|
||||||
|
LinkedHashMap<String, Object> map = new LinkedHashMap<String, Object>()
|
||||||
|
LinkedHashMap<String, String> map2 = new LinkedHashMap<String, String>()
|
||||||
|
LinkedHashMap<String, String> map3 = new LinkedHashMap<String, String>()
|
||||||
|
map.put("version", shortVersion)
|
||||||
|
map.put("downloads", map2)
|
||||||
|
map.put("launchermeta", map3)
|
||||||
|
|
||||||
|
File[] files = dir.listFiles()
|
||||||
|
for (file in files) {
|
||||||
|
String key = getKey(file.getName())
|
||||||
|
if (key == null) continue
|
||||||
|
uploadFile(key, file)
|
||||||
|
String url = cosUrl + key
|
||||||
|
String mcversion = getMcVersion(file.getName())
|
||||||
|
println(String.format("csl-%s-%s\t%s", mcversion.replace(".", "").toLowerCase(), cslversion, url))
|
||||||
|
|
||||||
|
if (key.endsWith(".jar")) {
|
||||||
|
map2.put(mcversion, url)
|
||||||
|
} else if (key.endsWith(".json")) {
|
||||||
|
map3.put(mcversion, url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
File latest = new File("build/libs/latest.json")
|
||||||
|
writeToFile(latest, toJson(map))
|
||||||
|
uploadFile("latest.json", latest)
|
||||||
|
}
|
||||||
|
|
||||||
|
ext {
|
||||||
|
uploadArtifacts = this.&uploadArtifacts
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
/**
|
||||||
|
* Gradle Script for Remap
|
||||||
|
* Designed for remapping jar.
|
||||||
|
* Remap Jar: mcp<->srg<->notch
|
||||||
|
*/
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
maven {
|
||||||
|
name = "forge"
|
||||||
|
url = "http://files.minecraftforge.net/maven"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath 'net.md-5:SpecialSource:1.8.6'
|
||||||
|
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
import net.md_5.specialsource.JarMapping
|
||||||
|
import net.md_5.specialsource.JarRemapper
|
||||||
|
import net.md_5.specialsource.provider.JarProvider
|
||||||
|
import net.md_5.specialsource.provider.JointProvider
|
||||||
|
|
||||||
|
|
||||||
|
void reobfSrgToNotch() {
|
||||||
|
def srgName = "${archivesBaseName}-${version}-srg.jar"
|
||||||
|
def notchName = srgName.replace('-srg', '')
|
||||||
|
if (config.srg_notch_map == null) {
|
||||||
|
//Default Map
|
||||||
|
def mcpName = srgName.replace('-srg', '-dev')
|
||||||
|
applySpecialSource(srgName, mcpName, getDefaultMap("srg-mcp"))
|
||||||
|
applySpecialSource(mcpName, notchName, getDefaultMap("mcp-notch"))
|
||||||
|
} else {
|
||||||
|
//Custom Map
|
||||||
|
applySpecialSource(srgName, notchName, config.srg_notch_map)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void applySpecialSource(String inputName, String outputName, String mapFile) {
|
||||||
|
def mapping = new JarMapping()
|
||||||
|
def srgFile = file(mapFile)
|
||||||
|
def inputFile = file("build/libs/${inputName}")
|
||||||
|
def outputFile = file("build/libs/${outputName}")
|
||||||
|
def remapper = new JarRemapper(null, mapping)
|
||||||
|
def inputJar = net.md_5.specialsource.Jar.init(inputFile)
|
||||||
|
def inheritanceProviders = new JointProvider()
|
||||||
|
def jarProvider = new JarProvider(inputJar)
|
||||||
|
inheritanceProviders.add(jarProvider)
|
||||||
|
mapping.loadMappings(srgFile)
|
||||||
|
mapping.setFallbackInheritanceProvider(inheritanceProviders)
|
||||||
|
remapper.remapJar(inputJar, outputFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
String getDefaultMap(String srgType) {
|
||||||
|
def mcpVersion = minecraft.mappings.replace('_', "/")
|
||||||
|
return System.getProperty('user.home') + "/.gradle/caches/minecraft/de/oceanlabs/mcp/mcp_${mcpVersion}/${config.forge_mc_version}/srgs/${srgType}.srg"
|
||||||
|
}
|
||||||
|
|
||||||
|
ext {
|
||||||
|
reobfSrgToNotch = this.&reobfSrgToNotch
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
/**
|
||||||
|
* Gradle Script for Version
|
||||||
|
* Format Version String
|
||||||
|
*/
|
||||||
|
|
||||||
|
boolean isRelease() {
|
||||||
|
String s = rootProject.ext.config.snapshot
|
||||||
|
return s == null || s == "" || s == "0"
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isSnapshot() {
|
||||||
|
return !isRelease()
|
||||||
|
}
|
||||||
|
|
||||||
|
String getBuildNum() {
|
||||||
|
if (System.getenv("CIRCLE_BUILD_NUM") != null)
|
||||||
|
return System.getenv("CIRCLE_BUILD_NUM")
|
||||||
|
return "00"
|
||||||
|
}
|
||||||
|
|
||||||
|
//Example: 14.10a-SNAPSHOT-33
|
||||||
|
String getCSLVersion() {
|
||||||
|
return rootProject.ext.config.version + rootProject.ext.config.dev_version +
|
||||||
|
(isRelease() ? '' : ('-SNAPSHOT-' + getBuildNum()))
|
||||||
|
}
|
||||||
|
|
||||||
|
//Example: 14.10a-s33
|
||||||
|
String getShortVersion() {
|
||||||
|
return getCSLVersion().replace("SNAPSHOT-", "s")
|
||||||
|
}
|
||||||
|
|
||||||
|
ext {
|
||||||
|
getCSLVersion = this.&getCSLVersion
|
||||||
|
getShortVersion = this.&getShortVersion
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "CustomSkinLoader",
|
||||||
|
"version": "${modVersion}",
|
||||||
|
"fullVersion": "${modFullVersion}",
|
||||||
|
"mcVersion": "${mcVersion}",
|
||||||
|
"mcFullVersions": "${mcFullVersions}",
|
||||||
|
"forgeVersion": "${forgeVersion}",
|
||||||
|
"gitVersion": "${gitVersion}",
|
||||||
|
"buildUrl": "${buildUrl}",
|
||||||
|
"buildTime": "${releaseTime}"
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
English(en)
|
||||||
|
|
||||||
|
LICENSE - Binary File
|
||||||
|
You could not modify binary file.
|
||||||
|
Feel free to use and share this mod and unmodified file in anyway like modpack.
|
||||||
|
When using in modpack, you must put 'CustomSkinLoader' in mod list.
|
||||||
|
You could not repost this mod to any website without permission.
|
||||||
|
You could not earn money with this mod excluding modpack.
|
||||||
|
|
||||||
|
LICENSE - Source Code
|
||||||
|
GPLv3: http://www.gnu.org/licenses/gpl.html
|
||||||
|
When using the code, you should change the name of package to avoid others' misunderstanding.
|
||||||
|
|
||||||
|
OTHER - Useful Link
|
||||||
|
Source Code: https://github.com/xfl03/MCCustomSkinLoader
|
||||||
|
Release Page: http://www.mcbbs.net/thread-269807-1-1.html
|
||||||
|
Build Server: https://ci.infstudio.net/job/CustomSkinLoader/
|
||||||
|
|
||||||
|
|
||||||
|
中文简体(zh_cn)
|
||||||
|
|
||||||
|
许可 - 编译产物
|
||||||
|
您不得对CustomSkinLoader的成品jar内部内容进行任何修改
|
||||||
|
您可以在不经我许可的情况下,以任意方式传播这一mod以及jar文件(例如加入整合包)。
|
||||||
|
在加入整合包时,请必须在帖子内mod列表中明确写上"万用皮肤补丁"或者"CustomSkinLoader"或者附上发布页面地址。
|
||||||
|
您不得在未经许可的情况下,在国内外任何网站进行二次发布(包括皮肤站)。
|
||||||
|
您不得以任何形式出售CustomSkinLoader或任何使用或参考CustomSkinLoader源代码的作品。
|
||||||
|
|
||||||
|
许可 - 源代码
|
||||||
|
GPLv3: http://www.gnu.org/licenses/gpl.html
|
||||||
|
为避免他人误解,您在使用代码时必须修改包名。
|
||||||
|
|
||||||
|
其他 - 有用的链接
|
||||||
|
源代码: https://github.com/xfl03/MCCustomSkinLoader
|
||||||
|
发布页面: http://www.mcbbs.net/thread-269807-1-1.html
|
||||||
|
构建服务器: https://ci.infstudio.net/job/CustomSkinLoader/
|
||||||
@@ -0,0 +1,192 @@
|
|||||||
|
package customskinloader;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||||
|
|
||||||
|
import customskinloader.config.Config;
|
||||||
|
import customskinloader.config.SkinSiteProfile;
|
||||||
|
import customskinloader.loader.*;
|
||||||
|
import customskinloader.profile.DynamicSkullManager;
|
||||||
|
import customskinloader.profile.ModelManager0;
|
||||||
|
import customskinloader.profile.ProfileCache;
|
||||||
|
import customskinloader.profile.UserProfile;
|
||||||
|
import customskinloader.utils.MinecraftUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom skin loader mod for Minecraft.
|
||||||
|
* @author (C) Jeremy Lam [JLChnToZ] 2013-2014 & Alexander Xia [xfl03] 2014-2020
|
||||||
|
* @version @MOD_FULL_VERSION@
|
||||||
|
*/
|
||||||
|
public class CustomSkinLoader {
|
||||||
|
public static final String CustomSkinLoader_VERSION="@MOD_VERSION@";
|
||||||
|
public static final String CustomSkinLoader_FULL_VERSION="@MOD_FULL_VERSION@";
|
||||||
|
|
||||||
|
public static final File DATA_DIR=new File(MinecraftUtil.getMinecraftDataDir(),"CustomSkinLoader"),
|
||||||
|
LOG_FILE=new File(DATA_DIR,"CustomSkinLoader.log"),
|
||||||
|
CONFIG_FILE=new File(DATA_DIR,"CustomSkinLoader.json");
|
||||||
|
public static final SkinSiteProfile[] DEFAULT_LOAD_LIST={
|
||||||
|
SkinSiteProfile.createMojangAPI("Mojang"),
|
||||||
|
SkinSiteProfile.createCustomSkinAPI("LittleSkin","https://littlesk.in/csl/"),
|
||||||
|
SkinSiteProfile.createCustomSkinAPI("BlessingSkin","http://skin.prinzeugen.net/"),
|
||||||
|
//OneSkin has been removed temporarily
|
||||||
|
//SkinSiteProfile.createCustomSkinAPI("OneSkin","http://fleey.cn/skin/skin_user/skin_json.php/"),
|
||||||
|
//Minecrack could not load skin correctly
|
||||||
|
//SkinSiteProfile.creatLegacy("Minecrack","http://minecrack.fr.nf/mc/skinsminecrackd/{USERNAME}.png","http://minecrack.fr.nf/mc/cloaksminecrackd/{USERNAME}.png",null),
|
||||||
|
SkinSiteProfile.createElyByAPI("ElyBy"),
|
||||||
|
SkinSiteProfile.createUniSkinAPI("SkinMe","http://www.skinme.cc/uniskin/"),
|
||||||
|
SkinSiteProfile.createLegacy("LocalSkin","LocalSkin/skins/{USERNAME}.png","LocalSkin/capes/{USERNAME}.png","LocalSkin/elytras/{USERNAME}.png"),
|
||||||
|
SkinSiteProfile.createGlitchlessAPI("GlitchlessGames","https://games.glitchless.ru/api/minecraft/users/profiles/textures/?nickname=")};
|
||||||
|
|
||||||
|
public static final Gson GSON=new GsonBuilder().setPrettyPrinting().create();
|
||||||
|
public static final Logger logger=initLogger();
|
||||||
|
public static final Config config=Config.loadConfig0();
|
||||||
|
|
||||||
|
private static final ProfileCache profileCache=new ProfileCache();
|
||||||
|
private static final DynamicSkullManager dynamicSkullManager=new DynamicSkullManager();
|
||||||
|
|
||||||
|
private static final ThreadPoolExecutor threadPool = new ThreadPoolExecutor(config.threadPoolSize, config.threadPoolSize, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue<>());
|
||||||
|
|
||||||
|
//For User Skin
|
||||||
|
public static Map<Type, MinecraftProfileTexture> loadProfile(GameProfile gameProfile){
|
||||||
|
String username=gameProfile.getName();
|
||||||
|
String credential=MinecraftUtil.getCredential(gameProfile);
|
||||||
|
//Fix: http://hopper.minecraft.net/crashes/minecraft/MCX-2773713
|
||||||
|
if(username==null){
|
||||||
|
logger.warning("Could not load profile: username is null.");
|
||||||
|
return Maps.newHashMap();
|
||||||
|
}
|
||||||
|
String tempName=Thread.currentThread().getName();
|
||||||
|
Thread.currentThread().setName(username);//Change Thread Name
|
||||||
|
UserProfile profile;
|
||||||
|
if(profileCache.isReady(credential)){
|
||||||
|
logger.info("Cached profile will be used.");
|
||||||
|
profile=profileCache.getProfile(credential);
|
||||||
|
if(profile==null){
|
||||||
|
logger.warning("(!Cached Profile is empty!) Expiry:"+profileCache.getExpiry(credential));
|
||||||
|
if(profileCache.isExpired(credential))//force load
|
||||||
|
profile=loadProfile0(gameProfile);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
logger.info(profile.toString(profileCache.getExpiry(credential)));
|
||||||
|
}else{
|
||||||
|
profileCache.setLoading(credential, true);
|
||||||
|
profile=loadProfile0(gameProfile);
|
||||||
|
}
|
||||||
|
Thread.currentThread().setName(tempName);
|
||||||
|
return ModelManager0.fromUserProfile(profile);
|
||||||
|
}
|
||||||
|
//Core
|
||||||
|
public static UserProfile loadProfile0(GameProfile gameProfile){
|
||||||
|
String username=gameProfile.getName();
|
||||||
|
String credential=MinecraftUtil.getCredential(gameProfile);
|
||||||
|
|
||||||
|
profileCache.setLoading(credential, true);
|
||||||
|
logger.info("Loading "+username+"'s profile.");
|
||||||
|
if(config.loadlist==null||config.loadlist.isEmpty()){
|
||||||
|
logger.info("LoadList is Empty.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
UserProfile profile0=new UserProfile();
|
||||||
|
for(int i=0;i<config.loadlist.size();i++){
|
||||||
|
SkinSiteProfile ssp=config.loadlist.get(i);
|
||||||
|
logger.info((i+1)+"/"+config.loadlist.size()+" Try to load profile from '"+ssp.name+"'.");
|
||||||
|
ProfileLoader.IProfileLoader loader=ProfileLoader.LOADERS.get(ssp.type.toLowerCase());
|
||||||
|
if(loader==null){
|
||||||
|
logger.info("Type '"+ssp.type+"' is not defined.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
UserProfile profile=null;
|
||||||
|
try{
|
||||||
|
profile=loader.loadProfile(ssp, gameProfile);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.warning("Exception occurs while loading.");
|
||||||
|
logger.warning(e);
|
||||||
|
if(e.getCause()!=null) {
|
||||||
|
logger.warning("Caused By:");
|
||||||
|
logger.warning(e.getCause());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(profile==null)
|
||||||
|
continue;
|
||||||
|
if(!config.forceLoadAllTextures){
|
||||||
|
profile0=profile;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
profile0.mix(profile);
|
||||||
|
if(profile0.isFull())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(!profile0.isEmpty()){
|
||||||
|
logger.info(username+"'s profile loaded.");
|
||||||
|
if(!config.enableCape)
|
||||||
|
profile0.capeUrl = null;
|
||||||
|
profileCache.updateCache(credential, profile0);
|
||||||
|
profileCache.setLoading(credential, false);
|
||||||
|
logger.info(profile0.toString(profileCache.getExpiry(credential)));
|
||||||
|
return profile0;
|
||||||
|
}
|
||||||
|
logger.info(username+"'s profile not found in load list.");
|
||||||
|
|
||||||
|
if(config.enableLocalProfileCache){
|
||||||
|
UserProfile profile=profileCache.getLocalProfile(credential);
|
||||||
|
if(profile==null)
|
||||||
|
logger.info(username+"'s LocalProfile not found.");
|
||||||
|
else{
|
||||||
|
profileCache.updateCache(credential, profile, false);
|
||||||
|
profileCache.setLoading(credential, false);
|
||||||
|
logger.info(username+"'s LocalProfile will be used.");
|
||||||
|
logger.info(profile.toString(profileCache.getExpiry(credential)));
|
||||||
|
return profile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
profileCache.setLoading(credential, false);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//For Skull
|
||||||
|
public static Map<Type, MinecraftProfileTexture> loadProfileFromCache(final GameProfile gameProfile) {
|
||||||
|
String username=gameProfile.getName();
|
||||||
|
String credential=MinecraftUtil.getCredential(gameProfile);
|
||||||
|
|
||||||
|
if(username == null || credential == null)
|
||||||
|
return dynamicSkullManager.getTexture(gameProfile);
|
||||||
|
if(config.enableUpdateSkull?profileCache.isReady(credential):profileCache.isExist(credential)){
|
||||||
|
UserProfile profile=profileCache.getProfile(credential);
|
||||||
|
return ModelManager0.fromUserProfile(profile);
|
||||||
|
}
|
||||||
|
if (!profileCache.isLoading(credential)) {
|
||||||
|
profileCache.setLoading(credential, true);
|
||||||
|
Runnable loadThread = () -> {
|
||||||
|
String tempName = Thread.currentThread().getName();
|
||||||
|
Thread.currentThread().setName(username + "'s skull");
|
||||||
|
loadProfile0(gameProfile);//Load in thread
|
||||||
|
Thread.currentThread().setName(tempName);
|
||||||
|
};
|
||||||
|
if (config.enableUpdateSkull) {
|
||||||
|
new Thread(loadThread).start();
|
||||||
|
} else {
|
||||||
|
threadPool.execute(loadThread);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Maps.newHashMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Logger initLogger() {
|
||||||
|
Logger logger=new Logger(LOG_FILE);
|
||||||
|
logger.info("CustomSkinLoader "+CustomSkinLoader_FULL_VERSION);
|
||||||
|
logger.info("DataDir: "+DATA_DIR.getAbsolutePath());
|
||||||
|
logger.info("Minecraft: "+MinecraftUtil.getMinecraftMainVersion()+"("+MinecraftUtil.getMinecraftVersionText()+")");
|
||||||
|
return logger;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
package customskinloader;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||||
|
public class Logger {
|
||||||
|
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
public enum Level{
|
||||||
|
DEBUG("DEBUG",false),
|
||||||
|
INFO("INFO",true),
|
||||||
|
WARNING("WARNING",true);
|
||||||
|
|
||||||
|
|
||||||
|
String name;
|
||||||
|
boolean display;
|
||||||
|
Level(String name,boolean display){
|
||||||
|
this.name=name;
|
||||||
|
this.display=display;
|
||||||
|
}
|
||||||
|
public String getName(){
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
public boolean display(){
|
||||||
|
return display;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private BufferedWriter writer=null;
|
||||||
|
public Logger(){
|
||||||
|
//Logger isn't created.
|
||||||
|
}
|
||||||
|
public Logger(String logFile) {
|
||||||
|
this(new File(logFile));
|
||||||
|
}
|
||||||
|
public Logger(File logFile){
|
||||||
|
try {
|
||||||
|
if(!logFile.getParentFile().exists()){
|
||||||
|
logFile.getParentFile().mkdirs();
|
||||||
|
}
|
||||||
|
if(!logFile.exists())
|
||||||
|
logFile.createNewFile();
|
||||||
|
|
||||||
|
writer = new BufferedWriter(new OutputStreamWriter(
|
||||||
|
new FileOutputStream(logFile), "UTF-8"));
|
||||||
|
|
||||||
|
System.out.println("Log Path: " + logFile.getAbsolutePath());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void close(){
|
||||||
|
if(writer!=null){
|
||||||
|
try {
|
||||||
|
writer.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void log(Level level,String msg){
|
||||||
|
if(!level.display()&&writer==null)
|
||||||
|
return;
|
||||||
|
String sb = String.format("[%s %s] %s", Thread.currentThread().getName(), level.getName(), msg);
|
||||||
|
if(level.display())
|
||||||
|
System.out.println(sb);
|
||||||
|
if(writer==null)
|
||||||
|
return;
|
||||||
|
try {
|
||||||
|
String sb2 = String.format("[%s] %s\r\n", DATE_FORMAT.format(new Date()), sb);
|
||||||
|
writer.write(sb2);
|
||||||
|
writer.flush();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void debug(String msg){
|
||||||
|
log(Level.DEBUG,msg);
|
||||||
|
}
|
||||||
|
public void debug(String format, Object... objs) {
|
||||||
|
debug(String.format(format, objs));
|
||||||
|
}
|
||||||
|
public void info(String msg){
|
||||||
|
log(Level.INFO,msg);
|
||||||
|
}
|
||||||
|
public void info(String format, Object... objs){
|
||||||
|
info(String.format(format, objs));
|
||||||
|
}
|
||||||
|
public void warning(String msg){
|
||||||
|
log(Level.WARNING,msg);
|
||||||
|
}
|
||||||
|
public void warning(String format, Object... objs){
|
||||||
|
warning(String.format(format, objs));
|
||||||
|
}
|
||||||
|
public void warning(Throwable e){
|
||||||
|
log(Level.WARNING,"Exception: "+e.toString());
|
||||||
|
StackTraceElement[] stes=e.getStackTrace();
|
||||||
|
for(StackTraceElement ste : stes){
|
||||||
|
log(Level.WARNING,ste.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,194 @@
|
|||||||
|
package customskinloader.config;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import customskinloader.utils.Version;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
|
import customskinloader.CustomSkinLoader;
|
||||||
|
import customskinloader.loader.ProfileLoader;
|
||||||
|
import customskinloader.utils.HttpRequestUtil;
|
||||||
|
import customskinloader.utils.HttpTextureUtil;
|
||||||
|
import customskinloader.utils.HttpUtil0;
|
||||||
|
|
||||||
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||||
|
public class Config {
|
||||||
|
//Program
|
||||||
|
public String version;
|
||||||
|
public List<SkinSiteProfile> loadlist;
|
||||||
|
|
||||||
|
//Function
|
||||||
|
public boolean enableDynamicSkull=true;
|
||||||
|
public boolean enableTransparentSkin=true;
|
||||||
|
public boolean ignoreHttpsCertificate=false;
|
||||||
|
public boolean forceLoadAllTextures=false;
|
||||||
|
public boolean enableCape = true;
|
||||||
|
public int threadPoolSize = 1;
|
||||||
|
|
||||||
|
//Cache
|
||||||
|
public int cacheExpiry=30;
|
||||||
|
public boolean enableUpdateSkull=false;
|
||||||
|
public boolean enableLocalProfileCache=false;
|
||||||
|
public boolean enableCacheAutoClean=false;
|
||||||
|
|
||||||
|
//Init config
|
||||||
|
public Config(SkinSiteProfile[] loadlist){
|
||||||
|
this.version=CustomSkinLoader.CustomSkinLoader_VERSION;
|
||||||
|
this.loadlist=Arrays.asList(loadlist);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Config loadConfig0() {
|
||||||
|
Config config=loadConfig();
|
||||||
|
|
||||||
|
//LoadList null checker
|
||||||
|
if(config.loadlist==null){
|
||||||
|
config.loadlist=new ArrayList<SkinSiteProfile>();
|
||||||
|
}else{
|
||||||
|
for(int i=0;i<config.loadlist.size();i++){
|
||||||
|
if(config.loadlist.get(i)==null)
|
||||||
|
config.loadlist.remove(i--);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Init program
|
||||||
|
config.loadExtraList();
|
||||||
|
config.initLocalFolder();
|
||||||
|
config.threadPoolSize = Math.max(config.threadPoolSize, 1);
|
||||||
|
if(config.ignoreHttpsCertificate)
|
||||||
|
HttpUtil0.ignoreHttpsCertificate();
|
||||||
|
if(config.enableCacheAutoClean && !config.enableLocalProfileCache){
|
||||||
|
try{
|
||||||
|
FileUtils.deleteDirectory(HttpRequestUtil.CACHE_DIR);
|
||||||
|
FileUtils.deleteDirectory(HttpTextureUtil.getCacheDir());
|
||||||
|
CustomSkinLoader.logger.info("Successfully cleaned cache.");
|
||||||
|
}catch(Exception e){
|
||||||
|
CustomSkinLoader.logger.warning("Exception occurs while cleaning cache: "+e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Check config version
|
||||||
|
Version configVersion = Version.of(config.version);
|
||||||
|
if (configVersion.compareTo(CustomSkinLoader.CustomSkinLoader_VERSION) < 0) {
|
||||||
|
CustomSkinLoader.logger.info("Config File is out of date: " + config.version);
|
||||||
|
config.version = CustomSkinLoader.CustomSkinLoader_VERSION;
|
||||||
|
|
||||||
|
//Update some config
|
||||||
|
if (configVersion.compareTo("14.10") < 0)//Lower than 14.10
|
||||||
|
config.enableCape = true;
|
||||||
|
writeConfig(config, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Output config
|
||||||
|
for (Field field : config.getClass().getDeclaredFields()) {
|
||||||
|
try {
|
||||||
|
Object value = field.get(config);
|
||||||
|
if (value instanceof String || value instanceof Integer || value instanceof Boolean)
|
||||||
|
CustomSkinLoader.logger.info(field.getName() + " : " + value);
|
||||||
|
} catch (Exception ignored) { }
|
||||||
|
}
|
||||||
|
CustomSkinLoader.logger.info("loadList : " + (config.loadlist == null ? 0 : config.loadlist.size()));
|
||||||
|
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Config loadConfig() {
|
||||||
|
CustomSkinLoader.logger.info("Config File: "+CustomSkinLoader.CONFIG_FILE.getAbsolutePath());
|
||||||
|
if(!CustomSkinLoader.CONFIG_FILE.exists()){
|
||||||
|
CustomSkinLoader.logger.info("Config file not found, use default instead.");
|
||||||
|
return initConfig();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
CustomSkinLoader.logger.info("Try to load config.");
|
||||||
|
String json=FileUtils.readFileToString(CustomSkinLoader.CONFIG_FILE, "UTF-8");
|
||||||
|
Config config=CustomSkinLoader.GSON.fromJson(json, Config.class);
|
||||||
|
CustomSkinLoader.logger.info("Successfully load config.");
|
||||||
|
return config;
|
||||||
|
}catch (Exception e) {
|
||||||
|
CustomSkinLoader.logger.info("Failed to load config, use default instead.("+e.toString()+")");
|
||||||
|
File brokenFile=new File(CustomSkinLoader.DATA_DIR,"BROKEN-CustomSkinLoader.json");
|
||||||
|
if(brokenFile.exists())
|
||||||
|
brokenFile.delete();
|
||||||
|
CustomSkinLoader.CONFIG_FILE.renameTo(brokenFile);
|
||||||
|
return initConfig();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadExtraList(){
|
||||||
|
File listAddition=new File(CustomSkinLoader.DATA_DIR,"ExtraList");
|
||||||
|
if(!listAddition.isDirectory()){
|
||||||
|
listAddition.mkdirs();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<SkinSiteProfile> adds=new ArrayList<SkinSiteProfile>();
|
||||||
|
File[] files=listAddition.listFiles();
|
||||||
|
for(File file: files != null ? files : new File[0]){
|
||||||
|
if(!file.getName().toLowerCase().endsWith(".json")&&!file.getName().toLowerCase().endsWith(".txt"))
|
||||||
|
continue;
|
||||||
|
try {
|
||||||
|
CustomSkinLoader.logger.info("Try to load Extra List.("+file.getName()+")");
|
||||||
|
String json=FileUtils.readFileToString(file, "UTF-8");
|
||||||
|
SkinSiteProfile ssp=CustomSkinLoader.GSON.fromJson(json, SkinSiteProfile.class);
|
||||||
|
CustomSkinLoader.logger.info("Successfully load Extra List.");
|
||||||
|
file.delete();
|
||||||
|
ProfileLoader.IProfileLoader loader=ProfileLoader.LOADERS.get(ssp.type.toLowerCase());
|
||||||
|
if(loader==null){
|
||||||
|
CustomSkinLoader.logger.info("Extra List will be ignore: Type '"+ssp.type+"' is not defined.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
boolean duplicate=false;
|
||||||
|
for(SkinSiteProfile ssp0:this.loadlist){
|
||||||
|
if(!ssp0.type.equalsIgnoreCase(ssp.type))
|
||||||
|
continue;
|
||||||
|
if(loader.compare(ssp0, ssp)){
|
||||||
|
duplicate=true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!duplicate){
|
||||||
|
adds.add(ssp);
|
||||||
|
CustomSkinLoader.logger.info("Successfully apply Extra List.("+ssp.name+")");
|
||||||
|
}else{
|
||||||
|
CustomSkinLoader.logger.info("Extra List will be ignore: Duplicate.("+ssp.name+")");
|
||||||
|
}
|
||||||
|
}catch (Exception e) {
|
||||||
|
CustomSkinLoader.logger.info("Failed to load Extra List.("+e.toString()+")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(adds.size()!=0){
|
||||||
|
adds.addAll(this.loadlist);
|
||||||
|
this.loadlist=adds;
|
||||||
|
writeConfig(this,true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initLocalFolder(){
|
||||||
|
for(SkinSiteProfile ssp:this.loadlist){
|
||||||
|
ProfileLoader.IProfileLoader loader=ProfileLoader.LOADERS.get(ssp.type.toLowerCase());
|
||||||
|
if(loader==null)
|
||||||
|
continue;
|
||||||
|
loader.init(ssp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Config initConfig() {
|
||||||
|
Config config=new Config(CustomSkinLoader.DEFAULT_LOAD_LIST);
|
||||||
|
writeConfig(config,false);
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
private static void writeConfig(Config config,boolean update){
|
||||||
|
String json=CustomSkinLoader.GSON.toJson(config);
|
||||||
|
if(CustomSkinLoader.CONFIG_FILE.exists())
|
||||||
|
CustomSkinLoader.CONFIG_FILE.delete();
|
||||||
|
try {
|
||||||
|
CustomSkinLoader.CONFIG_FILE.createNewFile();
|
||||||
|
FileUtils.write(CustomSkinLoader.CONFIG_FILE, json, "UTF-8");
|
||||||
|
CustomSkinLoader.logger.info("Successfully "+(update?"update":"create")+" config.");
|
||||||
|
} catch (Exception e) {
|
||||||
|
CustomSkinLoader.logger.info("Failed to "+(update?"update":"create")+" config.("+e.toString()+")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package customskinloader.config;
|
||||||
|
|
||||||
|
public class SkinSiteProfile {
|
||||||
|
//Common
|
||||||
|
public String name;
|
||||||
|
public String type;
|
||||||
|
public String userAgent;
|
||||||
|
|
||||||
|
//Mojang API
|
||||||
|
public String apiRoot;
|
||||||
|
public String sessionRoot;
|
||||||
|
|
||||||
|
//Json API
|
||||||
|
public String root;
|
||||||
|
|
||||||
|
//Legacy
|
||||||
|
public Boolean checkPNG;//Not suitable for local skin
|
||||||
|
public String skin;
|
||||||
|
public String model;
|
||||||
|
public String cape;
|
||||||
|
public String elytra;
|
||||||
|
|
||||||
|
public static SkinSiteProfile createMojangAPI(String name) {
|
||||||
|
SkinSiteProfile ssp = new SkinSiteProfile();
|
||||||
|
ssp.name = name;
|
||||||
|
ssp.type = "MojangAPI";
|
||||||
|
return ssp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SkinSiteProfile createCustomSkinAPI(String name, String root) {
|
||||||
|
SkinSiteProfile ssp = new SkinSiteProfile();
|
||||||
|
ssp.name = name;
|
||||||
|
ssp.type = "CustomSkinAPI";
|
||||||
|
ssp.root = root;
|
||||||
|
return ssp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SkinSiteProfile creatCustomSkinAPIPlus(String name, String root) {
|
||||||
|
SkinSiteProfile ssp = new SkinSiteProfile();
|
||||||
|
ssp.name = name;
|
||||||
|
ssp.type = "CustomSkinAPIPlus";
|
||||||
|
ssp.root = root;
|
||||||
|
return ssp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SkinSiteProfile createGlitchlessAPI(String name, String root) {
|
||||||
|
SkinSiteProfile ssp = new SkinSiteProfile();
|
||||||
|
ssp.name = name;
|
||||||
|
ssp.type = "GlitchlessAPI";
|
||||||
|
ssp.root = root;
|
||||||
|
return ssp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SkinSiteProfile createUniSkinAPI(String name, String root) {
|
||||||
|
SkinSiteProfile ssp = new SkinSiteProfile();
|
||||||
|
ssp.name = name;
|
||||||
|
ssp.type = "UniSkinAPI";
|
||||||
|
ssp.root = root;
|
||||||
|
return ssp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SkinSiteProfile createLegacy(String name, String skin, String cape, String elytra) {
|
||||||
|
SkinSiteProfile ssp = new SkinSiteProfile();
|
||||||
|
ssp.name = name;
|
||||||
|
ssp.type = "Legacy";
|
||||||
|
ssp.checkPNG = false;
|
||||||
|
ssp.skin = skin;
|
||||||
|
ssp.model = "auto";
|
||||||
|
ssp.cape = cape;
|
||||||
|
ssp.elytra = elytra;
|
||||||
|
return ssp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SkinSiteProfile createElyByAPI(String name) {
|
||||||
|
SkinSiteProfile ssp = new SkinSiteProfile();
|
||||||
|
ssp.name = name;
|
||||||
|
ssp.type = "ElyByAPI";
|
||||||
|
return ssp;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
package customskinloader.fake;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||||
|
|
||||||
|
import customskinloader.CustomSkinLoader;
|
||||||
|
import customskinloader.utils.MinecraftUtil;
|
||||||
|
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||||
|
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||||
|
import net.minecraft.client.renderer.texture.SimpleTexture;
|
||||||
|
import net.minecraft.client.renderer.texture.TextureManager;
|
||||||
|
import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||||
|
import net.minecraft.client.resources.SkinManager;
|
||||||
|
import net.minecraft.client.resources.SkinManager.SkinAvailableCallback;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.StringUtils;
|
||||||
|
|
||||||
|
public class FakeClientPlayer {
|
||||||
|
//For Legacy Skin
|
||||||
|
public static ThreadDownloadImageData getDownloadImageSkin(ResourceLocation resourceLocationIn, String username) {
|
||||||
|
//CustomSkinLoader.logger.debug("FakeClientPlayer/getDownloadImageSkin "+username);
|
||||||
|
TextureManager textman = MinecraftUtil.getTextureManager();
|
||||||
|
ITextureObject ito = textman.getTexture(resourceLocationIn);
|
||||||
|
|
||||||
|
if (ito == null || !(ito instanceof ThreadDownloadImageData)) {
|
||||||
|
//if Legacy Skin for username not loaded yet
|
||||||
|
SkinManager skinman = MinecraftUtil.getSkinManager();
|
||||||
|
UUID offlineUUID = getOfflineUUID(username);
|
||||||
|
GameProfile offlineProfile = new GameProfile(offlineUUID, username);
|
||||||
|
|
||||||
|
//Load Default Skin
|
||||||
|
ResourceLocation defaultSkin = DefaultPlayerSkin.getDefaultSkin(offlineUUID);
|
||||||
|
ITextureObject defaultSkinObj = new SimpleTexture(defaultSkin);
|
||||||
|
textman.loadTexture(resourceLocationIn, defaultSkinObj);
|
||||||
|
|
||||||
|
//Load Skin from SkinManager
|
||||||
|
skinman.loadProfileTextures(offlineProfile, new LegacyBuffer(resourceLocationIn), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ito instanceof ThreadDownloadImageData)
|
||||||
|
return (ThreadDownloadImageData) ito;
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResourceLocation getLocationSkin(String username) {
|
||||||
|
//CustomSkinLoader.logger.debug("FakeClientPlayer/getLocationSkin "+username);
|
||||||
|
return new ResourceLocation("skins/legacy-" + StringUtils.stripControlCodes(username));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UUID getOfflineUUID(String username) {
|
||||||
|
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + username).getBytes());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<ResourceLocation, ITextureObject> textureCache = Maps.newHashMap();
|
||||||
|
|
||||||
|
public static class LegacyBuffer implements SkinAvailableCallback {
|
||||||
|
ResourceLocation resourceLocationIn;
|
||||||
|
boolean loaded = false;
|
||||||
|
|
||||||
|
public LegacyBuffer(ResourceLocation resourceLocationIn) {
|
||||||
|
CustomSkinLoader.logger.debug("Loading Legacy Texture (" + resourceLocationIn + ")");
|
||||||
|
this.resourceLocationIn = resourceLocationIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void skinAvailable(Type typeIn, ResourceLocation location, MinecraftProfileTexture profileTexture) {
|
||||||
|
if (typeIn != Type.SKIN || loaded)
|
||||||
|
return;
|
||||||
|
|
||||||
|
TextureManager textman = MinecraftUtil.getTextureManager();
|
||||||
|
ITextureObject ito = textman.getTexture(location);
|
||||||
|
if (ito == null)
|
||||||
|
ito = textureCache.get(location);
|
||||||
|
if (ito == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
loaded = true;
|
||||||
|
textman.loadTexture(resourceLocationIn, ito);
|
||||||
|
CustomSkinLoader.logger.debug("Legacy Texture (" + resourceLocationIn + ") Loaded as " +
|
||||||
|
ito.toString() + " (" + location + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,183 @@
|
|||||||
|
package customskinloader.fake;
|
||||||
|
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
import customskinloader.CustomSkinLoader;
|
||||||
|
import customskinloader.fake.texture.FakeBufferedImage;
|
||||||
|
import customskinloader.fake.texture.FakeImage;
|
||||||
|
import customskinloader.fake.texture.FakeNativeImage;
|
||||||
|
import net.minecraft.client.renderer.IImageBuffer;
|
||||||
|
import net.minecraft.client.renderer.texture.NativeImage;
|
||||||
|
|
||||||
|
public class FakeSkinBuffer implements IImageBuffer {
|
||||||
|
private int ratio = 1;
|
||||||
|
private FakeImage image = null;
|
||||||
|
|
||||||
|
//parseUserSkin for 1.15+
|
||||||
|
public static NativeImage processLegacySkin(NativeImage image, Runnable processTask) {
|
||||||
|
if (processTask instanceof IImageBuffer) {
|
||||||
|
return ((IImageBuffer) processTask).func_195786_a(image);
|
||||||
|
}
|
||||||
|
return new FakeSkinBuffer().func_195786_a(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
//parseUserSkin for 1.13+
|
||||||
|
public NativeImage func_195786_a(NativeImage image) {
|
||||||
|
if (image == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
FakeImage img = parseUserSkin(new FakeNativeImage(image));
|
||||||
|
if (img instanceof FakeNativeImage)
|
||||||
|
return ((FakeNativeImage) img).getImage();
|
||||||
|
|
||||||
|
CustomSkinLoader.logger.warning("Failed to parseUserSkin(func_195786_a).");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//parseUserSkin for 1.12.2-
|
||||||
|
public BufferedImage parseUserSkin(BufferedImage image) {
|
||||||
|
if (image == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
FakeImage img = parseUserSkin(new FakeBufferedImage(image));
|
||||||
|
if (img instanceof FakeBufferedImage)
|
||||||
|
return ((FakeBufferedImage) img).getImage();
|
||||||
|
|
||||||
|
CustomSkinLoader.logger.warning("Failed to parseUserSkin.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FakeImage parseUserSkin(FakeImage image) {
|
||||||
|
if (image == null) return null;
|
||||||
|
this.ratio = image.getWidth() / 64;
|
||||||
|
|
||||||
|
if (image.getHeight() != image.getWidth()) {//Single Layer
|
||||||
|
//Create a new image and copy origin image data
|
||||||
|
FakeImage img = image.createImage(64 * ratio, 64 * ratio);
|
||||||
|
img.copyImageData(image);
|
||||||
|
image.close();
|
||||||
|
image = img;
|
||||||
|
image.fillArea(0 * ratio, 32 * ratio, 64 * ratio, 32 * ratio);
|
||||||
|
|
||||||
|
//Right Leg -> Left Leg
|
||||||
|
image.copyArea(4 * ratio, 16 * ratio, 16 * ratio, 32 * ratio, 4 * ratio, 4 * ratio, true, false);//Top
|
||||||
|
image.copyArea(8 * ratio, 16 * ratio, 16 * ratio, 32 * ratio, 4 * ratio, 4 * ratio, true, false);//Bottom
|
||||||
|
image.copyArea(0 * ratio, 20 * ratio, 24 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Right
|
||||||
|
image.copyArea(4 * ratio, 20 * ratio, 16 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Front
|
||||||
|
image.copyArea(8 * ratio, 20 * ratio, 8 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Left
|
||||||
|
image.copyArea(12 * ratio, 20 * ratio, 16 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Back
|
||||||
|
//Right Arm -> Left Arm
|
||||||
|
image.copyArea(44 * ratio, 16 * ratio, -8 * ratio, 32 * ratio, 4 * ratio, 4 * ratio, true, false);//Top
|
||||||
|
image.copyArea(48 * ratio, 16 * ratio, -8 * ratio, 32 * ratio, 4 * ratio, 4 * ratio, true, false);//Bottom
|
||||||
|
image.copyArea(40 * ratio, 20 * ratio, 0 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Right
|
||||||
|
image.copyArea(44 * ratio, 20 * ratio, -8 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Front
|
||||||
|
image.copyArea(48 * ratio, 20 * ratio, -16 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Left
|
||||||
|
image.copyArea(52 * ratio, 20 * ratio, -8 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Back
|
||||||
|
}
|
||||||
|
|
||||||
|
this.image = image;
|
||||||
|
setAreaDueToConfig(0 * ratio, 0 * ratio, 32 * ratio, 16 * ratio);//Head - 1
|
||||||
|
setAreaTransparent(32 * ratio, 0 * ratio, 64 * ratio, 16 * ratio);//Head - 2
|
||||||
|
setAreaDueToConfig(16 * ratio, 16 * ratio, 40 * ratio, 32 * ratio);//Body - 1
|
||||||
|
setAreaTransparent(16 * ratio, 32 * ratio, 40 * ratio, 48 * ratio);//Body - 2
|
||||||
|
|
||||||
|
setAreaDueToConfig(40 * ratio, 16 * ratio, 56 * ratio, 32 * ratio);//Right Arm - 1
|
||||||
|
setAreaTransparent(40 * ratio, 32 * ratio, 56 * ratio, 48 * ratio);//Right Arm - 2
|
||||||
|
setAreaDueToConfig(0 * ratio, 16 * ratio, 16 * ratio, 32 * ratio);//Right Leg - 1
|
||||||
|
setAreaTransparent(0 * ratio, 32 * ratio, 16 * ratio, 48 * ratio);//Right Leg - 2
|
||||||
|
|
||||||
|
setAreaDueToConfig(32 * ratio, 48 * ratio, 48 * ratio, 64 * ratio);//Left Arm - 1
|
||||||
|
setAreaTransparent(48 * ratio, 48 * ratio, 64 * ratio, 64 * ratio);//Left Arm - 2
|
||||||
|
setAreaDueToConfig(16 * ratio, 48 * ratio, 32 * ratio, 64 * ratio);//Left Leg - 1
|
||||||
|
setAreaTransparent(0 * ratio, 48 * ratio, 16 * ratio, 64 * ratio);//Left Leg - 2
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Judge the type of skin
|
||||||
|
* Must be called after parseUserSkin
|
||||||
|
*
|
||||||
|
* @return type of skin (slim / default)
|
||||||
|
* @since 14.9
|
||||||
|
*/
|
||||||
|
public String judgeType() {
|
||||||
|
if (this.image == null)
|
||||||
|
return "default";
|
||||||
|
int bgColor = image.getRGBA(63 * ratio, 20 * ratio);
|
||||||
|
/*
|
||||||
|
* If background is transparent, all the pixels in ((54, 20), (55, 31)) areas is transparent,
|
||||||
|
* which means it is Alex model.
|
||||||
|
* If background is opaque, all the pixels in ((54, 20), (55, 31)) areas is same with background,
|
||||||
|
* which means it is Alex model.
|
||||||
|
* Otherwise, it is Steve model.
|
||||||
|
* */
|
||||||
|
Predicate<Integer> predicate =
|
||||||
|
getA(bgColor) == 0 ? (c) -> getA(c) == 0 : (c) -> c == bgColor;
|
||||||
|
for (int x = 54 * ratio; x <= 55 * ratio; ++x) {
|
||||||
|
for (int y = 20 * ratio; y <= 31 * ratio; ++y) {
|
||||||
|
int color = image.getRGBA(x, y);
|
||||||
|
if (!predicate.test(color)) {
|
||||||
|
return "default";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "slim";
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 2^24-1
|
||||||
|
* 00000000 11111111 11111111 11111111 */
|
||||||
|
private static final int A = 16777215;
|
||||||
|
private static final int WHITE = getARGB(255, 255, 255, 255);
|
||||||
|
private static final int BLACK = getARGB(255, 0, 0, 0);
|
||||||
|
|
||||||
|
private boolean isFilled(int x0, int y0, int x1, int y1) {
|
||||||
|
int data = image.getRGBA(x0, y0);
|
||||||
|
if (data != WHITE && data != BLACK)
|
||||||
|
return false;
|
||||||
|
for (int x = x0; x < x1; ++x)
|
||||||
|
for (int y = y0; y < y1; ++y)
|
||||||
|
if (image.getRGBA(x, y) != data)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setAreaTransparent(int x0, int y0, int x1, int y1) {
|
||||||
|
if (!isFilled(x0, y0, x1, y1))
|
||||||
|
return;
|
||||||
|
for (int x = x0; x < x1; ++x)
|
||||||
|
for (int y = y0; y < y1; ++y)
|
||||||
|
image.setRGBA(x, y, image.getRGBA(x, y) & A);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -2^24
|
||||||
|
* 00000001 00000000 00000000 00000000 ->
|
||||||
|
* 11111110 11111111 11111111 11111111 ->
|
||||||
|
* 11111111 00000000 00000000 00000000 */
|
||||||
|
private static final int B = -16777216;
|
||||||
|
|
||||||
|
private void setAreaOpaque(int x0, int y0, int x1, int y1) {
|
||||||
|
for (int x = x0; x < x1; ++x)
|
||||||
|
for (int y = y0; y < y1; ++y)
|
||||||
|
image.setRGBA(x, y, image.getRGBA(x, y) | B);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setAreaDueToConfig(int x0, int y0, int x1, int y1) {
|
||||||
|
if (customskinloader.CustomSkinLoader.config.enableTransparentSkin)
|
||||||
|
setAreaTransparent(x0, y0, x1, y1);
|
||||||
|
else
|
||||||
|
setAreaOpaque(x0, y0, x1, y1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void skinAvailable() {
|
||||||
|
//A callback when skin loaded, nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getARGB(int a, int r, int g, int b) {
|
||||||
|
return (a << 24) | (r << 16) | (g << 8) | b;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getA(int argb) {
|
||||||
|
return (argb & B) >>> 24;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
package customskinloader.fake;
|
||||||
|
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||||
|
import customskinloader.CustomSkinLoader;
|
||||||
|
import customskinloader.fake.itf.IFakeMinecraft;
|
||||||
|
import customskinloader.fake.itf.IFakeTextureManager_1;
|
||||||
|
import customskinloader.fake.itf.IFakeTextureManager_2;
|
||||||
|
import customskinloader.utils.HttpTextureUtil;
|
||||||
|
import customskinloader.utils.HttpTextureUtil.HttpTextureInfo;
|
||||||
|
import customskinloader.utils.MinecraftUtil;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.IImageBuffer;
|
||||||
|
import net.minecraft.client.renderer.texture.SimpleTexture;
|
||||||
|
import net.minecraft.client.renderer.texture.Texture;
|
||||||
|
import net.minecraft.client.renderer.texture.TextureManager;
|
||||||
|
import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||||
|
import net.minecraft.client.resources.SkinManager.SkinAvailableCallback;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
public class FakeSkinManager {
|
||||||
|
private static final ExecutorService THREAD_POOL = new ThreadPoolExecutor(CustomSkinLoader.config.threadPoolSize, CustomSkinLoader.config.threadPoolSize, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue<>());
|
||||||
|
private final TextureManager textureManager;
|
||||||
|
|
||||||
|
private final Map<ResourceLocation, MinecraftProfileTexture> modelCache = new HashMap<>();
|
||||||
|
|
||||||
|
public FakeSkinManager(TextureManager textureManagerInstance, File skinCacheDirectory, MinecraftSessionService sessionService) {
|
||||||
|
this.textureManager = textureManagerInstance;
|
||||||
|
HttpTextureUtil.defaultCacheDir = skinCacheDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResourceLocation loadSkin(MinecraftProfileTexture profileTexture, Type textureType) {
|
||||||
|
return this.loadSkin(profileTexture, textureType, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResourceLocation loadSkin(final MinecraftProfileTexture profileTexture, final Type textureType, final SkinAvailableCallback skinAvailableCallback) {
|
||||||
|
HttpTextureInfo info = HttpTextureUtil.toHttpTextureInfo(profileTexture.getUrl());
|
||||||
|
|
||||||
|
final ResourceLocation resourcelocation = new ResourceLocation("skins/" + info.hash);
|
||||||
|
|
||||||
|
if (((IFakeTextureManager_1) this.textureManager).func_229267_b_(resourcelocation) != null) {//Have already loaded
|
||||||
|
makeCallback(skinAvailableCallback, textureType, resourcelocation, modelCache.getOrDefault(resourcelocation, profileTexture));
|
||||||
|
} else {
|
||||||
|
SimpleTexture threaddownloadimagedata = MinecraftUtil.createThreadDownloadImageData(info.cacheFile, info.url, DefaultPlayerSkin.getDefaultSkinLegacy(), new BaseBuffer(skinAvailableCallback, textureType, resourcelocation, profileTexture), textureType);
|
||||||
|
if (skinAvailableCallback instanceof FakeClientPlayer.LegacyBuffer)//Cache for client player
|
||||||
|
FakeClientPlayer.textureCache.put(resourcelocation, threaddownloadimagedata);
|
||||||
|
((IFakeTextureManager_2) this.textureManager).func_229263_a_(resourcelocation, (Texture) threaddownloadimagedata);
|
||||||
|
}
|
||||||
|
return resourcelocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadProfileTextures(final GameProfile profile, final SkinAvailableCallback skinAvailableCallback, final boolean requireSecure) {
|
||||||
|
THREAD_POOL.execute(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
final Map<Type, MinecraftProfileTexture> map = Maps.newHashMap();
|
||||||
|
map.putAll(customskinloader.CustomSkinLoader.loadProfile(profile));
|
||||||
|
|
||||||
|
((IFakeMinecraft) Minecraft.getMinecraft()).execute(() -> {
|
||||||
|
for (Type type : Type.values()) {
|
||||||
|
if (map.containsKey(type)) {
|
||||||
|
CustomSkinLoader.logger.debug("Loading type:" + type);
|
||||||
|
FakeSkinManager.this.loadSkin(map.get(type), type, skinAvailableCallback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Type, MinecraftProfileTexture> loadSkinFromCache(GameProfile profile) {
|
||||||
|
return CustomSkinLoader.loadProfileFromCache(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void makeCallback(SkinAvailableCallback callback, Type type, ResourceLocation location, MinecraftProfileTexture texture) {
|
||||||
|
if (callback != null)
|
||||||
|
callback.skinAvailable(type, location, texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class BaseBuffer implements IImageBuffer {
|
||||||
|
private IImageBuffer buffer;
|
||||||
|
|
||||||
|
private SkinAvailableCallback callback;
|
||||||
|
private Type type;
|
||||||
|
private ResourceLocation location;
|
||||||
|
private MinecraftProfileTexture texture;
|
||||||
|
|
||||||
|
public BaseBuffer(SkinAvailableCallback callback, Type type, ResourceLocation location, MinecraftProfileTexture texture) {
|
||||||
|
this.buffer = (type == Type.SKIN ? new FakeSkinBuffer() : null);
|
||||||
|
|
||||||
|
this.callback = callback;
|
||||||
|
this.type = type;
|
||||||
|
this.location = location;
|
||||||
|
this.texture = texture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public net.minecraft.client.renderer.texture.NativeImage func_195786_a(net.minecraft.client.renderer.texture.NativeImage image) {
|
||||||
|
return buffer instanceof FakeSkinBuffer ? ((FakeSkinBuffer) buffer).func_195786_a(image) : image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BufferedImage parseUserSkin(BufferedImage image) {
|
||||||
|
return buffer == null ? image : buffer.parseUserSkin(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void skinAvailable() {
|
||||||
|
if (buffer != null) {
|
||||||
|
buffer.skinAvailable();
|
||||||
|
if ("auto".equals(texture.getMetadata("model")) && buffer instanceof FakeSkinBuffer) {
|
||||||
|
//Auto judge skin type
|
||||||
|
Map<String, String> metadata = Maps.newHashMap();
|
||||||
|
String type = ((FakeSkinBuffer) buffer).judgeType();
|
||||||
|
metadata.put("model", type);
|
||||||
|
texture = new MinecraftProfileTexture(texture.getUrl(), metadata);
|
||||||
|
FakeSkinManager.this.modelCache.put(location, texture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FakeSkinManager.makeCallback(callback, type, location, texture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package customskinloader.fake.itf;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
||||||
|
public interface IFakeMinecraft {
|
||||||
|
default void execute(Runnable runnable) {
|
||||||
|
((Minecraft) this).addScheduledTask(runnable);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package customskinloader.fake.itf;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||||
|
import net.minecraft.client.renderer.texture.Texture;
|
||||||
|
import net.minecraft.client.renderer.texture.TextureManager;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
public interface IFakeTextureManager_1 {
|
||||||
|
default boolean func_229263_a_(ResourceLocation textureLocation, Texture textureObj) {
|
||||||
|
return ((TextureManager) this).loadTexture(textureLocation, (ITextureObject) textureObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
default Texture func_229267_b_(ResourceLocation textureLocation) {
|
||||||
|
return (Texture) ((TextureManager) this).getTexture(textureLocation);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package customskinloader.fake.itf;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.texture.Texture;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
public interface IFakeTextureManager_2 {
|
||||||
|
default void func_229263_a_(ResourceLocation textureLocation, Texture textureObj) {
|
||||||
|
((IFakeTextureManager_1) this).func_229263_a_(textureLocation, textureObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package customskinloader.fake.texture;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
|
public class FakeBufferedImage implements FakeImage {
|
||||||
|
private BufferedImage image;
|
||||||
|
private Graphics graphics;
|
||||||
|
|
||||||
|
public FakeBufferedImage(int width, int height) {
|
||||||
|
this(new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB));
|
||||||
|
}
|
||||||
|
|
||||||
|
public FakeBufferedImage(BufferedImage image) {
|
||||||
|
this.image = image;
|
||||||
|
graphics = image.getGraphics();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BufferedImage getImage() {
|
||||||
|
graphics.dispose();
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FakeImage createImage(int width, int height) {
|
||||||
|
return new FakeBufferedImage(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWidth() {
|
||||||
|
return image.getWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHeight() {
|
||||||
|
return image.getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRGBA(int x, int y) {
|
||||||
|
return image.getRGB(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRGBA(int x, int y, int rgba) {
|
||||||
|
image.setRGB(x, y, rgba);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void copyImageData(FakeImage image) {
|
||||||
|
if (!(image instanceof FakeBufferedImage)) return;
|
||||||
|
BufferedImage img = ((FakeBufferedImage) image).getImage();
|
||||||
|
graphics.drawImage(img, 0, 0, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fillArea(int x0, int y0, int width, int height) {
|
||||||
|
graphics.setColor(new Color(0, 0, 0, 0));
|
||||||
|
graphics.fillRect(x0, y0, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void copyArea(int x0, int y0, int dx, int dy, int width, int height, boolean reversex, boolean reversey) {
|
||||||
|
int x1 = x0 + width, x2 = x0 + dx, x3 = x2 + width;
|
||||||
|
int y1 = y0 + height, y2 = y0 + dy, y3 = y2 + height;
|
||||||
|
graphics.drawImage(image,
|
||||||
|
reversex ? x3 : x2, reversey ? y3 : y2,
|
||||||
|
reversex ? x2 : x3, reversey ? y2 : y3,
|
||||||
|
x0, y0, x1, y1, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() {
|
||||||
|
graphics.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package customskinloader.fake.texture;
|
||||||
|
|
||||||
|
public interface FakeImage {
|
||||||
|
FakeImage createImage(int width, int height);
|
||||||
|
|
||||||
|
int getWidth();
|
||||||
|
|
||||||
|
int getHeight();
|
||||||
|
|
||||||
|
int getRGBA(int x, int y);
|
||||||
|
|
||||||
|
void setRGBA(int x, int y, int rgba);
|
||||||
|
|
||||||
|
void copyImageData(FakeImage image);
|
||||||
|
|
||||||
|
void fillArea(int x0, int y0, int width, int height);
|
||||||
|
|
||||||
|
void copyArea(int x0, int y0, int dx, int dy, int width, int height, boolean reversex, boolean reversey);
|
||||||
|
|
||||||
|
void close();
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package customskinloader.fake.texture;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.texture.NativeImage;
|
||||||
|
|
||||||
|
public class FakeNativeImage implements FakeImage {
|
||||||
|
private NativeImage image;
|
||||||
|
|
||||||
|
public FakeNativeImage(int width, int height) {
|
||||||
|
this(new NativeImage(width, height, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
public FakeNativeImage(NativeImage image) {
|
||||||
|
this.image = image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NativeImage getImage() {
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FakeImage createImage(int width, int height) {
|
||||||
|
return new FakeNativeImage(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWidth() {
|
||||||
|
return image.func_195702_a();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHeight() {
|
||||||
|
return image.func_195714_b();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRGBA(int x, int y) {
|
||||||
|
return image.func_195709_a(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRGBA(int x, int y, int rgba) {
|
||||||
|
image.func_195700_a(x, y, rgba);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void copyImageData(FakeImage image) {
|
||||||
|
if (!(image instanceof FakeNativeImage)) return;
|
||||||
|
this.image.func_195703_a(((FakeNativeImage) image).getImage());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fillArea(int x0, int y0, int width, int height) {
|
||||||
|
image.func_195715_a(x0, y0, width, height, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void copyArea(int x0, int y0, int dx, int dy, int width, int height, boolean reversex, boolean reversey) {
|
||||||
|
image.func_195699_a(x0, y0, dx, dy, width, height, reversex, reversey);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
package customskinloader.loader;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
|
||||||
|
import customskinloader.CustomSkinLoader;
|
||||||
|
import customskinloader.config.SkinSiteProfile;
|
||||||
|
import customskinloader.loader.jsonapi.*;
|
||||||
|
import customskinloader.profile.UserProfile;
|
||||||
|
import customskinloader.utils.HttpRequestUtil;
|
||||||
|
import customskinloader.utils.HttpUtil0;
|
||||||
|
import customskinloader.utils.HttpRequestUtil.HttpRequest;
|
||||||
|
import customskinloader.utils.HttpRequestUtil.HttpResponce;
|
||||||
|
|
||||||
|
public class JsonAPILoader implements ProfileLoader.IProfileLoader {
|
||||||
|
|
||||||
|
public interface IJsonAPI {
|
||||||
|
String toJsonUrl(String root, String username);
|
||||||
|
String getPayload(SkinSiteProfile ssp);
|
||||||
|
UserProfile toUserProfile(String root, String json, boolean local);
|
||||||
|
String getName();
|
||||||
|
}
|
||||||
|
public static class ErrorProfile{
|
||||||
|
public int errno;
|
||||||
|
public String msg;
|
||||||
|
}
|
||||||
|
public enum Type{
|
||||||
|
CustomSkinAPI(new CustomSkinAPI()),
|
||||||
|
CustomSkinAPIPlus(new CustomSkinAPIPlus()),
|
||||||
|
UniSkinAPI(new UniSkinAPI()),
|
||||||
|
ElyByAPI(new ElyByAPI()),
|
||||||
|
GlitchlessAPI(new GlitchlessAPI());
|
||||||
|
public IJsonAPI jsonAPI;
|
||||||
|
Type(IJsonAPI jsonAPI){
|
||||||
|
this.jsonAPI=jsonAPI;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Type type;
|
||||||
|
public JsonAPILoader(Type type){
|
||||||
|
this.type=type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) throws Exception {
|
||||||
|
String username=gameProfile.getName();
|
||||||
|
if(StringUtils.isEmpty(ssp.root) && type!=Type.ElyByAPI){
|
||||||
|
CustomSkinLoader.logger.info("Root not defined.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
boolean local = HttpUtil0.isLocal(ssp.root);
|
||||||
|
String jsonUrl=type.jsonAPI.toJsonUrl(ssp.root, username);
|
||||||
|
String json;
|
||||||
|
if(local){
|
||||||
|
File jsonFile = new File(CustomSkinLoader.DATA_DIR, jsonUrl);
|
||||||
|
if(!jsonFile.exists()){
|
||||||
|
CustomSkinLoader.logger.info("Profile File not found.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
json=IOUtils.toString(new FileInputStream(jsonFile), "UTF-8");
|
||||||
|
}else{
|
||||||
|
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest(jsonUrl).setCacheTime(90).setUserAgent(ssp.userAgent).setPayload(type.jsonAPI.getPayload(ssp)));
|
||||||
|
json=responce.content;
|
||||||
|
}
|
||||||
|
if(json==null||json.equals("")){
|
||||||
|
CustomSkinLoader.logger.info("Profile not found.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorProfile profile=CustomSkinLoader.GSON.fromJson(json, ErrorProfile.class);
|
||||||
|
if(profile.errno!=0){
|
||||||
|
CustomSkinLoader.logger.info("Error "+profile.errno+": "+profile.msg);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
UserProfile p=type.jsonAPI.toUserProfile(ssp.root, json, local);
|
||||||
|
if(p==null||p.isEmpty()){
|
||||||
|
CustomSkinLoader.logger.info("Both skin and cape not found.");
|
||||||
|
return null;
|
||||||
|
}else{
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public boolean compare(SkinSiteProfile ssp0, SkinSiteProfile ssp1) {
|
||||||
|
return !StringUtils.isNoneEmpty(ssp0.root) || ssp0.root.equalsIgnoreCase(ssp1.root);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return type.jsonAPI.getName();
|
||||||
|
}
|
||||||
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||||
|
@Override
|
||||||
|
public void init(SkinSiteProfile ssp) {
|
||||||
|
if(HttpUtil0.isLocal(ssp.root)){
|
||||||
|
File f=new File(ssp.root);
|
||||||
|
if(!f.exists())
|
||||||
|
f.mkdirs();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
package customskinloader.loader;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import com.mojang.util.UUIDTypeAdapter;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
|
||||||
|
import customskinloader.CustomSkinLoader;
|
||||||
|
import customskinloader.config.SkinSiteProfile;
|
||||||
|
import customskinloader.profile.ModelManager0;
|
||||||
|
import customskinloader.profile.UserProfile;
|
||||||
|
import customskinloader.utils.HttpRequestUtil;
|
||||||
|
import customskinloader.utils.HttpRequestUtil.HttpRequest;
|
||||||
|
import customskinloader.utils.HttpRequestUtil.HttpResponce;
|
||||||
|
import customskinloader.utils.HttpTextureUtil;
|
||||||
|
import customskinloader.utils.HttpUtil0;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
public class LegacyLoader implements ProfileLoader.IProfileLoader {
|
||||||
|
public static final String USERNAME_PLACEHOLDER = "{USERNAME}";
|
||||||
|
public static final String UUID_PLACEHOLDER = "{UUID}";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) throws Exception {
|
||||||
|
String username = gameProfile.getName();
|
||||||
|
UserProfile profile = new UserProfile();
|
||||||
|
if (StringUtils.isNoneEmpty(ssp.skin)) {
|
||||||
|
String skin = expandURL(ssp.skin, username);
|
||||||
|
if (HttpUtil0.isLocal(ssp.skin)) {
|
||||||
|
File skinFile = new File(CustomSkinLoader.DATA_DIR, skin);
|
||||||
|
if (skinFile.exists() && skinFile.isFile())
|
||||||
|
profile.skinUrl = HttpTextureUtil.getLocalLegacyFakeUrl(skin, HttpTextureUtil.getHash(skin, skinFile.length(), skinFile.lastModified()));
|
||||||
|
} else {
|
||||||
|
HttpResponce responce = HttpRequestUtil.makeHttpRequest(new HttpRequest(skin).setUserAgent(ssp.userAgent).setCheckPNG(ssp.checkPNG != null && ssp.checkPNG).setLoadContent(false).setCacheTime(90));
|
||||||
|
if (responce.success)
|
||||||
|
profile.skinUrl = HttpTextureUtil.getLegacyFakeUrl(skin);
|
||||||
|
}
|
||||||
|
profile.model = profile.hasSkinUrl() ? ssp.model : null;
|
||||||
|
}
|
||||||
|
if (StringUtils.isNoneEmpty(ssp.cape)) {
|
||||||
|
String cape = expandURL(ssp.cape, username);
|
||||||
|
if (HttpUtil0.isLocal(ssp.cape)) {
|
||||||
|
File capeFile = new File(CustomSkinLoader.DATA_DIR, cape);
|
||||||
|
if (capeFile.exists() && capeFile.isFile())
|
||||||
|
profile.capeUrl = HttpTextureUtil.getLocalLegacyFakeUrl(cape, HttpTextureUtil.getHash(cape, capeFile.length(), capeFile.lastModified()));
|
||||||
|
} else {
|
||||||
|
HttpResponce responce = HttpRequestUtil.makeHttpRequest(new HttpRequest(cape).setUserAgent(ssp.userAgent).setCheckPNG(ssp.checkPNG != null && ssp.checkPNG).setLoadContent(false).setCacheTime(90));
|
||||||
|
if (responce.success)
|
||||||
|
profile.capeUrl = HttpTextureUtil.getLegacyFakeUrl(cape);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ModelManager0.isElytraSupported() && StringUtils.isNoneEmpty(ssp.elytra)) {
|
||||||
|
String elytra = expandURL(ssp.elytra, username);
|
||||||
|
if (HttpUtil0.isLocal(ssp.elytra)) {
|
||||||
|
File elytraFile = new File(CustomSkinLoader.DATA_DIR, elytra);
|
||||||
|
if (elytraFile.exists() && elytraFile.isFile())
|
||||||
|
profile.elytraUrl = HttpTextureUtil.getLocalLegacyFakeUrl(elytra, HttpTextureUtil.getHash(elytra, elytraFile.length(), elytraFile.lastModified()));
|
||||||
|
} else {
|
||||||
|
HttpResponce responce = HttpRequestUtil.makeHttpRequest(new HttpRequest(elytra).setUserAgent(ssp.userAgent).setCheckPNG(ssp.checkPNG != null && ssp.checkPNG).setLoadContent(false).setCacheTime(90));
|
||||||
|
if (responce.success)
|
||||||
|
profile.elytraUrl = HttpTextureUtil.getLegacyFakeUrl(elytra);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (profile.isEmpty()) {
|
||||||
|
CustomSkinLoader.logger.info("Both skin and cape not found.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return profile;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean compare(SkinSiteProfile ssp0, SkinSiteProfile ssp1) {
|
||||||
|
return (!StringUtils.isNoneEmpty(ssp0.skin) || ssp0.skin.equalsIgnoreCase(ssp1.skin)) || (!StringUtils.isNoneEmpty(ssp0.cape) || ssp0.cape.equalsIgnoreCase(ssp1.cape));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "Legacy";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(SkinSiteProfile ssp) {
|
||||||
|
if (HttpUtil0.isLocal(ssp.skin))
|
||||||
|
initFolder(ssp.skin);
|
||||||
|
if (HttpUtil0.isLocal(ssp.cape))
|
||||||
|
initFolder(ssp.cape);
|
||||||
|
if (HttpUtil0.isLocal(ssp.elytra))
|
||||||
|
initFolder(ssp.elytra);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||||
|
private void initFolder(String target) {
|
||||||
|
String file = target.replace(USERNAME_PLACEHOLDER, "init");
|
||||||
|
File folder = new File(CustomSkinLoader.DATA_DIR, file).getParentFile();
|
||||||
|
if (folder != null && !folder.exists())
|
||||||
|
folder.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String expandURL(String url, String username) {
|
||||||
|
String t = url.replace(USERNAME_PLACEHOLDER, username);
|
||||||
|
if (t.contains(UUID_PLACEHOLDER))
|
||||||
|
t = t.replace(UUID_PLACEHOLDER, getMojangUUID(username));
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
private String getMojangUUID(String username) {
|
||||||
|
GameProfile profile = MojangAPILoader.loadGameProfile(MojangAPILoader.getMojangApiRoot(), username);
|
||||||
|
if (profile == null) {
|
||||||
|
CustomSkinLoader.logger.info("UUID for %s not found.", username);
|
||||||
|
return "{ABORT}";
|
||||||
|
}
|
||||||
|
return UUIDTypeAdapter.fromUUID(profile.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,139 @@
|
|||||||
|
package customskinloader.loader;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import org.apache.commons.codec.Charsets;
|
||||||
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||||
|
import com.mojang.authlib.properties.Property;
|
||||||
|
import com.mojang.authlib.properties.PropertyMap;
|
||||||
|
import com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse;
|
||||||
|
import com.mojang.authlib.yggdrasil.response.MinecraftTexturesPayload;
|
||||||
|
import com.mojang.util.UUIDTypeAdapter;
|
||||||
|
|
||||||
|
import customskinloader.CustomSkinLoader;
|
||||||
|
import customskinloader.config.SkinSiteProfile;
|
||||||
|
import customskinloader.profile.ModelManager0;
|
||||||
|
import customskinloader.profile.UserProfile;
|
||||||
|
import customskinloader.utils.HttpRequestUtil;
|
||||||
|
import customskinloader.utils.HttpRequestUtil.HttpRequest;
|
||||||
|
import customskinloader.utils.HttpRequestUtil.HttpResponce;
|
||||||
|
|
||||||
|
public class MojangAPILoader implements ProfileLoader.IProfileLoader {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) throws Exception {
|
||||||
|
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = getTextures(gameProfile);
|
||||||
|
if (!map.isEmpty()) {
|
||||||
|
CustomSkinLoader.logger.info("Default profile will be used.");
|
||||||
|
return ModelManager0.toUserProfile(map);
|
||||||
|
}
|
||||||
|
String username = gameProfile.getName();
|
||||||
|
GameProfile newGameProfile = loadGameProfile(ssp.apiRoot, username);
|
||||||
|
if (newGameProfile == null) {
|
||||||
|
CustomSkinLoader.logger.info("Profile not found.(" + username + "'s profile not found.)");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
newGameProfile = fillGameProfile(ssp.sessionRoot, newGameProfile);
|
||||||
|
map = getTextures(newGameProfile);
|
||||||
|
if (!map.isEmpty()) {
|
||||||
|
gameProfile.getProperties().putAll(newGameProfile.getProperties());
|
||||||
|
return ModelManager0.toUserProfile(map);
|
||||||
|
}
|
||||||
|
CustomSkinLoader.logger.info("Profile not found.(" + username + " doesn't have skin/cape.)");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Username -> UUID
|
||||||
|
public static GameProfile loadGameProfile(String apiRoot, String username) {
|
||||||
|
//Doc (https://wiki.vg/Mojang_API#Playernames_-.3E_UUIDs)
|
||||||
|
Gson gson = new GsonBuilder().registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).create();
|
||||||
|
|
||||||
|
HttpResponce responce = HttpRequestUtil.makeHttpRequest(
|
||||||
|
new HttpRequest(apiRoot + "profiles/minecraft")
|
||||||
|
.setCacheTime(-1).setPayload(gson.toJson(Collections.singletonList(username)))
|
||||||
|
);
|
||||||
|
if (StringUtils.isEmpty(responce.content))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
|
||||||
|
GameProfile[] profiles = gson.fromJson(responce.content, GameProfile[].class);
|
||||||
|
if (profiles.length == 0) return null;
|
||||||
|
GameProfile gameProfile = profiles[0];
|
||||||
|
|
||||||
|
if (gameProfile.getId() == null)
|
||||||
|
return null;
|
||||||
|
return new GameProfile(gameProfile.getId(), gameProfile.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
//UUID -> Profile
|
||||||
|
public static GameProfile fillGameProfile(String sessionRoot, GameProfile profile) {
|
||||||
|
//Doc (http://wiki.vg/Mojang_API#UUID_-.3E_Profile_.2B_Skin.2FCape)
|
||||||
|
HttpResponce responce = HttpRequestUtil.makeHttpRequest(
|
||||||
|
new HttpRequest(sessionRoot + "session/minecraft/profile/"
|
||||||
|
+ UUIDTypeAdapter.fromUUID(profile.getId())).setCacheTime(90));
|
||||||
|
if (StringUtils.isEmpty(responce.content))
|
||||||
|
return profile;
|
||||||
|
|
||||||
|
Gson gson = new GsonBuilder()
|
||||||
|
.registerTypeAdapter(UUID.class, new UUIDTypeAdapter())
|
||||||
|
.registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer())
|
||||||
|
.create();
|
||||||
|
MinecraftProfilePropertiesResponse propertiesResponce = gson.fromJson(responce.content, MinecraftProfilePropertiesResponse.class);
|
||||||
|
GameProfile newGameProfile = new GameProfile(propertiesResponce.getId(), propertiesResponce.getName());
|
||||||
|
newGameProfile.getProperties().putAll(propertiesResponce.getProperties());
|
||||||
|
|
||||||
|
return newGameProfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> getTextures(GameProfile gameProfile) {
|
||||||
|
if (gameProfile == null)
|
||||||
|
return Maps.newHashMap();
|
||||||
|
Property textureProperty = Iterables.getFirst(gameProfile.getProperties().get("textures"), null);
|
||||||
|
if (textureProperty == null)
|
||||||
|
return Maps.newHashMap();
|
||||||
|
String value = textureProperty.getValue();
|
||||||
|
if (StringUtils.isBlank(value))
|
||||||
|
return Maps.newHashMap();
|
||||||
|
@SuppressWarnings("deprecation") String json = new String(Base64.decodeBase64(value), Charsets.UTF_8);
|
||||||
|
Gson gson = new GsonBuilder().registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).create();
|
||||||
|
MinecraftTexturesPayload result = gson.fromJson(json, MinecraftTexturesPayload.class);
|
||||||
|
if (result == null || result.getTextures() == null)
|
||||||
|
return Maps.newHashMap();
|
||||||
|
return result.getTextures();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean compare(SkinSiteProfile ssp0, SkinSiteProfile ssp1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "MojangAPI";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(SkinSiteProfile ssp) {
|
||||||
|
//Init default api & session root for Mojang API
|
||||||
|
if (ssp.apiRoot == null)
|
||||||
|
ssp.apiRoot = "https://api.mojang.com/";
|
||||||
|
if (ssp.sessionRoot == null)
|
||||||
|
ssp.sessionRoot = "https://sessionserver.mojang.com/";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String MOJANG_API_ROOT = "https://api{DO_NOT_MODIFY}.mojang.com/";
|
||||||
|
|
||||||
|
public static String getMojangApiRoot() {
|
||||||
|
return MOJANG_API_ROOT.replace("{DO_NOT_MODIFY}", "");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package customskinloader.loader;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
|
||||||
|
import customskinloader.config.SkinSiteProfile;
|
||||||
|
import customskinloader.plugin.PluginLoader;
|
||||||
|
import customskinloader.profile.UserProfile;
|
||||||
|
|
||||||
|
public class ProfileLoader {
|
||||||
|
private static final IProfileLoader[] DEFAULT_LOADERS={
|
||||||
|
new MojangAPILoader(),
|
||||||
|
new JsonAPILoader(JsonAPILoader.Type.CustomSkinAPI),
|
||||||
|
new JsonAPILoader(JsonAPILoader.Type.CustomSkinAPIPlus),
|
||||||
|
new JsonAPILoader(JsonAPILoader.Type.UniSkinAPI),
|
||||||
|
new JsonAPILoader(JsonAPILoader.Type.ElyByAPI),
|
||||||
|
new JsonAPILoader(JsonAPILoader.Type.GlitchlessAPI),
|
||||||
|
new LegacyLoader()};
|
||||||
|
|
||||||
|
public static final HashMap<String,IProfileLoader> LOADERS=initLoaders();
|
||||||
|
|
||||||
|
private static HashMap<String, IProfileLoader> initLoaders() {
|
||||||
|
HashMap<String, IProfileLoader> loaders=new HashMap<String, IProfileLoader>();
|
||||||
|
for(IProfileLoader loader:DEFAULT_LOADERS){
|
||||||
|
loaders.put(loader.getName().toLowerCase(), loader);
|
||||||
|
}
|
||||||
|
loaders.putAll(PluginLoader.loadPlugins());
|
||||||
|
return loaders;
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IProfileLoader {
|
||||||
|
UserProfile loadProfile(SkinSiteProfile ssp,GameProfile gameProfile) throws Exception;
|
||||||
|
boolean compare(SkinSiteProfile ssp0,SkinSiteProfile ssp1);
|
||||||
|
String getName();
|
||||||
|
void init(SkinSiteProfile ssp);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
package customskinloader.loader.jsonapi;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import customskinloader.CustomSkinLoader;
|
||||||
|
import customskinloader.config.SkinSiteProfile;
|
||||||
|
import customskinloader.loader.JsonAPILoader.IJsonAPI;
|
||||||
|
import customskinloader.profile.ModelManager0;
|
||||||
|
import customskinloader.profile.ModelManager0.Model;
|
||||||
|
import customskinloader.profile.UserProfile;
|
||||||
|
import customskinloader.utils.HttpTextureUtil;
|
||||||
|
|
||||||
|
public class CustomSkinAPI implements IJsonAPI {
|
||||||
|
private static final String TEXTURES="textures/";
|
||||||
|
private static final String SUFFIX=".json";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toJsonUrl(String root, String username) {
|
||||||
|
return root + username + SUFFIX;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserProfile toUserProfile(String root, String json, boolean local) {
|
||||||
|
CustomSkinAPIProfile profile=CustomSkinLoader.GSON.fromJson(json, CustomSkinAPIProfile.class);
|
||||||
|
UserProfile p=new UserProfile();
|
||||||
|
|
||||||
|
if(StringUtils.isNotBlank(profile.skin)){
|
||||||
|
p.skinUrl=root+TEXTURES+profile.skin;
|
||||||
|
if(local)
|
||||||
|
p.skinUrl=HttpTextureUtil.getLocalFakeUrl(p.skinUrl);
|
||||||
|
}
|
||||||
|
if(StringUtils.isNotBlank(profile.cape)){
|
||||||
|
p.capeUrl=root+TEXTURES+profile.cape;
|
||||||
|
if(local)
|
||||||
|
p.capeUrl=HttpTextureUtil.getLocalFakeUrl(p.capeUrl);
|
||||||
|
}
|
||||||
|
if(StringUtils.isNotBlank(profile.elytra)){
|
||||||
|
p.elytraUrl=root+TEXTURES+profile.elytra;
|
||||||
|
if(local)
|
||||||
|
p.elytraUrl=HttpTextureUtil.getLocalFakeUrl(p.elytraUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String,String> textures=new LinkedHashMap<String,String>();
|
||||||
|
if(profile.skins!=null)
|
||||||
|
textures.putAll(profile.skins);
|
||||||
|
if(profile.textures!=null)
|
||||||
|
textures.putAll(profile.textures);
|
||||||
|
if(textures.isEmpty())
|
||||||
|
return p;
|
||||||
|
|
||||||
|
boolean hasSkin=false;
|
||||||
|
for(String model:textures.keySet()){
|
||||||
|
Model enumModel=ModelManager0.getEnumModel(model);
|
||||||
|
if(enumModel==null||StringUtils.isEmpty(textures.get(model)))
|
||||||
|
continue;
|
||||||
|
if(ModelManager0.isSkin(enumModel))
|
||||||
|
if(hasSkin)
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
hasSkin=true;
|
||||||
|
String url=root+TEXTURES+textures.get(model);
|
||||||
|
if(local)
|
||||||
|
url=HttpTextureUtil.getLocalFakeUrl(url);
|
||||||
|
p.put(enumModel, url);
|
||||||
|
}
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
private class CustomSkinAPIProfile{
|
||||||
|
public String username;
|
||||||
|
public LinkedHashMap<String,String> textures;
|
||||||
|
|
||||||
|
public LinkedHashMap<String,String> skins;
|
||||||
|
|
||||||
|
public String skin;
|
||||||
|
public String cape;
|
||||||
|
public String elytra;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getPayload(SkinSiteProfile ssp) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "CustomSkinAPI";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
package customskinloader.loader.jsonapi;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
|
import customskinloader.CustomSkinLoader;
|
||||||
|
import customskinloader.config.SkinSiteProfile;
|
||||||
|
import customskinloader.loader.JsonAPILoader;
|
||||||
|
import customskinloader.loader.JsonAPILoader.IJsonAPI;
|
||||||
|
import customskinloader.profile.UserProfile;
|
||||||
|
import customskinloader.utils.MinecraftUtil;
|
||||||
|
|
||||||
|
public class CustomSkinAPIPlus implements IJsonAPI {
|
||||||
|
|
||||||
|
private static String clientID=null;
|
||||||
|
public CustomSkinAPIPlus(){
|
||||||
|
File clientIDFile=new File(CustomSkinLoader.DATA_DIR,"CustomSkinAPIPlus-ClientID");
|
||||||
|
|
||||||
|
if(clientIDFile.isFile())
|
||||||
|
try{
|
||||||
|
clientID=FileUtils.readFileToString(clientIDFile, "UTF-8");
|
||||||
|
}catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
if(clientID==null){
|
||||||
|
clientID=UUID.randomUUID().toString();
|
||||||
|
try {
|
||||||
|
FileUtils.write(clientIDFile, clientID, "UTF-8");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String toJsonUrl(String root, String username) {
|
||||||
|
return JsonAPILoader.Type.CustomSkinAPI.jsonAPI.toJsonUrl(root, username);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPayload(SkinSiteProfile ssp) {
|
||||||
|
return new Gson().toJson(new CustomSkinAPIPlusPayload());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserProfile toUserProfile(String root, String json, boolean local) {
|
||||||
|
return JsonAPILoader.Type.CustomSkinAPI.jsonAPI.toUserProfile(root, json, local);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "CustomSKinAPIPlus";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class CustomSkinAPIPlusPayload{
|
||||||
|
String gameVersion;//minecraft version
|
||||||
|
String modVersion;//mod version
|
||||||
|
String serverAddress;//ip:port
|
||||||
|
String clientID;//Minecraft Client ID
|
||||||
|
CustomSkinAPIPlusPayload(){
|
||||||
|
gameVersion = MinecraftUtil.getMinecraftMainVersion();
|
||||||
|
modVersion = CustomSkinLoader.CustomSkinLoader_VERSION;
|
||||||
|
serverAddress = MinecraftUtil.isLanServer() ? null : MinecraftUtil.getStandardServerAddress();
|
||||||
|
clientID = CustomSkinAPIPlus.clientID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package customskinloader.loader.jsonapi;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||||
|
import customskinloader.config.SkinSiteProfile;
|
||||||
|
import customskinloader.loader.JsonAPILoader;
|
||||||
|
import customskinloader.profile.ModelManager0;
|
||||||
|
import customskinloader.profile.UserProfile;
|
||||||
|
import customskinloader.utils.MinecraftUtil;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ElyByAPI implements JsonAPILoader.IJsonAPI {
|
||||||
|
@Override
|
||||||
|
public String toJsonUrl(String root, String username) {
|
||||||
|
return "http://skinsystem.ely.by/textures/" + username + "?version=2&minecraft_version=" + MinecraftUtil.getMinecraftMainVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserProfile toUserProfile(String root, String json, boolean local) {
|
||||||
|
Map<Type, MinecraftProfileTexture> result = new Gson().fromJson(json, new TypeToken<Map<Type, MinecraftProfileTexture>>() {
|
||||||
|
}.getType());
|
||||||
|
if (!result.containsKey(Type.SKIN))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
//Check URL
|
||||||
|
try {
|
||||||
|
URI uri = new URI(result.get(Type.SKIN).getUrl());
|
||||||
|
if (!uri.getHost().endsWith("ely.by"))
|
||||||
|
return null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ModelManager0.toUserProfile(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPayload(SkinSiteProfile ssp) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "ElyByAPI";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package customskinloader.loader.jsonapi;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||||
|
import customskinloader.config.SkinSiteProfile;
|
||||||
|
import customskinloader.loader.JsonAPILoader;
|
||||||
|
import customskinloader.profile.ModelManager0;
|
||||||
|
import customskinloader.profile.UserProfile;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class GlitchlessAPI implements JsonAPILoader.IJsonAPI {
|
||||||
|
@Override
|
||||||
|
public String toJsonUrl(String root, String username) {
|
||||||
|
return root + username;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserProfile toUserProfile(String root, String json, boolean local) {
|
||||||
|
GlitchlessApiResponse result = new Gson().fromJson(json, GlitchlessApiResponse.class);
|
||||||
|
if (!result.textures.containsKey(MinecraftProfileTexture.Type.SKIN))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return ModelManager0.toUserProfile(result.textures);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPayload(SkinSiteProfile ssp) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "GlitchlessAPI";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class GlitchlessApiResponse {
|
||||||
|
protected Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> textures;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package customskinloader.loader.jsonapi;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import customskinloader.CustomSkinLoader;
|
||||||
|
import customskinloader.config.SkinSiteProfile;
|
||||||
|
import customskinloader.loader.JsonAPILoader.IJsonAPI;
|
||||||
|
import customskinloader.profile.ModelManager0;
|
||||||
|
import customskinloader.profile.UserProfile;
|
||||||
|
import customskinloader.profile.ModelManager0.Model;
|
||||||
|
import customskinloader.utils.HttpTextureUtil;
|
||||||
|
|
||||||
|
public class UniSkinAPI implements IJsonAPI {
|
||||||
|
private static final String TEXTURES="textures/";
|
||||||
|
private static final String SUFFIX=".json";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toJsonUrl(String root, String username) {
|
||||||
|
return root + username + SUFFIX;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserProfile toUserProfile(String root, String json, boolean local) {
|
||||||
|
UniSkinAPIProfile profile=CustomSkinLoader.GSON.fromJson(json, UniSkinAPIProfile.class);
|
||||||
|
UserProfile p=new UserProfile();
|
||||||
|
|
||||||
|
if(StringUtils.isNotBlank(profile.cape)){
|
||||||
|
p.capeUrl=root+TEXTURES+profile.cape;
|
||||||
|
if(local)
|
||||||
|
p.capeUrl=HttpTextureUtil.getLocalFakeUrl(p.capeUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(profile.skins==null||profile.skins.isEmpty())
|
||||||
|
return p;
|
||||||
|
if(profile.model_preference==null||profile.model_preference.isEmpty())
|
||||||
|
return p;
|
||||||
|
|
||||||
|
boolean hasSkin=false;
|
||||||
|
for(String model:profile.model_preference){
|
||||||
|
Model enumModel=ModelManager0.getEnumModel(model);
|
||||||
|
if(enumModel==null||StringUtils.isEmpty(profile.skins.get(model)))
|
||||||
|
continue;
|
||||||
|
if(ModelManager0.isSkin(enumModel))
|
||||||
|
if(hasSkin)
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
hasSkin=true;
|
||||||
|
String url=root+TEXTURES+profile.skins.get(model);
|
||||||
|
if(local)
|
||||||
|
url=HttpTextureUtil.getLocalFakeUrl(url);
|
||||||
|
p.put(enumModel, url);
|
||||||
|
}
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Json profile for UniSkinAPI
|
||||||
|
* Source Code: https://github.com/RecursiveG/UniSkinMod/blob/master/src/main/java/org/devinprogress/uniskinmod/UniSkinApiProfile.java#L18-L22
|
||||||
|
* @author RecursiveG
|
||||||
|
*/
|
||||||
|
private class UniSkinAPIProfile{
|
||||||
|
public String player_name;
|
||||||
|
public long last_update;
|
||||||
|
public List<String> model_preference;
|
||||||
|
public Map<String,String> skins;
|
||||||
|
|
||||||
|
public String cape;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getPayload(SkinSiteProfile ssp) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "UniSkinAPI";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package customskinloader.plugin;
|
||||||
|
|
||||||
|
import customskinloader.loader.ProfileLoader;
|
||||||
|
|
||||||
|
public interface ICustomSkinLoaderPlugin {
|
||||||
|
ProfileLoader.IProfileLoader getProfileLoader();
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package customskinloader.plugin;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.ServiceLoader;
|
||||||
|
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
|
import customskinloader.CustomSkinLoader;
|
||||||
|
import customskinloader.loader.ProfileLoader;
|
||||||
|
|
||||||
|
public class PluginLoader {
|
||||||
|
public static HashMap<String, ProfileLoader.IProfileLoader> loadPlugins() {
|
||||||
|
File pluginsDir = new File(CustomSkinLoader.DATA_DIR, "Plugins");
|
||||||
|
ArrayList<URL> urls = new ArrayList<URL>();
|
||||||
|
if (!pluginsDir.isDirectory()) {
|
||||||
|
pluginsDir.mkdirs();
|
||||||
|
} else {
|
||||||
|
for (File plugin : FileUtils.listFiles(pluginsDir, new String[] {"jar", "zip"}, false)) {
|
||||||
|
try {
|
||||||
|
urls.add(plugin.toURI().toURL());
|
||||||
|
CustomSkinLoader.logger.info("Found a jar or zip file: " + plugin.getName());
|
||||||
|
} catch (MalformedURLException ignored) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ServiceLoader<ICustomSkinLoaderPlugin> sl = ServiceLoader.load(ICustomSkinLoaderPlugin.class, new URLClassLoader(urls.toArray(new URL[0]), PluginLoader.class.getClassLoader()));
|
||||||
|
HashMap<String, ProfileLoader.IProfileLoader> profileLoaders = new HashMap<String, ProfileLoader.IProfileLoader>();
|
||||||
|
for (ICustomSkinLoaderPlugin cslPlugin : sl) {
|
||||||
|
ProfileLoader.IProfileLoader profileLoader = cslPlugin.getProfileLoader();
|
||||||
|
profileLoaders.put(profileLoader.getName().toLowerCase(), profileLoader);
|
||||||
|
CustomSkinLoader.logger.info("Add profile loader: " + profileLoader.getName());
|
||||||
|
}
|
||||||
|
return profileLoaders;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,160 @@
|
|||||||
|
package customskinloader.profile;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import org.apache.commons.codec.Charsets;
|
||||||
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||||
|
import com.mojang.authlib.properties.Property;
|
||||||
|
import com.mojang.util.UUIDTypeAdapter;
|
||||||
|
|
||||||
|
import customskinloader.CustomSkinLoader;
|
||||||
|
import customskinloader.utils.HttpRequestUtil;
|
||||||
|
import customskinloader.utils.HttpRequestUtil.HttpRequest;
|
||||||
|
import customskinloader.utils.HttpRequestUtil.HttpResponce;
|
||||||
|
import customskinloader.utils.HttpTextureUtil;
|
||||||
|
import customskinloader.utils.HttpUtil0;
|
||||||
|
|
||||||
|
public class DynamicSkullManager {
|
||||||
|
public static class SkullTexture{
|
||||||
|
public Map<Type,MinecraftProfileTexture> textures;
|
||||||
|
public String index;//Index File
|
||||||
|
public ArrayList<String> skins;
|
||||||
|
public int interval;
|
||||||
|
public boolean fromZero;
|
||||||
|
//For program
|
||||||
|
public long startTime;
|
||||||
|
public int period;
|
||||||
|
}
|
||||||
|
private Map<GameProfile, SkullTexture> dynamicTextures = new ConcurrentHashMap<>();
|
||||||
|
private Map<GameProfile, Map<Type, MinecraftProfileTexture>> staticTextures = new ConcurrentHashMap<>();
|
||||||
|
private List<GameProfile> loadingList=new ArrayList<GameProfile>();
|
||||||
|
|
||||||
|
private void parseGameProfile(GameProfile profile){
|
||||||
|
Property textureProperty = Iterables.getFirst(profile.getProperties().get("textures"), null);
|
||||||
|
if (textureProperty==null){
|
||||||
|
staticTextures.put(profile, Maps.<Type, MinecraftProfileTexture>newHashMap());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String value=textureProperty.getValue();
|
||||||
|
if(StringUtils.isBlank(value)){
|
||||||
|
staticTextures.put(profile, Maps.<Type, MinecraftProfileTexture>newHashMap());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
@SuppressWarnings("deprecation") String json = new String(Base64.decodeBase64(value), Charsets.UTF_8);
|
||||||
|
Gson gson=new GsonBuilder().registerTypeAdapter(UUID.class,new UUIDTypeAdapter()).create();
|
||||||
|
SkullTexture result=gson.fromJson(json,SkullTexture.class);
|
||||||
|
if(result==null){
|
||||||
|
staticTextures.put(profile, Maps.<Type, MinecraftProfileTexture>newHashMap());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
staticTextures.put(profile, (result.textures==null || !result.textures.containsKey(Type.SKIN)) ?
|
||||||
|
Maps.<Type, MinecraftProfileTexture>newHashMap() : parseTextures(result.textures));
|
||||||
|
|
||||||
|
if(StringUtils.isNotEmpty(result.index)){
|
||||||
|
File indexFile=new File(CustomSkinLoader.DATA_DIR,result.index);
|
||||||
|
try{
|
||||||
|
String index=FileUtils.readFileToString(indexFile, "UTF-8");
|
||||||
|
if(StringUtils.isNotEmpty(index)){
|
||||||
|
String[] skins = CustomSkinLoader.GSON.fromJson(index, String[].class);
|
||||||
|
if(skins != null && skins.length != 0)
|
||||||
|
result.skins = Lists.newArrayList(skins);
|
||||||
|
}
|
||||||
|
}catch(Exception e){
|
||||||
|
CustomSkinLoader.logger.warning("Exception occurs while parsing index file: "+e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!CustomSkinLoader.config.enableDynamicSkull||result.skins==null||result.skins.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
CustomSkinLoader.logger.info("Try to load Dynamic Skull: "+json);
|
||||||
|
|
||||||
|
for(int i=0;i<result.skins.size();i++){//check and cache skins
|
||||||
|
String skin=result.skins.get(i);
|
||||||
|
if(HttpUtil0.isLocal(skin)){
|
||||||
|
//Local Skin
|
||||||
|
File skinFile=new File(CustomSkinLoader.DATA_DIR,skin);
|
||||||
|
if(skinFile.isFile()&&skinFile.length()>0){
|
||||||
|
//Skin found
|
||||||
|
String fakeUrl=HttpTextureUtil.getLocalFakeUrl(skin);
|
||||||
|
result.skins.set(i, fakeUrl);
|
||||||
|
}else{
|
||||||
|
//Could not find skin
|
||||||
|
result.skins.remove(i--);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
//Online Skin
|
||||||
|
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest(skin).setCacheFile(HttpTextureUtil.getCacheFile(FilenameUtils.getBaseName(skin))).setCacheTime(0).setLoadContent(false));
|
||||||
|
if(!responce.success){
|
||||||
|
//Could not load skin
|
||||||
|
result.skins.remove(i--);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(result.skins.isEmpty()){//Nothing loaded
|
||||||
|
CustomSkinLoader.logger.info("Failed: Nothing loaded.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
result.interval=Math.max(result.interval, 50);
|
||||||
|
if(result.fromZero)
|
||||||
|
result.startTime=System.currentTimeMillis();
|
||||||
|
result.period=result.interval*result.skins.size();
|
||||||
|
CustomSkinLoader.logger.info("Successfully loaded Dynamic Skull: "+new Gson().toJson(result));
|
||||||
|
dynamicTextures.put(profile, result);
|
||||||
|
staticTextures.remove(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Support local skin for skull
|
||||||
|
public Map<Type, MinecraftProfileTexture> parseTextures(Map<Type, MinecraftProfileTexture> textures) {
|
||||||
|
MinecraftProfileTexture skin=textures.get(Type.SKIN);
|
||||||
|
String skinUrl=skin.getUrl();
|
||||||
|
if(!HttpUtil0.isLocal(skinUrl))
|
||||||
|
return textures;
|
||||||
|
File skinFile=new File(CustomSkinLoader.DATA_DIR,skinUrl);
|
||||||
|
if(!skinFile.isFile())
|
||||||
|
return Maps.newHashMap();
|
||||||
|
textures.put(Type.SKIN, ModelManager0.getProfileTexture(HttpTextureUtil.getLocalFakeUrl(skinUrl), null));
|
||||||
|
return textures;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Type,MinecraftProfileTexture> getTexture(final GameProfile profile){
|
||||||
|
if(staticTextures.get(profile)!=null)
|
||||||
|
return staticTextures.get(profile);
|
||||||
|
if(loadingList.contains(profile))
|
||||||
|
return Maps.newHashMap();
|
||||||
|
if(dynamicTextures.containsKey(profile)){
|
||||||
|
SkullTexture texture=dynamicTextures.get(profile);
|
||||||
|
long time=System.currentTimeMillis()-texture.startTime;
|
||||||
|
int index=(int)Math.floor((time%texture.period)/texture.interval);
|
||||||
|
Map<Type,MinecraftProfileTexture> map=Maps.newHashMap();
|
||||||
|
map.put(Type.SKIN, ModelManager0.getProfileTexture(texture.skins.get(index), null));
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
loadingList.add(profile);
|
||||||
|
Thread loadThread=new Thread(){
|
||||||
|
public void run(){
|
||||||
|
parseGameProfile(profile);//Load in thread
|
||||||
|
loadingList.remove(profile);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
loadThread.setName("Skull "+profile.hashCode());
|
||||||
|
loadThread.start();
|
||||||
|
return Maps.newHashMap();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
package customskinloader.profile;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model Manager for 1.8 and higher.
|
||||||
|
* A manager to check if model is available.
|
||||||
|
* It is the only class in package 'customskinloader' which has differences in different Minecraft version.
|
||||||
|
*
|
||||||
|
* @since 13.1
|
||||||
|
*/
|
||||||
|
public class ModelManager0 {
|
||||||
|
public enum Model {
|
||||||
|
SKIN_DEFAULT,
|
||||||
|
SKIN_SLIM,
|
||||||
|
CAPE,
|
||||||
|
ELYTRA
|
||||||
|
}
|
||||||
|
|
||||||
|
private static HashMap<String, Model> models = new HashMap<String, Model>();
|
||||||
|
private static Type typeElytra = null;
|
||||||
|
|
||||||
|
static {
|
||||||
|
for (Type type : Type.values()) {
|
||||||
|
if (type.ordinal() == 2)//ELYTRA
|
||||||
|
typeElytra = type;
|
||||||
|
}
|
||||||
|
models.put("default", Model.SKIN_DEFAULT);
|
||||||
|
models.put("slim", Model.SKIN_SLIM);
|
||||||
|
models.put("cape", Model.CAPE);
|
||||||
|
if (typeElytra != null) {
|
||||||
|
models.put("elytra", Model.ELYTRA);
|
||||||
|
models.put("elytron", Model.ELYTRA);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get enum for the model.
|
||||||
|
*
|
||||||
|
* @param model - string model
|
||||||
|
* @since 14.5
|
||||||
|
*/
|
||||||
|
public static Model getEnumModel(String model) {
|
||||||
|
return models.get(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if model is skin.
|
||||||
|
*
|
||||||
|
* @since 14.5
|
||||||
|
*/
|
||||||
|
public static boolean isSkin(Model model) {
|
||||||
|
return model == Model.SKIN_DEFAULT || model == Model.SKIN_SLIM;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if elytra is supported.
|
||||||
|
*
|
||||||
|
* @since 14.5
|
||||||
|
*/
|
||||||
|
public static boolean isElytraSupported() {
|
||||||
|
return typeElytra != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse hashMapProfile to UserProfile
|
||||||
|
*
|
||||||
|
* @param profile - hashMapProfile (HashMap<String,MinecraftProfileTexture>)
|
||||||
|
* @return profile - UserProfile instance
|
||||||
|
* @since 13.1
|
||||||
|
*/
|
||||||
|
public static UserProfile toUserProfile(Map<Type, MinecraftProfileTexture> profile) {
|
||||||
|
UserProfile userProfile = new UserProfile();
|
||||||
|
if (profile == null)
|
||||||
|
return userProfile;
|
||||||
|
MinecraftProfileTexture skin = profile.get(Type.SKIN);
|
||||||
|
userProfile.skinUrl = skin == null ? null : skin.getUrl();//Avoid NullPointerException
|
||||||
|
userProfile.model = skin == null ? null : skin.getMetadata("model");
|
||||||
|
if (StringUtils.isEmpty(userProfile.model))
|
||||||
|
userProfile.model = "default";
|
||||||
|
|
||||||
|
MinecraftProfileTexture cape = profile.get(Type.CAPE);
|
||||||
|
userProfile.capeUrl = cape == null ? null : cape.getUrl();
|
||||||
|
return userProfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse UserProfile to hashMapProfile
|
||||||
|
*
|
||||||
|
* @param profile - UserProfile instance
|
||||||
|
* @return profile - hashMapProfile (HashMap<String,MinecraftProfileTexture>)
|
||||||
|
* @since 13.1
|
||||||
|
*/
|
||||||
|
public static Map<Type, MinecraftProfileTexture> fromUserProfile(UserProfile profile) {
|
||||||
|
Map<Type, MinecraftProfileTexture> map = Maps.newHashMap();
|
||||||
|
if (profile == null)
|
||||||
|
return map;
|
||||||
|
if (profile.skinUrl != null) {
|
||||||
|
Map<String, String> metadata = null;
|
||||||
|
if ("slim".equals(profile.model) || "auto".equals(profile.model)) {
|
||||||
|
metadata = Maps.newHashMap();
|
||||||
|
metadata.put("model", profile.model);
|
||||||
|
}
|
||||||
|
map.put(Type.SKIN, getProfileTexture(profile.skinUrl, metadata));
|
||||||
|
}
|
||||||
|
if (profile.capeUrl != null)
|
||||||
|
map.put(Type.CAPE, getProfileTexture(profile.capeUrl, null));
|
||||||
|
if (typeElytra != null && profile.elytraUrl != null)
|
||||||
|
map.put(typeElytra, getProfileTexture(profile.elytraUrl, null));
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse url to MinecraftProfileTexture
|
||||||
|
*
|
||||||
|
* @param url - textureUrl
|
||||||
|
* @param metadata - metadata
|
||||||
|
* @return MinecraftProfileTexture
|
||||||
|
* @since 14.5
|
||||||
|
*/
|
||||||
|
public static MinecraftProfileTexture getProfileTexture(String url, Map<String, String> metadata) {
|
||||||
|
return new MinecraftProfileTexture(url, metadata);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
package customskinloader.profile;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
|
import customskinloader.CustomSkinLoader;
|
||||||
|
import customskinloader.utils.TimeUtil;
|
||||||
|
|
||||||
|
public class ProfileCache {
|
||||||
|
public static File PROFILE_CACHE_DIR=new File(CustomSkinLoader.DATA_DIR,"ProfileCache");
|
||||||
|
|
||||||
|
private Map<String, CachedProfile> cachedProfiles = new ConcurrentHashMap<>();
|
||||||
|
private Map<String, UserProfile> localProfiles = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||||
|
public ProfileCache(){
|
||||||
|
if(!PROFILE_CACHE_DIR.exists())
|
||||||
|
PROFILE_CACHE_DIR.mkdir();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isExist(String username){
|
||||||
|
return cachedProfiles.containsKey(username.toLowerCase());
|
||||||
|
}
|
||||||
|
public boolean isLoading(String username) {
|
||||||
|
CachedProfile cp=cachedProfiles.get(username.toLowerCase());
|
||||||
|
return cp != null && cp.loading;
|
||||||
|
}
|
||||||
|
public boolean isReady(String username){
|
||||||
|
CachedProfile cp=cachedProfiles.get(username.toLowerCase());
|
||||||
|
return cp != null && (cp.loading || cp.expiryTime > TimeUtil.getCurrentUnixTimestamp());
|
||||||
|
}
|
||||||
|
public boolean isExpired(String username){
|
||||||
|
CachedProfile cp=cachedProfiles.get(username.toLowerCase());
|
||||||
|
return cp == null || (cp.expiryTime <= TimeUtil.getCurrentUnixTimestamp());
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserProfile getProfile(String username){
|
||||||
|
return getCachedProfile(username).profile;
|
||||||
|
}
|
||||||
|
public long getExpiry(String username){
|
||||||
|
return getCachedProfile(username).expiryTime;
|
||||||
|
}
|
||||||
|
public UserProfile getLocalProfile(String username){
|
||||||
|
if(localProfiles.containsKey(username.toLowerCase()))
|
||||||
|
return localProfiles.get(username.toLowerCase());
|
||||||
|
return loadLocalProfile(username);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLoading(String username,boolean loading){
|
||||||
|
getCachedProfile(username).loading=loading;
|
||||||
|
}
|
||||||
|
public void updateCache(String username,UserProfile profile){
|
||||||
|
updateCache(username,profile,CustomSkinLoader.config.enableLocalProfileCache);
|
||||||
|
}
|
||||||
|
public void updateCache(String username,UserProfile profile,boolean saveLocalProfile){
|
||||||
|
CachedProfile cp=getCachedProfile(username);
|
||||||
|
cp.profile=profile;
|
||||||
|
cp.expiryTime=TimeUtil.getUnixTimestampRandomDelay(CustomSkinLoader.config.cacheExpiry);
|
||||||
|
if(!saveLocalProfile)
|
||||||
|
return;
|
||||||
|
saveLocalProfile(username,profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
private CachedProfile getCachedProfile(String username){
|
||||||
|
CachedProfile cp=cachedProfiles.get(username.toLowerCase());
|
||||||
|
if(cp!=null)
|
||||||
|
return cp;
|
||||||
|
cp=new CachedProfile();
|
||||||
|
cachedProfiles.put(username.toLowerCase(), cp);
|
||||||
|
return cp;
|
||||||
|
}
|
||||||
|
private UserProfile loadLocalProfile(String username){
|
||||||
|
File localProfile=new File(PROFILE_CACHE_DIR,username.toLowerCase()+".json");
|
||||||
|
if(!localProfile.exists()){
|
||||||
|
localProfiles.put(username.toLowerCase(), null);
|
||||||
|
}
|
||||||
|
try{
|
||||||
|
String json = FileUtils.readFileToString(localProfile, "UTF-8");
|
||||||
|
UserProfile profile=CustomSkinLoader.GSON.fromJson(json, UserProfile.class);
|
||||||
|
localProfiles.put(username.toLowerCase(), profile);
|
||||||
|
CustomSkinLoader.logger.info("Successfully load LocalProfile.");
|
||||||
|
return profile;
|
||||||
|
}catch(Exception e){
|
||||||
|
CustomSkinLoader.logger.info("Failed to load LocalProfile.("+e.toString()+")");
|
||||||
|
localProfiles.put(username.toLowerCase(), null);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||||
|
private void saveLocalProfile(String username, UserProfile profile){
|
||||||
|
String json=CustomSkinLoader.GSON.toJson(profile);
|
||||||
|
File localProfile=new File(PROFILE_CACHE_DIR,username+".json");
|
||||||
|
if(localProfile.exists())
|
||||||
|
localProfile.delete();
|
||||||
|
try {
|
||||||
|
FileUtils.write(localProfile, json, "UTF-8");
|
||||||
|
CustomSkinLoader.logger.info("Successfully save LocalProfile.");
|
||||||
|
} catch (Exception e) {
|
||||||
|
CustomSkinLoader.logger.info("Failed to save LocalProfile.("+e.toString()+")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class CachedProfile{
|
||||||
|
public UserProfile profile;
|
||||||
|
public long expiryTime=0;
|
||||||
|
public boolean loading=false;
|
||||||
|
}
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
package customskinloader.profile;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import customskinloader.profile.ModelManager0.Model;
|
||||||
|
|
||||||
|
/**The instance to storage user's profile in memory temporarily.
|
||||||
|
* In this manner, it could be easier to pass profile in program.
|
||||||
|
* @since 13.1
|
||||||
|
*/
|
||||||
|
public class UserProfile {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Direct url for skin.
|
||||||
|
* @since 13.1
|
||||||
|
*/
|
||||||
|
public String skinUrl=null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model for skin.
|
||||||
|
* default/slim
|
||||||
|
* @since 13.1
|
||||||
|
*/
|
||||||
|
public String model=null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Direct url for cape.
|
||||||
|
* @since 13.1
|
||||||
|
*/
|
||||||
|
public String capeUrl=null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Direct url for elytra.
|
||||||
|
* @since 14.5
|
||||||
|
*/
|
||||||
|
public String elytraUrl=null;
|
||||||
|
|
||||||
|
public void put(Model model,String url){
|
||||||
|
if(model==null||StringUtils.isEmpty(url))
|
||||||
|
return;
|
||||||
|
switch(model){
|
||||||
|
case SKIN_DEFAULT:
|
||||||
|
this.skinUrl=url;
|
||||||
|
this.model="default";
|
||||||
|
return;
|
||||||
|
case SKIN_SLIM:
|
||||||
|
this.skinUrl=url;
|
||||||
|
this.model="slim";
|
||||||
|
return;
|
||||||
|
case CAPE:
|
||||||
|
this.capeUrl=url;
|
||||||
|
return;
|
||||||
|
case ELYTRA:
|
||||||
|
this.capeUrl=url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get parsed String to output the instance.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString(){
|
||||||
|
return toString(0);
|
||||||
|
}
|
||||||
|
public String toString(long expiry){
|
||||||
|
return "(SkinUrl: "+skinUrl+
|
||||||
|
" , Model: "+model+
|
||||||
|
" , CapeUrl: "+capeUrl+
|
||||||
|
(StringUtils.isBlank(elytraUrl)?" ":" , ElytraUrl: "+elytraUrl)+
|
||||||
|
(expiry==0?"":(" , Expiry: "+expiry))+")";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the instance is empty.
|
||||||
|
* @return status (true - empty)
|
||||||
|
*/
|
||||||
|
public boolean isEmpty(){
|
||||||
|
return StringUtils.isEmpty(skinUrl) && StringUtils.isEmpty(capeUrl) && StringUtils.isEmpty(elytraUrl);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Check if the instance is full(Both skin and cape).
|
||||||
|
* @return status (true - full)
|
||||||
|
* @since 14.7
|
||||||
|
*/
|
||||||
|
public boolean isFull(){
|
||||||
|
return StringUtils.isNoneBlank(skinUrl,capeUrl);
|
||||||
|
}
|
||||||
|
public boolean hasSkinUrl(){
|
||||||
|
return StringUtils.isNotEmpty(skinUrl);
|
||||||
|
}
|
||||||
|
public void mix(UserProfile profile){
|
||||||
|
if(profile==null)
|
||||||
|
return;
|
||||||
|
if(StringUtils.isEmpty(this.skinUrl)) {
|
||||||
|
this.skinUrl = profile.skinUrl;
|
||||||
|
this.model = profile.model;
|
||||||
|
}
|
||||||
|
if(StringUtils.isEmpty(this.capeUrl))
|
||||||
|
this.capeUrl=profile.capeUrl;
|
||||||
|
if(StringUtils.isEmpty(this.elytraUrl))
|
||||||
|
this.elytraUrl=profile.elytraUrl;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,260 @@
|
|||||||
|
package customskinloader.utils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import customskinloader.CustomSkinLoader;
|
||||||
|
|
||||||
|
public class HttpRequestUtil {
|
||||||
|
public static class HttpRequest {
|
||||||
|
public String url;
|
||||||
|
public String userAgent = null;
|
||||||
|
public String payload = null;
|
||||||
|
public boolean loadContent = true;
|
||||||
|
public boolean checkPNG = false;
|
||||||
|
|
||||||
|
public int cacheTime = 600;//-1=No Cache 0=Always Cache t=Default Cache Time(second)
|
||||||
|
public File cacheFile = null;//Default Cache File
|
||||||
|
|
||||||
|
public HttpRequest(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HttpRequest setUserAgent(String userAgent) {
|
||||||
|
this.userAgent = userAgent;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HttpRequest setPayload(String payload) {
|
||||||
|
this.payload = payload;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HttpRequest setLoadContent(boolean loadContent) {
|
||||||
|
this.loadContent = loadContent;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HttpRequest setCheckPNG(boolean checkPNG) {
|
||||||
|
this.checkPNG = checkPNG;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HttpRequest setCacheTime(int cacheTime) {
|
||||||
|
this.cacheTime = cacheTime;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HttpRequest setCacheFile(File cacheFile) {
|
||||||
|
this.cacheFile = cacheFile;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class HttpResponce {
|
||||||
|
public String content = null;
|
||||||
|
public int responceCode = -1;
|
||||||
|
public boolean success = false;
|
||||||
|
public boolean fromCache = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class CacheInfo {
|
||||||
|
public String url;
|
||||||
|
public String etag = null;
|
||||||
|
|
||||||
|
public long lastModified = -1;//ms
|
||||||
|
public long expire = -1;//UNIX timestamp
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final File CACHE_DIR = new File(CustomSkinLoader.DATA_DIR, "caches");
|
||||||
|
|
||||||
|
public static HttpResponce makeHttpRequest(HttpRequest request) {
|
||||||
|
return makeHttpRequest(request, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HttpResponce makeHttpRequest(HttpRequest request, int redirectTime) {
|
||||||
|
try {
|
||||||
|
if(request.url.contains("{ABORT}")){
|
||||||
|
CustomSkinLoader.logger.info("ABORT tag found in url, request has been aborted.");
|
||||||
|
return new HttpResponce();
|
||||||
|
}
|
||||||
|
CustomSkinLoader.logger.debug("Try to request '" + request.url + (request.userAgent == null ? "'." : "' with user agent '" + request.userAgent + "'."));
|
||||||
|
//Check Cache
|
||||||
|
if (StringUtils.isNotEmpty(request.payload))
|
||||||
|
request.cacheTime = -1;//No Cache
|
||||||
|
File cacheInfoFile = null;
|
||||||
|
CacheInfo cacheInfo = new CacheInfo();
|
||||||
|
if (request.cacheFile == null && request.cacheTime >= 0) {
|
||||||
|
String hash = DigestUtils.sha1Hex(request.url);
|
||||||
|
request.cacheFile = new File(CACHE_DIR, hash);
|
||||||
|
cacheInfoFile = new File(CACHE_DIR, hash + ".json");
|
||||||
|
}
|
||||||
|
if (request.cacheTime == 0 && request.cacheFile.isFile())
|
||||||
|
return loadFromCache(request, new HttpResponce());
|
||||||
|
if (cacheInfoFile != null && cacheInfoFile.isFile()) {
|
||||||
|
String json = FileUtils.readFileToString(cacheInfoFile, "UTF-8");
|
||||||
|
if (StringUtils.isNotEmpty(json))
|
||||||
|
cacheInfo = CustomSkinLoader.GSON.fromJson(json, CacheInfo.class);
|
||||||
|
if (cacheInfo == null)
|
||||||
|
cacheInfo = new CacheInfo();
|
||||||
|
if (cacheInfo.expire >= TimeUtil.getCurrentUnixTimestamp())
|
||||||
|
return loadFromCache(request, new HttpResponce(), cacheInfo.expire);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Init Connection
|
||||||
|
URL rawUrl = new URL(request.url);
|
||||||
|
URI uri = new URI(
|
||||||
|
rawUrl.getProtocol(),
|
||||||
|
rawUrl.getUserInfo(),
|
||||||
|
rawUrl.getHost(),
|
||||||
|
rawUrl.getPort(),
|
||||||
|
rawUrl.getPath(),
|
||||||
|
rawUrl.getQuery(),
|
||||||
|
rawUrl.getRef()
|
||||||
|
);
|
||||||
|
String url = uri.toASCIIString();
|
||||||
|
if (!url.equalsIgnoreCase(request.url))
|
||||||
|
CustomSkinLoader.logger.debug("Encoded URL: " + url);
|
||||||
|
HttpURLConnection c = (HttpURLConnection) (new URL(url)).openConnection();
|
||||||
|
c.setReadTimeout(1000 * 10);
|
||||||
|
c.setConnectTimeout(1000 * 10);
|
||||||
|
c.setDoInput(true);
|
||||||
|
c.setUseCaches(false);
|
||||||
|
c.setInstanceFollowRedirects(true);
|
||||||
|
|
||||||
|
//Make Connection
|
||||||
|
if (cacheInfo.lastModified >= 0)
|
||||||
|
c.setIfModifiedSince(cacheInfo.lastModified);
|
||||||
|
if (cacheInfo.etag != null)
|
||||||
|
c.setRequestProperty("If-None-Match", cacheInfo.etag);
|
||||||
|
c.setRequestProperty("Accept-Encoding", "gzip");
|
||||||
|
if (request.userAgent != null)
|
||||||
|
c.setRequestProperty("User-Agent", request.userAgent);
|
||||||
|
if (StringUtils.isNotEmpty(request.payload)) {
|
||||||
|
CustomSkinLoader.logger.info("Payload: " + request.payload);
|
||||||
|
c.setRequestProperty("Content-Type", "application/json");
|
||||||
|
c.setDoOutput(true);
|
||||||
|
OutputStream os = c.getOutputStream();
|
||||||
|
IOUtils.write(request.payload, os, "UTF-8");
|
||||||
|
IOUtils.closeQuietly(os);
|
||||||
|
}
|
||||||
|
c.connect();
|
||||||
|
|
||||||
|
//Check Connection
|
||||||
|
HttpResponce responce = new HttpResponce();
|
||||||
|
responce.responceCode = c.getResponseCode();
|
||||||
|
int res = c.getResponseCode();
|
||||||
|
if (res / 100 == 4 || res / 100 == 5) {//Failed
|
||||||
|
CustomSkinLoader.logger.debug("Failed to request (Response Code: " + res + ")");
|
||||||
|
return responce;
|
||||||
|
}
|
||||||
|
if (res == HttpURLConnection.HTTP_MOVED_PERM || res == HttpURLConnection.HTTP_MOVED_TEMP) {
|
||||||
|
//Redirect
|
||||||
|
if (redirectTime >= 4) {
|
||||||
|
CustomSkinLoader.logger.debug("Failed to request (Too many redirection)");
|
||||||
|
return responce;
|
||||||
|
}
|
||||||
|
request.url = c.getHeaderField("Location");//Get redirecting location
|
||||||
|
if (request.url == null) {
|
||||||
|
CustomSkinLoader.logger.debug("Failed to request (Redirecting location not found)");
|
||||||
|
return responce;
|
||||||
|
}
|
||||||
|
CustomSkinLoader.logger.debug("Redirect to: " + request.url);
|
||||||
|
return makeHttpRequest(request, redirectTime + 1);//Recursion
|
||||||
|
}
|
||||||
|
responce.success = true;
|
||||||
|
CustomSkinLoader.logger.debug("Successfully request (Response Code: " + res + " , Content Length: " + c.getContentLength() + ")");
|
||||||
|
if (responce.responceCode == HttpURLConnection.HTTP_NOT_MODIFIED)
|
||||||
|
return loadFromCache(request, responce);
|
||||||
|
if (responce.responceCode == HttpURLConnection.HTTP_NO_CONTENT)
|
||||||
|
request.cacheTime = 3600;
|
||||||
|
|
||||||
|
//Load Content
|
||||||
|
InputStream is = "gzip".equals(c.getContentEncoding()) ? new GZIPInputStream(c.getInputStream()) : c.getInputStream();
|
||||||
|
byte[] bytes = IOUtils.toByteArray(is);
|
||||||
|
if (request.checkPNG && (bytes.length <= 4 || bytes[1] != (byte) 'P' || bytes[2] != (byte) 'N' || bytes[3] != (byte) 'G')) {
|
||||||
|
CustomSkinLoader.logger.debug("Failed to request (Not Standard PNG)");
|
||||||
|
responce.success = false;
|
||||||
|
return responce;
|
||||||
|
}
|
||||||
|
if (request.cacheFile != null) {
|
||||||
|
FileUtils.writeByteArrayToFile(request.cacheFile, bytes);
|
||||||
|
if (cacheInfoFile != null) {
|
||||||
|
cacheInfo.url = request.url;
|
||||||
|
cacheInfo.etag = c.getHeaderField("ETag");
|
||||||
|
cacheInfo.lastModified = c.getLastModified();
|
||||||
|
cacheInfo.expire = getExpire(c, request.cacheTime);
|
||||||
|
FileUtils.write(cacheInfoFile, CustomSkinLoader.GSON.toJson(cacheInfo), "UTF-8");
|
||||||
|
}
|
||||||
|
CustomSkinLoader.logger.debug("Saved to cache (Length: " + request.cacheFile.length() + " , Path: '" + request.cacheFile.getAbsolutePath() + "' , Expire: " + cacheInfo.expire + ")");
|
||||||
|
}
|
||||||
|
if (!request.loadContent)
|
||||||
|
return responce;
|
||||||
|
responce.content = new String(bytes, "UTF-8");
|
||||||
|
CustomSkinLoader.logger.debug("Content: " + responce.content);
|
||||||
|
return responce;
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
CustomSkinLoader.logger.debug("Failed to request (Exception: " + e.toString() + ")");
|
||||||
|
return loadFromCache(request, new HttpResponce());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static File getCacheFile(String hash) {
|
||||||
|
return new File(CACHE_DIR, hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static HttpResponce loadFromCache(HttpRequest request, HttpResponce responce) {
|
||||||
|
return loadFromCache(request, responce, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static HttpResponce loadFromCache(HttpRequest request, HttpResponce responce, long expireTime) {
|
||||||
|
if (request.cacheFile == null || !request.cacheFile.isFile())
|
||||||
|
return responce;
|
||||||
|
CustomSkinLoader.logger.debug("Cache file found (Length: " + request.cacheFile.length() + " , Path: '" + request.cacheFile.getAbsolutePath() + "' , Expire: " + expireTime + "')");
|
||||||
|
responce.fromCache = true;
|
||||||
|
responce.success = true;
|
||||||
|
if (!request.loadContent)
|
||||||
|
return responce;
|
||||||
|
|
||||||
|
CustomSkinLoader.logger.info("Try to load from cache '" + request.cacheFile.getAbsolutePath() + "'.");
|
||||||
|
try {
|
||||||
|
responce.content = FileUtils.readFileToString(request.cacheFile, "UTF-8");
|
||||||
|
CustomSkinLoader.logger.debug("Successfully load from cache");
|
||||||
|
CustomSkinLoader.logger.debug("Content: " + responce.content);
|
||||||
|
} catch (IOException e) {
|
||||||
|
CustomSkinLoader.logger.debug("Failed to load from cache (Exception: " + e.toString() + ")");
|
||||||
|
responce.success = false;
|
||||||
|
}
|
||||||
|
return responce;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final static Pattern MAX_AGE_PATTERN = Pattern.compile(".*?max-age=(\\d+).*?");
|
||||||
|
|
||||||
|
private static long getExpire(HttpURLConnection connection, int cacheTime) {
|
||||||
|
String cacheControl = connection.getHeaderField("Cache-Control");
|
||||||
|
if (StringUtils.isNotEmpty(cacheControl)) {
|
||||||
|
Matcher m = MAX_AGE_PATTERN.matcher(cacheControl);
|
||||||
|
if (m.matches())
|
||||||
|
return TimeUtil.getUnixTimestamp(Long.parseLong(m.group(m.groupCount())));
|
||||||
|
}
|
||||||
|
long expires = connection.getExpiration();
|
||||||
|
if (expires > 0)
|
||||||
|
return expires / 1000;
|
||||||
|
return TimeUtil.getUnixTimestampRandomDelay(cacheTime == 0 ? 86400 : cacheTime);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
package customskinloader.utils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
|
||||||
|
import customskinloader.CustomSkinLoader;
|
||||||
|
|
||||||
|
public class HttpTextureUtil {
|
||||||
|
public static class HttpTextureInfo{
|
||||||
|
public String url="";
|
||||||
|
public File cacheFile;
|
||||||
|
public String hash;
|
||||||
|
}
|
||||||
|
private static final String
|
||||||
|
LEGACY_MARK="(LEGACY)",
|
||||||
|
LOCAL_MARK="(LOCAL)",
|
||||||
|
LOCAL_LEGACY_MARK="(LOCAL_LEGACY)";
|
||||||
|
public static File defaultCacheDir;
|
||||||
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||||
|
public static void cleanCacheDir(){
|
||||||
|
if(defaultCacheDir!=null){
|
||||||
|
defaultCacheDir.delete();
|
||||||
|
defaultCacheDir.mkdirs();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static File getCacheDir(){
|
||||||
|
return defaultCacheDir==null?new File(MinecraftUtil.getMinecraftDataDir(),"assets/skins"):defaultCacheDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HttpTextureInfo toHttpTextureInfo(String fakeUrl){
|
||||||
|
HttpTextureInfo info=new HttpTextureInfo();
|
||||||
|
if(fakeUrl.startsWith("http")){
|
||||||
|
info.url=fakeUrl;
|
||||||
|
info.hash=FilenameUtils.getBaseName(fakeUrl);
|
||||||
|
info.cacheFile=getCacheFile(info.hash);
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
if(fakeUrl.startsWith(LOCAL_LEGACY_MARK)){
|
||||||
|
fakeUrl=fakeUrl.replace(LOCAL_LEGACY_MARK, "");
|
||||||
|
String[] t=fakeUrl.split(",",2);
|
||||||
|
if(t.length!=2)
|
||||||
|
return info;
|
||||||
|
info.cacheFile=new File(CustomSkinLoader.DATA_DIR,t[1]);
|
||||||
|
info.hash=t[0];
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
if(fakeUrl.startsWith(LOCAL_MARK)){
|
||||||
|
fakeUrl=fakeUrl.replace(LOCAL_MARK, "");
|
||||||
|
info.cacheFile=new File(CustomSkinLoader.DATA_DIR,fakeUrl);
|
||||||
|
info.hash=FilenameUtils.getBaseName(fakeUrl);
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
if(fakeUrl.startsWith(LEGACY_MARK)){
|
||||||
|
fakeUrl=fakeUrl.replace(LEGACY_MARK, "");
|
||||||
|
info.url=fakeUrl;
|
||||||
|
info.hash=DigestUtils.sha1Hex(info.url);
|
||||||
|
info.cacheFile = HttpRequestUtil.getCacheFile(info.hash);
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getLegacyFakeUrl(String url){
|
||||||
|
return LEGACY_MARK+url;
|
||||||
|
}
|
||||||
|
public static String getLocalFakeUrl(String path){
|
||||||
|
return LOCAL_MARK+path;
|
||||||
|
}
|
||||||
|
public static String getLocalLegacyFakeUrl(String path,String hash){
|
||||||
|
return LOCAL_LEGACY_MARK+hash+","+path;
|
||||||
|
}
|
||||||
|
public static String getHash(String url,long size,long lastModified){
|
||||||
|
return DigestUtils.sha1Hex(size+url+lastModified);
|
||||||
|
}
|
||||||
|
public static File getCacheFile(String hash){
|
||||||
|
return getCacheFile(defaultCacheDir,hash);
|
||||||
|
}
|
||||||
|
public static File getCacheFile(File cacheDir,String hash){
|
||||||
|
return new File(new File(cacheDir,hash.length()>2?hash.substring(0,2):"xx"), hash);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
package customskinloader.utils;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.Socket;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
import java.security.cert.X509Certificate;
|
||||||
|
|
||||||
|
import javax.net.ssl.*;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
public class HttpUtil0 {
|
||||||
|
public static boolean isLocal(String url){
|
||||||
|
return url != null && !url.startsWith("http");
|
||||||
|
}
|
||||||
|
|
||||||
|
//From: http://blog.csdn.net/xiyushiyi/article/details/46685387
|
||||||
|
public static void ignoreHttpsCertificate(){
|
||||||
|
HostnameVerifier doNotVerify = new HostnameVerifier() {
|
||||||
|
|
||||||
|
public boolean verify(String hostname, SSLSession session) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() {
|
||||||
|
public X509Certificate[] getAcceptedIssuers() {
|
||||||
|
return new X509Certificate[] {};
|
||||||
|
}
|
||||||
|
public void checkClientTrusted(X509Certificate[] chain, String authType){}
|
||||||
|
public void checkServerTrusted(X509Certificate[] chain, String authType){}
|
||||||
|
}};
|
||||||
|
|
||||||
|
try {
|
||||||
|
SSLContext sc = SSLContext.getInstance("TLS");
|
||||||
|
sc.init(null, trustAllCerts, new java.security.SecureRandom());
|
||||||
|
//HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
|
||||||
|
HttpsURLConnection.setDefaultSSLSocketFactory(new SSLSocketFactoryFacade());
|
||||||
|
HttpsURLConnection.setDefaultHostnameVerifier(doNotVerify);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String parseAddress(String address) {
|
||||||
|
if(StringUtils.isEmpty(address))
|
||||||
|
return null;
|
||||||
|
String[] addresses=address.split(":");
|
||||||
|
InetAddress add;
|
||||||
|
try {
|
||||||
|
add = InetAddress.getByName(addresses[0]);
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return add.getHostAddress()+(addresses.length==2 ? addresses[1] : "25565");
|
||||||
|
}
|
||||||
|
public static boolean isLanServer(String standardAddress){
|
||||||
|
if(StringUtils.isEmpty(standardAddress))
|
||||||
|
return true;
|
||||||
|
String[] addresses=standardAddress.split(":");
|
||||||
|
int numIp=getNumIp(addresses[0]);
|
||||||
|
return numIp==0||numIp==getNumIp("127.0.0.1")||
|
||||||
|
(numIp>=getNumIp("192.168.0.0")&&numIp<=getNumIp("192.168.255.255"))||
|
||||||
|
(numIp>=getNumIp("10.0.0.0")&&numIp<=getNumIp("10.255.255.255"))||
|
||||||
|
(numIp>=getNumIp("172.16.0.0")&&numIp<=getNumIp("172.31.255.255"));
|
||||||
|
}
|
||||||
|
public static int getNumIp(String ip){
|
||||||
|
int num=0;
|
||||||
|
String[] ips=ip.split("\\.");
|
||||||
|
if(ips.length!=4)
|
||||||
|
return 0;
|
||||||
|
for(int i=0;i<4;i++)
|
||||||
|
num+=Integer.parseInt(ips[i])*(256^(3-i));
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
//https://stackoverflow.com/questions/30817934/extended-server-name-sni-extension-not-sent-with-jdk1-8-0-but-send-with-jdk1-7
|
||||||
|
public static class SSLSocketFactoryFacade extends SSLSocketFactory {
|
||||||
|
|
||||||
|
SSLSocketFactory sslsf;
|
||||||
|
|
||||||
|
public SSLSocketFactoryFacade() {
|
||||||
|
sslsf = (SSLSocketFactory) SSLSocketFactory.getDefault();;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getDefaultCipherSuites() {
|
||||||
|
return sslsf.getDefaultCipherSuites();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getSupportedCipherSuites() {
|
||||||
|
return sslsf.getSupportedCipherSuites();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Socket createSocket(Socket socket, String s, int i, boolean b) throws IOException {
|
||||||
|
return sslsf.createSocket(socket, s, i, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Socket createSocket(String s, int i) throws IOException, UnknownHostException {
|
||||||
|
return sslsf.createSocket(s, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Socket createSocket(String s, int i, InetAddress inetAddress, int i1) throws IOException, UnknownHostException {
|
||||||
|
return sslsf.createSocket(s, i, inetAddress, i1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Socket createSocket(InetAddress inetAddress, int i) throws IOException {
|
||||||
|
return createSocket(inetAddress, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Socket createSocket(InetAddress inetAddress, int i, InetAddress inetAddress1, int i1) throws IOException {
|
||||||
|
return createSocket(inetAddress, i, inetAddress1, i1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package customskinloader.utils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
|
public class JavaUtil {
|
||||||
|
public static URL[] getClasspath() {
|
||||||
|
if (JavaUtil.class.getClassLoader() instanceof URLClassLoader) {
|
||||||
|
//Java 8-
|
||||||
|
//Use URLClassLoader Directly
|
||||||
|
URLClassLoader ucl = (URLClassLoader) JavaUtil.class.getClassLoader();
|
||||||
|
return ucl.getURLs();
|
||||||
|
} else {
|
||||||
|
//Java 9+
|
||||||
|
//It uses APPClassLoader instead of URLClassLoader
|
||||||
|
//Get Classpath from properties and parse it to URL array
|
||||||
|
String classpath = System.getProperty("java.class.path");
|
||||||
|
String[] elements = classpath.split(File.pathSeparator);
|
||||||
|
if (elements.length == 0)
|
||||||
|
return new URL[0];
|
||||||
|
LinkedList<URL> urls = new LinkedList<URL>();
|
||||||
|
for (String ele : elements) {
|
||||||
|
try {
|
||||||
|
urls.add(new File(ele).toURI().toURL());
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return urls.toArray(new URL[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,176 @@
|
|||||||
|
package customskinloader.utils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLDecoder;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.IImageBuffer;
|
||||||
|
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||||
|
import net.minecraft.client.renderer.texture.SimpleTexture;
|
||||||
|
import net.minecraft.client.renderer.texture.TextureManager;
|
||||||
|
import net.minecraft.client.resources.SkinManager;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Alexander Xia
|
||||||
|
* @since 13.6
|
||||||
|
*/
|
||||||
|
public class MinecraftUtil {
|
||||||
|
public static File getMinecraftDataDir() {
|
||||||
|
return Minecraft.getMinecraft().gameDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TextureManager getTextureManager() {
|
||||||
|
return Minecraft.getMinecraft().getTextureManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SkinManager getSkinManager() {
|
||||||
|
return Minecraft.getMinecraft().getSkinManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean is_1_15_plus = false;
|
||||||
|
private static Constructor<?> constructor = null;
|
||||||
|
public static SimpleTexture createThreadDownloadImageData(File cacheFileIn, String imageUrlIn, ResourceLocation textureResourceLocation, IImageBuffer imageBufferIn, MinecraftProfileTexture.Type textureType) {
|
||||||
|
if (constructor == null) {
|
||||||
|
Class<?> c;
|
||||||
|
try {
|
||||||
|
c = Class.forName("net.minecraft.client.renderer.texture.ThreadDownloadImageData", false, MinecraftUtil.class.getClassLoader()); // Forge 1.13
|
||||||
|
} catch (ClassNotFoundException e1) {
|
||||||
|
try {
|
||||||
|
c = Class.forName("net.minecraft.client.renderer.texture.DownloadingTexture", false, MinecraftUtil.class.getClassLoader()); // Forge 1.14+
|
||||||
|
} catch (ClassNotFoundException e2) {
|
||||||
|
c = ThreadDownloadImageData.class; // Forge 1.12- or Fabric or Vanilla
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
constructor = c.getConstructor(File.class, String.class, ResourceLocation.class, boolean.class, Runnable.class); // For 1.15+
|
||||||
|
is_1_15_plus = true;
|
||||||
|
} catch (NoSuchMethodException e1) {
|
||||||
|
try {
|
||||||
|
constructor = c.getConstructor(File.class, String.class, ResourceLocation.class, IImageBuffer.class); // For 1.15-
|
||||||
|
} catch (NoSuchMethodException e2) {
|
||||||
|
throw new RuntimeException(e2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (is_1_15_plus) {
|
||||||
|
return (SimpleTexture) constructor.newInstance(cacheFileIn, imageUrlIn, textureResourceLocation, textureType == MinecraftProfileTexture.Type.SKIN, imageBufferIn);
|
||||||
|
} else {
|
||||||
|
return (SimpleTexture) constructor.newInstance(cacheFileIn, imageUrlIn, textureResourceLocation, imageBufferIn);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static ArrayList<String> minecraftVersion = new ArrayList<String>();
|
||||||
|
private static String minecraftMainVersion = null;
|
||||||
|
private final static Pattern MINECRAFT_VERSION_PATTERN = Pattern.compile(".*?(\\d+\\.\\d+[\\.]?\\d*).*?");
|
||||||
|
|
||||||
|
public static ArrayList<String> getMinecraftVersions() {
|
||||||
|
if (minecraftVersion != null && !minecraftVersion.isEmpty())
|
||||||
|
return minecraftVersion;
|
||||||
|
testProbe();
|
||||||
|
return minecraftVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getMinecraftVersionText() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (String version : getMinecraftVersions())
|
||||||
|
sb.append(version).append(" ");
|
||||||
|
return StringUtils.trim(sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getMinecraftMainVersion() {
|
||||||
|
if (minecraftMainVersion != null)
|
||||||
|
return minecraftMainVersion;
|
||||||
|
for (String version : getMinecraftVersions()) {
|
||||||
|
Matcher m = null;
|
||||||
|
try {
|
||||||
|
m = MINECRAFT_VERSION_PATTERN.matcher(version);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
if (m == null || !m.matches())
|
||||||
|
continue;
|
||||||
|
minecraftMainVersion = m.group(m.groupCount());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return minecraftMainVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
// (domain|ip)(:port)
|
||||||
|
public static String getServerAddress() {
|
||||||
|
net.minecraft.client.multiplayer.ServerData data = Minecraft.getMinecraft().getCurrentServerData();
|
||||||
|
if (data == null)//Single Player
|
||||||
|
return null;
|
||||||
|
return data.serverIP;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ip:port
|
||||||
|
public static String getStandardServerAddress() {
|
||||||
|
return HttpUtil0.parseAddress(getServerAddress());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isLanServer() {
|
||||||
|
return HttpUtil0.isLanServer(getStandardServerAddress());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getCurrentUsername() {
|
||||||
|
return Minecraft.getMinecraft().getSession().getProfile().getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final static Pattern MINECRAFT_CORE_FILE_PATTERN = Pattern.compile("^(.*?)/versions/([^\\/\\\\]*?)/([^\\/\\\\]*?).jar$");
|
||||||
|
|
||||||
|
private static void testProbe() {
|
||||||
|
minecraftVersion.clear();
|
||||||
|
URL urls[] = JavaUtil.getClasspath();
|
||||||
|
for (URL url : urls) {
|
||||||
|
Matcher m = null;
|
||||||
|
try {
|
||||||
|
m = MINECRAFT_CORE_FILE_PATTERN.matcher(URLDecoder.decode(url.getPath(), "UTF-8"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
if (m == null || !m.matches())
|
||||||
|
continue;
|
||||||
|
minecraftVersion.add(m.group(2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isCoreFile(URL url) {
|
||||||
|
return regexMatch(url, MINECRAFT_CORE_FILE_PATTERN);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final static Pattern LIBRARY_FILE_PATTERN = Pattern.compile("^(.*?)/libraries/(.*?)/([^\\/\\\\]*?).jar$");
|
||||||
|
|
||||||
|
public static boolean isLibraryFile(URL url) {
|
||||||
|
return regexMatch(url, LIBRARY_FILE_PATTERN);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean regexMatch(URL url, Pattern p) {
|
||||||
|
Matcher m;
|
||||||
|
try {
|
||||||
|
m = p.matcher(URLDecoder.decode(url.getPath(), "UTF-8"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return m.matches();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getCredential(GameProfile profile) {
|
||||||
|
return (profile == null || profile.hashCode() == 0) ? null :
|
||||||
|
(profile.getId() == null ? profile.getName() : String.format("%s-%s", profile.getName(), profile.getId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package customskinloader.utils;
|
||||||
|
|
||||||
|
public class TimeUtil {
|
||||||
|
public static long getCurrentUnixTimestamp(){
|
||||||
|
return System.currentTimeMillis() / 1000L;
|
||||||
|
}
|
||||||
|
public static long getUnixTimestamp(long offset){
|
||||||
|
return getCurrentUnixTimestamp()+offset;
|
||||||
|
}
|
||||||
|
public static long getUnixTimestampRandomDelay(long offset){
|
||||||
|
return getCurrentUnixTimestamp()+offset+random(0,5);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int random(int min,int max){
|
||||||
|
return (int)(Math.random()*(max-min+1))+min;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package customskinloader.utils;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
public class Version implements Comparable {
|
||||||
|
private String version;
|
||||||
|
private int sub[];
|
||||||
|
|
||||||
|
public Version(String version) {
|
||||||
|
if (version == null) version = "";
|
||||||
|
this.version = version;
|
||||||
|
|
||||||
|
//Parse Subversion
|
||||||
|
String[] split = version.split("\\.");
|
||||||
|
sub = new int[split.length];
|
||||||
|
for (int i = 0; i < split.length; i++) {
|
||||||
|
if (StringUtils.isNumeric(split[i]))
|
||||||
|
sub[i] = Integer.parseInt(split[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Version of(String version) {
|
||||||
|
return new Version(version);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int compare(String version, String anotherVersion) {
|
||||||
|
return Version.of(version).compareTo(anotherVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(Object o) {
|
||||||
|
if (o instanceof String) o = Version.of((String) o);//Parse String version
|
||||||
|
if (!(o instanceof Version)) throw new IllegalArgumentException(String.format("'%s' is not a Version.", o));
|
||||||
|
|
||||||
|
Version v = (Version) o;
|
||||||
|
int i = 0;
|
||||||
|
//Skip same subversion
|
||||||
|
while (i < sub.length && i < v.sub.length && sub[i] == v.sub[i]) i++;
|
||||||
|
//Compare first non-equal number
|
||||||
|
if (i < sub.length && i < v.sub.length)
|
||||||
|
return (sub[i] < v.sub[i]) ? -1 : ((sub[i] == v.sub[i]) ? 0 : 1); //Integer.compare(sub[i], v.sub[i]);
|
||||||
|
//Compare length if all subversion is same
|
||||||
|
return Integer.signum(sub.length - v.sub.length);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package net.minecraft.client.renderer;
|
||||||
|
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.texture.NativeImage;
|
||||||
|
|
||||||
|
public interface IImageBuffer extends Runnable {
|
||||||
|
BufferedImage parseUserSkin(BufferedImage image);
|
||||||
|
|
||||||
|
NativeImage func_195786_a(NativeImage image);
|
||||||
|
|
||||||
|
void skinAvailable();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default void run() {
|
||||||
|
this.skinAvailable();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package net.minecraft.client.renderer.texture;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.IImageBuffer;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
public class DownloadingTexture extends SimpleTexture {
|
||||||
|
public DownloadingTexture(File cacheFileIn, String imageUrlIn, ResourceLocation textureResourceLocation, IImageBuffer imageBufferIn) {
|
||||||
|
super(textureResourceLocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DownloadingTexture(File cacheFileIn, String imageUrlIn, ResourceLocation textureResourceLocation, boolean legacySkinIn, Runnable processTaskIn) {
|
||||||
|
super(textureResourceLocation);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package net.minecraft.client.renderer.texture;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Empty stack for NativeImage
|
||||||
|
*/
|
||||||
|
public class NativeImage {
|
||||||
|
public NativeImage(int p_i48122_1_, int p_i48122_2_, boolean p_i48122_3_) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getWidth
|
||||||
|
*/
|
||||||
|
public int func_195702_a() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getHeight
|
||||||
|
*/
|
||||||
|
public int func_195714_b() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* copyImage image
|
||||||
|
*/
|
||||||
|
public void func_195703_a(NativeImage p_195703_1_) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fillAreaRGBA x0 y0 weight height rgba
|
||||||
|
*/
|
||||||
|
public void func_195715_a(int p_195715_1_, int p_195715_2_, int p_195715_3_, int p_195715_4_, int p_195715_5_) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* copyAreaRGBA x0 y0 dx dy weight height reversex reversey
|
||||||
|
*/
|
||||||
|
public void func_195699_a(int p_195699_1_, int p_195699_2_, int p_195699_3_, int p_195699_4_, int p_195699_5_, int p_195699_6_, boolean p_195699_7_, boolean p_195699_8_) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getPixelRGBA x y
|
||||||
|
*/
|
||||||
|
public int func_195709_a(int p_195709_1_, int p_195709_2_) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* setPixelRGBA x y rgba
|
||||||
|
*/
|
||||||
|
public void func_195700_a(int p_195700_1_, int p_195700_2_, int p_195700_3_) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package net.minecraft.client.renderer.texture;
|
||||||
|
|
||||||
|
// exclude
|
||||||
|
public interface Texture {
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package net.minecraft.client.renderer.texture;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.IImageBuffer;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
public class ThreadDownloadImageData extends SimpleTexture {
|
||||||
|
public ThreadDownloadImageData(File cacheFileIn, String imageUrlIn, ResourceLocation textureResourceLocation, IImageBuffer imageBufferIn) {
|
||||||
|
super(textureResourceLocation);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
customskinloader/fake/itf/IFakeTextureManager_1 customskinloader/fake/itf/IFakeTextureManager_1
|
||||||
|
func_229263_a_ (Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/client/renderer/texture/Texture;)Z method_4616
|
||||||
|
func_229267_b_ (Lnet/minecraft/util/ResourceLocation;)Lnet/minecraft/client/renderer/texture/Texture; method_4619
|
||||||
|
customskinloader/fake/itf/IFakeTextureManager_2 customskinloader/fake/itf/IFakeTextureManager_2
|
||||||
|
func_229263_a_ (Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/client/renderer/texture/Texture;)V method_4616
|
||||||
|
net/minecraft/client/gui/GuiPlayerTabOverlay net/minecraft/class_355
|
||||||
|
net/minecraft/client/gui/spectator/PlayerMenuObject net/minecraft/class_530
|
||||||
|
net/minecraft/client/Minecraft net/minecraft/class_310
|
||||||
|
field_71412_D field_1697
|
||||||
|
func_110432_I ()Lnet/minecraft/util/Session; method_1548
|
||||||
|
func_110434_K ()Lnet/minecraft/client/renderer/texture/TextureManager; method_1531
|
||||||
|
func_147104_D ()Lnet/minecraft/client/multiplayer/ServerData; method_1558
|
||||||
|
func_152342_ad ()Lnet/minecraft/client/resources/SkinManager; method_1582
|
||||||
|
func_152347_ac ()Lcom/mojang/authlib/minecraft/MinecraftSessionService; method_1495
|
||||||
|
func_71410_x ()Lnet/minecraft/client/Minecraft; method_1551
|
||||||
|
net/minecraft/client/multiplayer/ServerData net/minecraft/class_642
|
||||||
|
field_78845_b field_3761
|
||||||
|
net/minecraft/client/renderer/IImageBuffer net/minecraft/class_760
|
||||||
|
func_152634_a ()V method_3238
|
||||||
|
func_195786_a (Lnet/minecraft/client/renderer/texture/NativeImage;)Lnet/minecraft/client/renderer/texture/NativeImage; method_3237
|
||||||
|
net/minecraft/client/renderer/ThreadDownloadImageData net/minecraft/class_1046
|
||||||
|
net/minecraft/client/renderer/texture/DownloadingTexture net/minecraft/class_1046
|
||||||
|
net/minecraft/client/renderer/texture/ITextureObject net/minecraft/class_1062
|
||||||
|
net/minecraft/client/renderer/texture/NativeImage net/minecraft/class_1011
|
||||||
|
func_195699_a (IIIIIIZZ)V method_4304
|
||||||
|
func_195700_a (III)V method_4305
|
||||||
|
func_195702_a ()I method_4307
|
||||||
|
func_195703_a (Lnet/minecraft/client/renderer/texture/NativeImage;)V method_4317
|
||||||
|
func_195709_a (II)I method_4315
|
||||||
|
func_195714_b ()I method_4323
|
||||||
|
func_195715_a (IIIII)V method_4326
|
||||||
|
net/minecraft/client/renderer/texture/SimpleTexture net/minecraft/class_1049
|
||||||
|
net/minecraft/client/renderer/texture/Texture net/minecraft/class_1044
|
||||||
|
net/minecraft/client/renderer/texture/TextureManager net/minecraft/class_1060
|
||||||
|
func_110579_a (Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/client/renderer/texture/ITextureObject;)Z method_4616
|
||||||
|
func_110581_b (Lnet/minecraft/util/ResourceLocation;)Lnet/minecraft/client/renderer/texture/ITextureObject; method_4619
|
||||||
|
net/minecraft/client/renderer/texture/ThreadDownloadImageData net/minecraft/class_1046
|
||||||
|
net/minecraft/client/resources/DefaultPlayerSkin net/minecraft/class_1068
|
||||||
|
func_177334_a (Ljava/util/UUID;)Lnet/minecraft/util/ResourceLocation; method_4648
|
||||||
|
func_177335_a ()Lnet/minecraft/util/ResourceLocation; method_4649
|
||||||
|
net/minecraft/client/resources/SkinManager net/minecraft/class_1071
|
||||||
|
func_152790_a (Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V method_4652
|
||||||
|
net/minecraft/client/resources/SkinManager$SkinAvailableCallback net/minecraft/class_1071$class_1072
|
||||||
|
func_180521_a (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/util/ResourceLocation;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)V onSkinTextureAvailable
|
||||||
|
net/minecraft/tileentity/TileEntitySkull net/minecraft/class_2631
|
||||||
|
net/minecraft/util/ResourceLocation net/minecraft/class_2960
|
||||||
|
net/minecraft/util/Session net/minecraft/class_320
|
||||||
|
func_148256_e ()Lcom/mojang/authlib/GameProfile; method_1677
|
||||||
|
net/minecraft/util/StringUtils net/minecraft/class_3544
|
||||||
|
func_76338_a (Ljava/lang/String;)Ljava/lang/String; method_15440
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
apply plugin: 'net.minecraftforge.gradle.forge'
|
||||||
|
apply plugin: 'org.spongepowered.mixin'
|
||||||
|
|
||||||
|
ext.configFile = file "build.properties"
|
||||||
|
configFile.withReader {
|
||||||
|
def prop = new Properties()
|
||||||
|
prop.load(it)
|
||||||
|
project.ext.config = new ConfigSlurper().parse prop
|
||||||
|
}
|
||||||
|
apply from: rootProject.file("BuildScripts/version.gradle")
|
||||||
|
|
||||||
|
version = getCSLVersion()
|
||||||
|
group = "customskinloader"
|
||||||
|
archivesBaseName = "CustomSkinLoader_Fabric"
|
||||||
|
ext.shortVersion = getShortVersion()
|
||||||
|
|
||||||
|
sourceCompatibility = targetCompatibility = 1.8
|
||||||
|
compileJava {
|
||||||
|
sourceCompatibility = targetCompatibility = 1.8
|
||||||
|
}
|
||||||
|
|
||||||
|
minecraft {
|
||||||
|
version = config.forge_mc_version + "-" + config.forge_version
|
||||||
|
runDir = "run"
|
||||||
|
mappings = config.mappings_version
|
||||||
|
|
||||||
|
replace '@MOD_VERSION@', rootProject.ext.config.version
|
||||||
|
replace '@MOD_FULL_VERSION@', project.version
|
||||||
|
replaceIn 'CustomSkinLoader.java'
|
||||||
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
exclude 'customskinloader/tweaker/**'
|
||||||
|
exclude 'net/minecraft/client/renderer/texture/**'
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = "sponge"
|
||||||
|
url = "https://repo.spongepowered.org/maven"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation 'org.spongepowered:mixin:0.8'
|
||||||
|
}
|
||||||
|
|
||||||
|
mixin {
|
||||||
|
add sourceSets.main, "mixins.customskinloader.refmap.json"
|
||||||
|
reobfSrgFile = "mixin.srg"
|
||||||
|
reobfNotchSrgFile = "mixin.srg"
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
main {
|
||||||
|
java {
|
||||||
|
//Common
|
||||||
|
srcDir "${rootDir}/Common/source"
|
||||||
|
//Vanilla
|
||||||
|
srcDir "${rootDir}/Vanilla/source"
|
||||||
|
//Fabric
|
||||||
|
srcDir "source"
|
||||||
|
}
|
||||||
|
resources {
|
||||||
|
//Common
|
||||||
|
srcDir "${rootDir}/Common/resource"
|
||||||
|
exclude "Profile.json"
|
||||||
|
//Fabric
|
||||||
|
srcDir "resource"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
processResources {
|
||||||
|
expand([
|
||||||
|
modVersion : rootProject.ext.config.version,
|
||||||
|
modFullVersion : project.version,
|
||||||
|
modShortFullVersion: shortVersion,
|
||||||
|
mcVersion : config.minecraft_version,
|
||||||
|
mcFullVersions : config.minecraft_full_versions,
|
||||||
|
forgeVersion : config.forge_version,
|
||||||
|
gitVersion : System.getenv("CIRCLE_SHA1"),
|
||||||
|
buildUrl : System.getenv("CIRCLE_BUILD_URL"),
|
||||||
|
releaseTime : new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: rootProject.file("BuildScripts/remap.gradle")
|
||||||
|
task afterBuild {
|
||||||
|
doLast {
|
||||||
|
//renameSrgJar
|
||||||
|
def file0 = file("build/libs/${archivesBaseName}-${version}.jar")
|
||||||
|
def file1 = file("build/libs/${archivesBaseName}-${version}-srg.jar")
|
||||||
|
file0.renameTo(file1)
|
||||||
|
|
||||||
|
//reobfSrgToNotch
|
||||||
|
reobfSrgToNotch()
|
||||||
|
|
||||||
|
//copyBuildFile
|
||||||
|
copy {
|
||||||
|
from "build/libs"
|
||||||
|
into "${rootDir}/build/libs"
|
||||||
|
include "**/*.jar"
|
||||||
|
exclude "**/*-srg.jar"
|
||||||
|
exclude "**/*-dev.jar"
|
||||||
|
exclude "**/*-sources.jar"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
build.finalizedBy afterBuild
|
||||||
|
|
||||||
|
|
||||||
|
apply plugin: 'maven-publish'
|
||||||
|
publishing {
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = "GitHubPackages"
|
||||||
|
url = uri("https://maven.pkg.github.com/xfl03/MCCustomSkinLoader")
|
||||||
|
credentials {
|
||||||
|
username = project.findProperty("gpr.user") ?: System.getenv("USERNAME")
|
||||||
|
password = project.findProperty("gpr.key") ?: System.getenv("GITHUB_TOKEN")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
publications {
|
||||||
|
gpr(MavenPublication) {
|
||||||
|
groupId 'customskinloader'
|
||||||
|
artifactId project.archivesBaseName
|
||||||
|
from(components.java)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tasks.withType(PublishToMavenRepository) {
|
||||||
|
onlyIf { System.getenv("GITHUB_TOKEN") != null }
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
minecraft_version=1.14
|
||||||
|
minecraft_full_versions=1.14,1.14.1,1.14.2,1.14.3,1.14.4,1.15,1.15.1,1.15.2,1.16,1.16.1
|
||||||
|
#forge gradle needs forge version
|
||||||
|
forge_mc_version=1.12.2
|
||||||
|
forge_version=14.23.5.2768
|
||||||
|
mappings_version=stable_39
|
||||||
|
srg_notch_map=Fabric.tsrg
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
CL: com/mojang/blaze3d/matrix/MatrixStack net/minecraft/class_4587
|
||||||
|
CL: net/minecraft/client/entity/AbstractClientPlayer net/minecraft/class_742
|
||||||
|
CL: net/minecraft/client/gui/GuiPlayerTabOverlay net/minecraft/class_355
|
||||||
|
CL: net/minecraft/client/Minecraft net/minecraft/class_310
|
||||||
|
CL: net/minecraft/client/renderer/ThreadDownloadImageData net/minecraft/class_1046
|
||||||
|
CL: net/minecraft/client/renderer/texture/NativeImage net/minecraft/class_1011
|
||||||
|
CL: net/minecraft/client/renderer/texture/TextureManager net/minecraft/class_1060
|
||||||
|
CL: net/minecraft/client/resources/SkinManager net/minecraft/class_1071
|
||||||
|
CL: net/minecraft/client/resources/SkinManager$SkinAvailableCallback net/minecraft/class_1071$class_1072
|
||||||
|
CL: net/minecraft/scoreboard/ScoreObjective net/minecraft/class_266
|
||||||
|
CL: net/minecraft/scoreboard/Scoreboard net/minecraft/class_269
|
||||||
|
CL: net/minecraft/tileentity/TileEntitySkull net/minecraft/class_2631
|
||||||
|
CL: net/minecraft/util/ResourceLocation net/minecraft/class_2960
|
||||||
|
FD: net/minecraft/client/renderer/ThreadDownloadImageData/processTask net/minecraft/class_1046/field_20843
|
||||||
|
MD: net/minecraft/client/entity/AbstractClientPlayer/getDownloadImageSkin (Lnet/minecraft/util/ResourceLocation;Ljava/lang/String;)Lnet/minecraft/client/renderer/ThreadDownloadImageData; net/minecraft/class_742/method_3120 (Lnet/minecraft/class_2960;Ljava/lang/String;)Lnet/minecraft/class_1046;
|
||||||
|
MD: net/minecraft/client/entity/AbstractClientPlayer/getLocationSkin (Ljava/lang/String;)Lnet/minecraft/util/ResourceLocation; net/minecraft/class_742/method_3124 (Ljava/lang/String;)Lnet/minecraft/class_2960;
|
||||||
|
MD: net/minecraft/client/gui/GuiPlayerTabOverlay/renderPlayerlist (ILnet/minecraft/scoreboard/Scoreboard;Lnet/minecraft/scoreboard/ScoreObjective;)V net/minecraft/class_355/method_1919 (ILnet/minecraft/class_269;Lnet/minecraft/class_266;)V
|
||||||
|
MD: net/minecraft/client/gui/GuiPlayerTabOverlay/renderPlayerlist (Lcom/mojang/blaze3d/matrix/MatrixStack;ILnet/minecraft/scoreboard/Scoreboard;Lnet/minecraft/scoreboard/ScoreObjective;)V net/minecraft/class_355/method_1919 (Lnet/minecraft/class_4587;ILnet/minecraft/class_269;Lnet/minecraft/class_266;)V
|
||||||
|
MD: net/minecraft/client/Minecraft/isIntegratedServerRunning ()Z net/minecraft/class_310/method_1542 ()Z
|
||||||
|
MD: net/minecraft/client/renderer/ThreadDownloadImageData/loadTexture (Ljava/io/InputStream;)Lnet/minecraft/client/renderer/texture/NativeImage; net/minecraft/class_1046/method_22795 (Ljava/io/InputStream;)Lnet/minecraft/class_1011;
|
||||||
|
MD: net/minecraft/client/renderer/ThreadDownloadImageData/processLegacySkin (Lnet/minecraft/client/renderer/texture/NativeImage;)Lnet/minecraft/client/renderer/texture/NativeImage; net/minecraft/class_1046/method_22798 (Lnet/minecraft/class_1011;)Lnet/minecraft/class_1011;
|
||||||
|
MD: net/minecraft/client/resources/SkinManager/loadProfileTextures (Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V net/minecraft/class_1071/method_4652 (Lcom/mojang/authlib/GameProfile;Lnet/minecraft/class_1071$class_1072;Z)V
|
||||||
|
MD: net/minecraft/client/resources/SkinManager/loadSkin (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)Lnet/minecraft/util/ResourceLocation; net/minecraft/class_1071/method_4651 (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/class_1071$class_1072;)Lnet/minecraft/class_2960;
|
||||||
|
MD: net/minecraft/client/resources/SkinManager/loadSkinFromCache (Lcom/mojang/authlib/GameProfile;)Ljava/util/Map; net/minecraft/class_1071/method_4654 (Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;
|
||||||
|
MD: net/minecraft/tileentity/TileEntitySkull/updateGameProfile (Lcom/mojang/authlib/GameProfile;)Lcom/mojang/authlib/GameProfile; net/minecraft/class_2631/method_11335 (Lcom/mojang/authlib/GameProfile;)Lcom/mojang/authlib/GameProfile;
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"schemaVersion": 1,
|
||||||
|
"id": "customskinloader",
|
||||||
|
"version": "${modFullVersion}",
|
||||||
|
|
||||||
|
"name": "CustomSkinLoader",
|
||||||
|
"description": "Custom Skin Loader for Minecraft",
|
||||||
|
"authors": ["xfl03", "JLChnToZ"],
|
||||||
|
"contact": {
|
||||||
|
"homepage": "https://github.com/xfl03/MCCustomSkinLoader",
|
||||||
|
"issues": "https://github.com/xfl03/MCCustomSkinLoader/issues",
|
||||||
|
"sources": "https://github.com/xfl03/MCCustomSkinLoader"
|
||||||
|
},
|
||||||
|
"license": "GPL-3.0-only",
|
||||||
|
|
||||||
|
"environment": "client",
|
||||||
|
"mixins": [
|
||||||
|
{
|
||||||
|
"config": "mixins.customskinloader.json",
|
||||||
|
"environment": "client"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"compatibilityLevel": "JAVA_8",
|
||||||
|
"package": "customskinloader.mixin",
|
||||||
|
"client": [
|
||||||
|
"MixinGuiPlayerTabOverlay",
|
||||||
|
"MixinMinecraft",
|
||||||
|
"MixinSkinManager",
|
||||||
|
"MixinTextureManager",
|
||||||
|
"MixinThreadDownloadImageData",
|
||||||
|
"MixinTileEntitySkull"
|
||||||
|
],
|
||||||
|
"refmap": "mixins.customskinloader.refmap.json",
|
||||||
|
"injectors": {
|
||||||
|
"defaultRequire": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
/bin/
|
||||||
|
/build/
|
||||||
|
/run/
|
||||||
Binary file not shown.
@@ -0,0 +1,143 @@
|
|||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
jcenter()
|
||||||
|
maven {
|
||||||
|
name = "forge"
|
||||||
|
url = "http://files.minecraftforge.net/maven"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
apply plugin: 'net.minecraftforge.gradle.forge'
|
||||||
|
|
||||||
|
ext.configFile = file "build.properties"
|
||||||
|
configFile.withReader {
|
||||||
|
def prop = new Properties()
|
||||||
|
prop.load(it)
|
||||||
|
project.ext.config = new ConfigSlurper().parse prop
|
||||||
|
}
|
||||||
|
apply from: rootProject.file("BuildScripts/version.gradle")
|
||||||
|
|
||||||
|
archivesBaseName = "CustomSkinLoader_Forge"
|
||||||
|
version = getCSLVersion()
|
||||||
|
group = "customskinloader"
|
||||||
|
|
||||||
|
sourceCompatibility = targetCompatibility = 1.8
|
||||||
|
compileJava {
|
||||||
|
sourceCompatibility = targetCompatibility = 1.8
|
||||||
|
}
|
||||||
|
jar {
|
||||||
|
manifest {
|
||||||
|
attributes([
|
||||||
|
"FMLCorePlugin" : "customskinloader.forge.ForgePlugin",
|
||||||
|
"FMLCorePluginContainsFMLMod": true,
|
||||||
|
"Specification-Title" : "CustomSkinLoader",
|
||||||
|
"Specification-Vendor" : "xfl03",
|
||||||
|
"Specification-Version" : "1",
|
||||||
|
"Implementation-Title" : "CustomSkinLoader",
|
||||||
|
"Implementation-Version" : "${version}",
|
||||||
|
"Implementation-Vendor" : "xfl03",
|
||||||
|
"Implementation-Timestamp" : new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
|
||||||
|
])
|
||||||
|
}
|
||||||
|
exclude 'net/minecraft/client/renderer/texture/**'
|
||||||
|
exclude 'net/minecraftforge/**'
|
||||||
|
}
|
||||||
|
sourceSets {
|
||||||
|
main {
|
||||||
|
java {
|
||||||
|
//Common
|
||||||
|
srcDir "${rootDir}/Common/source"
|
||||||
|
//Forge
|
||||||
|
srcDir "source"
|
||||||
|
}
|
||||||
|
resources {
|
||||||
|
//Common
|
||||||
|
srcDir "${rootDir}/Common/resource"
|
||||||
|
exclude "Profile.json"
|
||||||
|
//Forge
|
||||||
|
srcDir "resource"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
minecraft {
|
||||||
|
version = config.forge_mc_version + "-" + config.forge_version
|
||||||
|
runDir = "run"
|
||||||
|
mappings = config.mappings_version
|
||||||
|
clientJvmArgs += "-Dfml.coreMods.load=customskinloader.forge.ForgePlugin"
|
||||||
|
|
||||||
|
replace '@MOD_VERSION@', rootProject.ext.config.version
|
||||||
|
replace '@MOD_FULL_VERSION@', project.version
|
||||||
|
replaceIn 'CustomSkinLoader.java'
|
||||||
|
replaceIn 'ForgeMod.java'
|
||||||
|
}
|
||||||
|
|
||||||
|
processResources {
|
||||||
|
filesNotMatching("**/*.js"){
|
||||||
|
expand([
|
||||||
|
modVersion : rootProject.ext.config.version,
|
||||||
|
modFullVersion: project.version,
|
||||||
|
mcVersion : config.minecraft_version,
|
||||||
|
mcFullVersions: config.minecraft_full_versions,
|
||||||
|
forgeVersion : config.forge_version,
|
||||||
|
gitVersion : System.getenv("CIRCLE_SHA1"),
|
||||||
|
buildUrl : System.getenv("CIRCLE_BUILD_URL"),
|
||||||
|
releaseTime : new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
|
||||||
|
])}
|
||||||
|
}
|
||||||
|
|
||||||
|
task signJar(type: SignJar, dependsOn: reobfJar) {
|
||||||
|
onlyIf { System.getenv("KEY_PASS") != null }
|
||||||
|
doLast { System.out.println("Jar will be signed.") }
|
||||||
|
|
||||||
|
inputFile = jar.archivePath
|
||||||
|
outputFile = jar.archivePath
|
||||||
|
|
||||||
|
keyStore = 'CustomSkinLoader.jks'
|
||||||
|
alias = 'CustomSkinLoader'
|
||||||
|
storePass = System.getenv("KEY_PASS")
|
||||||
|
keyPass = System.getenv("KEY_PASS")
|
||||||
|
}
|
||||||
|
build.dependsOn signJar
|
||||||
|
|
||||||
|
task afterBuild {
|
||||||
|
doLast {
|
||||||
|
//copyBuildFile
|
||||||
|
copy {
|
||||||
|
from "build/libs"
|
||||||
|
into "${rootDir}/build/libs"
|
||||||
|
include "**/*.jar"
|
||||||
|
exclude "**/*-sources.jar"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
build.finalizedBy afterBuild
|
||||||
|
|
||||||
|
|
||||||
|
apply plugin: 'maven-publish'
|
||||||
|
publishing {
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = "GitHubPackages"
|
||||||
|
url = uri("https://maven.pkg.github.com/xfl03/MCCustomSkinLoader")
|
||||||
|
credentials {
|
||||||
|
username = project.findProperty("gpr.user") ?: System.getenv("USERNAME")
|
||||||
|
password = project.findProperty("gpr.key") ?: System.getenv("GITHUB_TOKEN")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
publications {
|
||||||
|
gpr(MavenPublication) {
|
||||||
|
groupId 'customskinloader'
|
||||||
|
artifactId project.archivesBaseName
|
||||||
|
from(components.java)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tasks.withType(PublishToMavenRepository) {
|
||||||
|
onlyIf { System.getenv("GITHUB_TOKEN") != null }
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
minecraft_version=1.12.2
|
||||||
|
minecraft_full_versions=1.8,1.8.8,1.8.9,1.9,1.9.4,1.10,1.10.2,1.11,1.11.2,1.12,1.12.1,1.12.2,1.13.2,1.14.2,1.14.3,1.14.4,1.15,1.15.1,1.15.2,1.16.1
|
||||||
|
#forge gradle needs forge version
|
||||||
|
forge_mc_version=1.12.2
|
||||||
|
forge_version=14.23.5.2768
|
||||||
|
mappings_version=stable_39
|
||||||
|
srg_notch_map=Forge.srg
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"transformers": "transformers.js"
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
modLoader="javafml"
|
||||||
|
loaderVersion="[25,)"
|
||||||
|
[[mods]]
|
||||||
|
modId="customskinloader"
|
||||||
|
version="${modFullVersion}"
|
||||||
|
displayName="CustomSkinLoader"
|
||||||
|
description='''
|
||||||
|
Custom Skin Loader for Minecraft
|
||||||
|
'''
|
||||||
|
issueTrackerURL="https://github.com/xfl03/MCCustomSkinLoader/issues"
|
||||||
|
displayURL="https://github.com/xfl03/MCCustomSkinLoader"
|
||||||
|
authors=["xfl03", "JLChnToZ"]
|
||||||
|
[[dependencies.customskinloader]]
|
||||||
|
modId="forge"
|
||||||
|
mandatory=true
|
||||||
|
versionRange="[25,)"
|
||||||
|
ordering="NONE"
|
||||||
|
side="CLIENT"
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"modid": "customskinloader",
|
||||||
|
"name": "CustomSkinLoader",
|
||||||
|
"description": "Custom Skin Loader for Minecraft",
|
||||||
|
"version": "${modFullVersion}",
|
||||||
|
"url": "https://github.com/xfl03/MCCustomSkinLoader",
|
||||||
|
"authorList": ["xfl03", "JLChnToZ"]
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"pack": {
|
||||||
|
"description": "CustomSkinLoader resources",
|
||||||
|
"pack_format": 4
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
var FieldInsnNode = Java.type('org.objectweb.asm.tree.FieldInsnNode');
|
||||||
|
var InsnList = Java.type('org.objectweb.asm.tree.InsnList');
|
||||||
|
var InsnNode = Java.type('org.objectweb.asm.tree.InsnNode');
|
||||||
|
var MethodInsnNode = Java.type('org.objectweb.asm.tree.MethodInsnNode');
|
||||||
|
var VarInsnNode = Java.type('org.objectweb.asm.tree.VarInsnNode');
|
||||||
|
|
||||||
|
var Opcodes = Java.type('org.objectweb.asm.Opcodes');
|
||||||
|
|
||||||
|
function initializeCoreMod() {
|
||||||
|
return {
|
||||||
|
'PlayerTabTransformer': {
|
||||||
|
'target': {
|
||||||
|
'type': 'CLASS',
|
||||||
|
'names': function (target) {
|
||||||
|
return ['net/minecraft/client/gui/GuiPlayerTabOverlay', 'net/minecraft/client/gui/overlay/PlayerTabOverlayGui'];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'transformer': function (cn) {
|
||||||
|
cn.methods.forEach(function (mn) {
|
||||||
|
if (mn.name === 'func_175249_a' || mn.name === 'func_238523_a_') {
|
||||||
|
for (var iterator = mn.instructions.iterator(); iterator.hasNext();) {
|
||||||
|
var node = iterator.next();
|
||||||
|
if (node.getOpcode() === Opcodes.INVOKEVIRTUAL && node.name === "func_71387_A") {
|
||||||
|
mn.instructions.insertBefore(node, new InsnNode(Opcodes.POP));
|
||||||
|
mn.instructions.set(node, new InsnNode(Opcodes.ICONST_1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return cn;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'TileEntitySkullTransformer': {
|
||||||
|
'target': {
|
||||||
|
'type': 'CLASS',
|
||||||
|
'names': function (target) {
|
||||||
|
return ['net/minecraft/tileentity/TileEntitySkull', 'net/minecraft/tileentity/SkullTileEntity'];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'transformer': function (cn) {
|
||||||
|
cn.methods.forEach(function (mn) {
|
||||||
|
if (mn.name === 'func_174884_b') {
|
||||||
|
var il = new InsnList();
|
||||||
|
il.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
||||||
|
il.add(new InsnNode(Opcodes.ARETURN));
|
||||||
|
mn.instructions.insert(il);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return cn;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// For 1.13+
|
||||||
|
'AbstractTextureTransformer': {
|
||||||
|
'target': {
|
||||||
|
'type': 'CLASS',
|
||||||
|
'name': 'net/minecraft/client/renderer/texture/AbstractTexture'
|
||||||
|
},
|
||||||
|
'transformer': function (cn) {
|
||||||
|
cn.interfaces.add("net/minecraft/client/renderer/texture/Texture");
|
||||||
|
return cn;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'TextureTransformer': {
|
||||||
|
'target': {
|
||||||
|
'type': 'CLASS',
|
||||||
|
'name': 'net/minecraft/client/renderer/texture/Texture'
|
||||||
|
},
|
||||||
|
'transformer': function (cn) {
|
||||||
|
if (cn.access === 0) {
|
||||||
|
cn.access = Opcodes.ACC_PUBLIC | Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT;
|
||||||
|
}
|
||||||
|
return cn;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// For 1.14+
|
||||||
|
'MinecraftTransformer': {
|
||||||
|
'target': {
|
||||||
|
'type': 'CLASS',
|
||||||
|
'name': 'net/minecraft/client/Minecraft'
|
||||||
|
},
|
||||||
|
'transformer': function (cn) {
|
||||||
|
cn.interfaces.add("customskinloader/fake/itf/IFakeMinecraft");
|
||||||
|
return cn;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// For 1.15+
|
||||||
|
'TextureManagerTransformer': {
|
||||||
|
'target': {
|
||||||
|
'type': 'CLASS',
|
||||||
|
'name': 'net/minecraft/client/renderer/texture/TextureManager'
|
||||||
|
},
|
||||||
|
'transformer': function (cn) {
|
||||||
|
cn.interfaces.add("customskinloader/fake/itf/IFakeTextureManager_1");
|
||||||
|
cn.interfaces.add("customskinloader/fake/itf/IFakeTextureManager_2");
|
||||||
|
return cn;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'DownloadingTextureTransformer': {
|
||||||
|
'target': {
|
||||||
|
'type': 'CLASS',
|
||||||
|
'name': 'net/minecraft/client/renderer/texture/DownloadingTexture'
|
||||||
|
},
|
||||||
|
'transformer': function (cn) {
|
||||||
|
cn.methods.forEach(function (mn) {
|
||||||
|
if (mn.name === 'func_229159_a_') {
|
||||||
|
for (var iterator = mn.instructions.iterator(); iterator.hasNext();) {
|
||||||
|
var node = iterator.next();
|
||||||
|
if (node.getOpcode() === Opcodes.INVOKESTATIC && node.name === "func_229163_c_") {
|
||||||
|
mn.instructions.insertBefore(node, new VarInsnNode(Opcodes.ALOAD, 0));
|
||||||
|
mn.instructions.insertBefore(node, new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/renderer/texture/DownloadingTexture", "field_229155_i_", "Ljava/lang/Runnable;"));
|
||||||
|
iterator.set(new MethodInsnNode(Opcodes.INVOKESTATIC, "customskinloader/fake/FakeSkinBuffer", "processLegacySkin", "(Lnet/minecraft/client/renderer/texture/NativeImage;Ljava/lang/Runnable;)Lnet/minecraft/client/renderer/texture/NativeImage;", false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return cn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package customskinloader.forge;
|
||||||
|
|
||||||
|
import customskinloader.CustomSkinLoader;
|
||||||
|
|
||||||
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||||
|
import net.minecraftforge.fml.common.event.FMLFingerprintViolationEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forge Mod Container
|
||||||
|
*/
|
||||||
|
@Mod(
|
||||||
|
value = "customskinloader",
|
||||||
|
modid = "customskinloader",
|
||||||
|
name = "CustomSkinLoader",
|
||||||
|
version = "@MOD_FULL_VERSION@",
|
||||||
|
clientSideOnly = true,
|
||||||
|
acceptedMinecraftVersions = "[1.8,)",
|
||||||
|
acceptableRemoteVersions = "*",
|
||||||
|
certificateFingerprint = "52885f395e68f42e9b3b629ba56ecf606f7d4269"
|
||||||
|
)//1.13-
|
||||||
|
public class ForgeMod {
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void fingerprintError(FMLFingerprintViolationEvent event) {
|
||||||
|
if (event.isDirectory()) return;//Development Environment
|
||||||
|
|
||||||
|
CustomSkinLoader.logger.warning("!!!Fingerprint ERROR!!!");
|
||||||
|
CustomSkinLoader.logger.warning("Failed to check fingerprint in file '" + event.getSource().getAbsolutePath() + "'.");
|
||||||
|
CustomSkinLoader.logger.warning("Excepted Fingerprint: " + event.getExpectedFingerprint());
|
||||||
|
if (event.getFingerprints().isEmpty()) {
|
||||||
|
CustomSkinLoader.logger.warning("No Fingerprint Founded.");
|
||||||
|
} else {
|
||||||
|
CustomSkinLoader.logger.warning("Founded Fingerprint: ");
|
||||||
|
for (String s : event.getFingerprints())
|
||||||
|
CustomSkinLoader.logger.warning(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new RuntimeException("Fingerprint ERROR, please **DO NOT MODIFY** any mod.");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package customskinloader.forge;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
|
||||||
|
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin.Name;
|
||||||
|
|
||||||
|
@Name("CustomSkinLoader")
|
||||||
|
public class ForgePlugin implements IFMLLoadingPlugin {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getASMTransformerClass() {
|
||||||
|
return new String[]{"customskinloader.forge.loader.LaunchWrapper"};//LaunchWrapper
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getModContainerClass() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSetupClass() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void injectData(Map<String, Object> data) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getAccessTransformerClass() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
package customskinloader.forge;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import customskinloader.Logger;
|
||||||
|
import net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
|
||||||
|
public class TransformerManager {
|
||||||
|
public static Logger logger = new Logger(new File("./CustomSkinLoader/ForgePlugin.log"));
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.TYPE)
|
||||||
|
public @interface TransformTarget {
|
||||||
|
String className();
|
||||||
|
|
||||||
|
String[] methodNames() default {};
|
||||||
|
|
||||||
|
String desc() default "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IClassTransformer {
|
||||||
|
void transform(ClassNode cn);
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IMethodTransformer {
|
||||||
|
void transform(ClassNode cn, MethodNode mn);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, IClassTransformer> classMap = new HashMap<>();
|
||||||
|
public Map<String, Map<String, IMethodTransformer>> map = new HashMap<>();
|
||||||
|
|
||||||
|
public TransformerManager(IMethodTransformer... methodTransformers) {
|
||||||
|
this(new IClassTransformer[0], methodTransformers);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TransformerManager(IClassTransformer[] classTransformers, IMethodTransformer[] methodTransformers) {
|
||||||
|
for (IClassTransformer t : classTransformers) {
|
||||||
|
TransformTarget tt = this.getTransformTarget(t.getClass());
|
||||||
|
if (tt != null) {
|
||||||
|
addClassTransformer(tt.className(), t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (IMethodTransformer t : methodTransformers) {
|
||||||
|
TransformTarget tt = this.getTransformTarget(t.getClass());
|
||||||
|
if (tt != null) {
|
||||||
|
addMethodTransformer(tt, tt.className(), t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private TransformTarget getTransformTarget(Class<?> cl) {
|
||||||
|
logger.info("[CSL DEBUG] REGISTERING TRANSFORMER %s", cl.getName());
|
||||||
|
if (!cl.isAnnotationPresent(TransformTarget.class)) {
|
||||||
|
logger.info("[CSL DEBUG] ERROR occurs while parsing Annotation.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return cl.getAnnotation(TransformTarget.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addClassTransformer(String className, IClassTransformer transformer) {
|
||||||
|
if (!classMap.containsKey(className)) {
|
||||||
|
classMap.put(className, transformer);
|
||||||
|
logger.info("[CSL DEBUG] REGISTERING CLASS %s", className);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addMethodTransformer(TransformTarget target, String className, IMethodTransformer transformer) {
|
||||||
|
if (!map.containsKey(className))
|
||||||
|
map.put(className, new HashMap<String, IMethodTransformer>());
|
||||||
|
for (String methodName : target.methodNames()) {
|
||||||
|
map.get(className).put(methodName + target.desc(), transformer);
|
||||||
|
logger.info("[CSL DEBUG] REGISTERING METHOD %s(%s)", className, methodName + target.desc());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClassNode transform(ClassNode classNode) {
|
||||||
|
IClassTransformer transformer = classMap.get(FMLDeobfuscatingRemapper.INSTANCE.map(classNode.name).replace("/", "."));
|
||||||
|
if (transformer != null) {
|
||||||
|
try {
|
||||||
|
transformer.transform(classNode);
|
||||||
|
logger.info("[CSL DEBUG] Successfully transformed class %s", classNode.name);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warning("[CSL DEBUG] An error happened when transforming class %s.", classNode.name);
|
||||||
|
logger.warning(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return classNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MethodNode transform(ClassNode classNode, MethodNode methodNode, String className, String methodName, String methodDesc) {
|
||||||
|
Map<String, IMethodTransformer> transMap = map.get(className);
|
||||||
|
String methodTarget = methodName + methodDesc;
|
||||||
|
if (transMap != null && transMap.containsKey(methodTarget)) {
|
||||||
|
try {
|
||||||
|
transMap.get(methodTarget).transform(classNode, methodNode);
|
||||||
|
logger.info("[CSL DEBUG] Successfully transformed method %s in class %s", methodName, className);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warning("[CSL DEBUG] An error happened when transforming method %s in class %s.", methodTarget, className);
|
||||||
|
logger.warning(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return methodNode;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package customskinloader.forge.loader;
|
||||||
|
|
||||||
|
import customskinloader.forge.TransformerManager;
|
||||||
|
import customskinloader.forge.transformer.FakeInterfacesTransformer;
|
||||||
|
import customskinloader.forge.transformer.PlayerTabTransformer;
|
||||||
|
import customskinloader.forge.transformer.SkinManagerTransformer;
|
||||||
|
import customskinloader.forge.transformer.SpectatorMenuTransformer;
|
||||||
|
import customskinloader.forge.transformer.TileEntitySkullTransformer;
|
||||||
|
import net.minecraft.launchwrapper.IClassTransformer;
|
||||||
|
import net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
|
||||||
|
import org.objectweb.asm.ClassReader;
|
||||||
|
import org.objectweb.asm.ClassWriter;
|
||||||
|
import org.objectweb.asm.Opcodes;
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
|
||||||
|
//LaunchWrapper for 1.13-
|
||||||
|
public class LaunchWrapper implements IClassTransformer {
|
||||||
|
private static final TransformerManager.IClassTransformer[] CLASS_TRANSFORMERS = {
|
||||||
|
new FakeInterfacesTransformer.MinecraftTransformer(),
|
||||||
|
new FakeInterfacesTransformer.AbstractTextureTransfomer(),
|
||||||
|
new FakeInterfacesTransformer.TextureTransformer(),
|
||||||
|
new FakeInterfacesTransformer.TextureManagerTransformer()
|
||||||
|
};
|
||||||
|
private static final TransformerManager.IMethodTransformer[] TRANFORMERS = {
|
||||||
|
new SkinManagerTransformer.InitTransformer(),
|
||||||
|
new SkinManagerTransformer.LoadSkinTransformer(),
|
||||||
|
new SkinManagerTransformer.LoadProfileTexturesTransformer(),
|
||||||
|
new SkinManagerTransformer.LoadSkinFromCacheTransformer(),
|
||||||
|
new PlayerTabTransformer.ScoreObjectiveTransformer(),
|
||||||
|
new SpectatorMenuTransformer.PlayerMenuObjectTransformer(),
|
||||||
|
new TileEntitySkullTransformer.UpdateGameProfileTransformer()
|
||||||
|
};
|
||||||
|
private TransformerManager transformerManager = new TransformerManager(CLASS_TRANSFORMERS, TRANFORMERS);
|
||||||
|
|
||||||
|
//From: https://github.com/RecursiveG/UniSkinMod/blob/1.9.4/src/main/java/org/devinprogress/uniskinmod/coremod/BaseAsmTransformer.java#L83-L114
|
||||||
|
public byte[] transform(String obfClassName, String className, byte[] bytes) {
|
||||||
|
if (!transformerManager.classMap.containsKey(className) && !transformerManager.map.containsKey(className)) return bytes;//Check if should be transformed
|
||||||
|
|
||||||
|
//Parse bytes to ClassNode
|
||||||
|
ClassNode cn = new ClassNode();
|
||||||
|
if (bytes != null && bytes.length > 0) {
|
||||||
|
ClassReader cr = new ClassReader(bytes);
|
||||||
|
cr.accept(cn, 0);
|
||||||
|
} else {
|
||||||
|
cn.name = className.replace(".", "/");
|
||||||
|
cn.version = Opcodes.V1_8;
|
||||||
|
cn.superName = "java/lang/Object";
|
||||||
|
}
|
||||||
|
|
||||||
|
//Transform ClassNode
|
||||||
|
transformerManager.transform(cn);
|
||||||
|
for (MethodNode mn : cn.methods) {
|
||||||
|
String methodName = FMLDeobfuscatingRemapper.INSTANCE.mapMethodName(obfClassName, mn.name, mn.desc);
|
||||||
|
String methodDesc = FMLDeobfuscatingRemapper.INSTANCE.mapMethodDesc(mn.desc);
|
||||||
|
transformerManager.transform(cn, mn, className, methodName, methodDesc);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Parse Class Node to bytes
|
||||||
|
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
||||||
|
cn.accept(cw);
|
||||||
|
return cw.toByteArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package customskinloader.forge.loader;
|
||||||
|
|
||||||
|
import customskinloader.forge.TransformerManager;
|
||||||
|
import customskinloader.forge.transformer.FakeSkinManagerTransformer;
|
||||||
|
import customskinloader.forge.transformer.PlayerTabTransformer;
|
||||||
|
import customskinloader.forge.transformer.SkinManagerTransformer;
|
||||||
|
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ModLauncher for 1.13+
|
||||||
|
* @deprecated Use JavaScript Instead
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public class ModLauncher {
|
||||||
|
|
||||||
|
private static final TransformerManager.IMethodTransformer[] TRANFORMERS = {
|
||||||
|
new SkinManagerTransformer.InitTransformer(),
|
||||||
|
new SkinManagerTransformer.LoadSkinTransformer(),
|
||||||
|
new SkinManagerTransformer.LoadProfileTexturesTransformer(),
|
||||||
|
new SkinManagerTransformer.LoadSkinFromCacheTransformer(),
|
||||||
|
new PlayerTabTransformer.ScoreObjectiveTransformer(),
|
||||||
|
new FakeSkinManagerTransformer.InitTransformer()
|
||||||
|
};
|
||||||
|
private TransformerManager transformerManager = new TransformerManager(TRANFORMERS);
|
||||||
|
|
||||||
|
public ClassNode transform(ClassNode input) {
|
||||||
|
for (MethodNode mn : input.methods) {
|
||||||
|
transformerManager.transform(input, mn, input.name, mn.name, mn.desc);
|
||||||
|
}
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Singleton
|
||||||
|
private volatile static ModLauncher INSTANCE = null;
|
||||||
|
|
||||||
|
public static ModLauncher instance() {
|
||||||
|
if (INSTANCE == null) {
|
||||||
|
synchronized (ModLauncher.class) {
|
||||||
|
if (INSTANCE == null) {
|
||||||
|
INSTANCE = new ModLauncher();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package customskinloader.forge.transformer;
|
||||||
|
|
||||||
|
import customskinloader.forge.TransformerManager;
|
||||||
|
import org.objectweb.asm.Opcodes;
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
|
||||||
|
public class FakeInterfacesTransformer {
|
||||||
|
@TransformerManager.TransformTarget(
|
||||||
|
className = "net.minecraft.client.Minecraft"
|
||||||
|
)
|
||||||
|
public static class MinecraftTransformer implements TransformerManager.IClassTransformer {
|
||||||
|
@Override
|
||||||
|
public void transform(ClassNode cn) {
|
||||||
|
cn.interfaces.add("customskinloader/fake/itf/IFakeMinecraft");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@TransformerManager.TransformTarget(
|
||||||
|
className = "net.minecraft.client.renderer.texture.AbstractTexture"
|
||||||
|
)
|
||||||
|
public static class AbstractTextureTransfomer implements TransformerManager.IClassTransformer {
|
||||||
|
@Override
|
||||||
|
public void transform(ClassNode cn) {
|
||||||
|
cn.interfaces.add("net/minecraft/client/renderer/texture/Texture");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@TransformerManager.TransformTarget(
|
||||||
|
className = "net.minecraft.client.renderer.texture.Texture"
|
||||||
|
)
|
||||||
|
public static class TextureTransformer implements TransformerManager.IClassTransformer {
|
||||||
|
@Override
|
||||||
|
public void transform(ClassNode cn) {
|
||||||
|
if (cn.access == 0) {
|
||||||
|
cn.access = Opcodes.ACC_PUBLIC | Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@TransformerManager.TransformTarget(
|
||||||
|
className = "net.minecraft.client.renderer.texture.TextureManager"
|
||||||
|
)
|
||||||
|
public static class TextureManagerTransformer implements TransformerManager.IClassTransformer {
|
||||||
|
@Override
|
||||||
|
public void transform(ClassNode cn) {
|
||||||
|
cn.interfaces.add("customskinloader/fake/itf/IFakeTextureManager_1");
|
||||||
|
cn.interfaces.add("customskinloader/fake/itf/IFakeTextureManager_2");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package customskinloader.forge.transformer;
|
||||||
|
|
||||||
|
import customskinloader.forge.TransformerManager;
|
||||||
|
import customskinloader.forge.TransformerManager.IMethodTransformer;
|
||||||
|
import customskinloader.forge.TransformerManager.TransformTarget;
|
||||||
|
|
||||||
|
import org.objectweb.asm.tree.*;
|
||||||
|
|
||||||
|
import java.util.ListIterator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transformer of FakeSkinManager for 1.13+
|
||||||
|
* @deprecated Use JavaScript Instead
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public class FakeSkinManagerTransformer {
|
||||||
|
private final static String TARGET_CLASS = "net/minecraft/client/renderer/ThreadDownloadImageData";
|
||||||
|
private final static String NEW_TARGET_CLASS = "net/minecraft/client/renderer/texture/ThreadDownloadImageData";
|
||||||
|
private final static String CALLBACK_CLASS = "net/minecraft/client/resources/SkinManager$SkinAvailableCallback";
|
||||||
|
|
||||||
|
|
||||||
|
@TransformTarget(className = "customskinloader.fake.FakeSkinManager",
|
||||||
|
methodNames = {"<init>"},
|
||||||
|
desc = "(Lnet/minecraft/client/renderer/texture/TextureManager;Ljava/io/File;Lcom/mojang/authlib/minecraft/MinecraftSessionService;)V")
|
||||||
|
public static class InitTransformer implements IMethodTransformer {
|
||||||
|
@Override
|
||||||
|
public void transform(ClassNode cn, MethodNode mn) {
|
||||||
|
TransformerManager.logger.info("1.13 detected, FakeSkinManager will be transformed.");
|
||||||
|
//ClassNameRemapper.remapClassName(cn, TARGET_CLASS, NEW_TARGET_CLASS);
|
||||||
|
//MethodNameRemapper.remapMethodName(cn, CALLBACK_CLASS, "func_180521_a", "onSkinTextureAvailable");
|
||||||
|
|
||||||
|
InsnList il = mn.instructions;
|
||||||
|
ListIterator<AbstractInsnNode> li = il.iterator();
|
||||||
|
while (li.hasNext()) {
|
||||||
|
AbstractInsnNode ain = li.next();
|
||||||
|
if (ain instanceof MethodInsnNode) {
|
||||||
|
MethodInsnNode min = (MethodInsnNode) ain;
|
||||||
|
|
||||||
|
if (min.owner.equals(TARGET_CLASS)) {
|
||||||
|
min.owner = NEW_TARGET_CLASS;
|
||||||
|
//il.set(min, new MethodInsnNode(min.getOpcode(), NEW_TARGET_CLASS, min.name, min.desc, false));
|
||||||
|
}
|
||||||
|
if (min.owner.equals(CALLBACK_CLASS) && min.name.equals("func_180521_a")) {
|
||||||
|
min.name = "onSkinTextureAvailable";
|
||||||
|
//il.set(min, new MethodInsnNode(min.getOpcode(), min.owner, "onSkinTextureAvailable", min.desc, false));
|
||||||
|
}
|
||||||
|
} else if (ain instanceof TypeInsnNode) {
|
||||||
|
TypeInsnNode tin = (TypeInsnNode) ain;
|
||||||
|
|
||||||
|
if (tin.desc.equals(TARGET_CLASS)) {
|
||||||
|
tin.desc = NEW_TARGET_CLASS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package customskinloader.forge.transformer;
|
||||||
|
|
||||||
|
import java.util.ListIterator;
|
||||||
|
|
||||||
|
import org.objectweb.asm.Opcodes;
|
||||||
|
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
import org.objectweb.asm.tree.InsnNode;
|
||||||
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
import org.objectweb.asm.tree.VarInsnNode;
|
||||||
|
|
||||||
|
import customskinloader.forge.TransformerManager.IMethodTransformer;
|
||||||
|
import customskinloader.forge.TransformerManager.TransformTarget;
|
||||||
|
|
||||||
|
public class PlayerTabTransformer {
|
||||||
|
@TransformTarget(className = "net.minecraft.client.gui.GuiPlayerTabOverlay",
|
||||||
|
methodNames = {"func_175249_a", "renderPlayerlist"},
|
||||||
|
desc = "(ILnet/minecraft/scoreboard/Scoreboard;Lnet/minecraft/scoreboard/ScoreObjective;)V")
|
||||||
|
public static class ScoreObjectiveTransformer implements IMethodTransformer {
|
||||||
|
//From: http://git.oschina.net/AsteriskTeam/TabIconHackForge/blob/master/src/main/java/kengxxiao/tabiconhack/coremod/TabIconHackForgeClassTransformer.java#L30-L43
|
||||||
|
@Override
|
||||||
|
public void transform(ClassNode cn, MethodNode mn) {
|
||||||
|
ListIterator<AbstractInsnNode> iterator = mn.instructions.iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
AbstractInsnNode node = iterator.next();
|
||||||
|
if (node instanceof VarInsnNode) {
|
||||||
|
VarInsnNode varNode = (VarInsnNode) node;
|
||||||
|
if (varNode.getOpcode() == Opcodes.ISTORE && varNode.var == 11) {
|
||||||
|
mn.instructions.set(varNode.getPrevious(), new InsnNode(Opcodes.ICONST_1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
package customskinloader.forge.transformer;
|
||||||
|
|
||||||
|
import org.objectweb.asm.Opcodes;
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
import org.objectweb.asm.tree.FieldInsnNode;
|
||||||
|
import org.objectweb.asm.tree.FieldNode;
|
||||||
|
import org.objectweb.asm.tree.InsnNode;
|
||||||
|
import org.objectweb.asm.tree.MethodInsnNode;
|
||||||
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
import org.objectweb.asm.tree.TypeInsnNode;
|
||||||
|
import org.objectweb.asm.tree.VarInsnNode;
|
||||||
|
|
||||||
|
import customskinloader.forge.TransformerManager.IMethodTransformer;
|
||||||
|
import customskinloader.forge.TransformerManager.TransformTarget;
|
||||||
|
|
||||||
|
public class SkinManagerTransformer {
|
||||||
|
@TransformTarget(className="net.minecraft.client.resources.SkinManager",
|
||||||
|
methodNames={"<init>"},
|
||||||
|
desc="(Lnet/minecraft/client/renderer/texture/TextureManager;Ljava/io/File;Lcom/mojang/authlib/minecraft/MinecraftSessionService;)V")
|
||||||
|
public static class InitTransformer implements IMethodTransformer{
|
||||||
|
@Override
|
||||||
|
public void transform(ClassNode cn,MethodNode mn) {
|
||||||
|
boolean hasField = false;
|
||||||
|
for (FieldNode fn : cn.fields) {
|
||||||
|
if (fn.name.equals("fakeManager")) {
|
||||||
|
hasField = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!hasField) {
|
||||||
|
cn.fields.add(new FieldNode(Opcodes.ACC_PRIVATE, "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;", null, null));
|
||||||
|
}
|
||||||
|
mn.instructions.clear();
|
||||||
|
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,0));
|
||||||
|
mn.instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL,"java/lang/Object","<init>","()V", false));
|
||||||
|
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,0));
|
||||||
|
mn.instructions.add(new TypeInsnNode(Opcodes.NEW, "customskinloader/fake/FakeSkinManager"));
|
||||||
|
mn.instructions.add(new InsnNode(Opcodes.DUP));
|
||||||
|
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,1));
|
||||||
|
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,2));
|
||||||
|
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,3));
|
||||||
|
mn.instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL,"customskinloader/fake/FakeSkinManager","<init>",
|
||||||
|
"(Lnet/minecraft/client/renderer/texture/TextureManager;Ljava/io/File;Lcom/mojang/authlib/minecraft/MinecraftSessionService;)V", false));
|
||||||
|
mn.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, "net/minecraft/client/resources/SkinManager", "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;"));
|
||||||
|
mn.instructions.add(new InsnNode(Opcodes.RETURN));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@TransformTarget(className="net.minecraft.client.resources.SkinManager",
|
||||||
|
methodNames={"func_152789_a","loadSkin"},
|
||||||
|
desc="(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)Lnet/minecraft/util/ResourceLocation;")
|
||||||
|
public static class LoadSkinTransformer implements IMethodTransformer{
|
||||||
|
@Override
|
||||||
|
public void transform(ClassNode cn,MethodNode mn) {
|
||||||
|
mn.instructions.clear();
|
||||||
|
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,0));
|
||||||
|
mn.instructions.add(new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/resources/SkinManager", "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;"));
|
||||||
|
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,1));
|
||||||
|
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,2));
|
||||||
|
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,3));
|
||||||
|
mn.instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL,"customskinloader/fake/FakeSkinManager","loadSkin",
|
||||||
|
"(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)Lnet/minecraft/util/ResourceLocation;", false));
|
||||||
|
mn.instructions.add(new InsnNode(Opcodes.ARETURN));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@TransformTarget(className="net.minecraft.client.resources.SkinManager",
|
||||||
|
methodNames={"func_152790_a","loadProfileTextures"},
|
||||||
|
desc="(Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V")
|
||||||
|
public static class LoadProfileTexturesTransformer implements IMethodTransformer{
|
||||||
|
@Override
|
||||||
|
public void transform(ClassNode cn,MethodNode mn) {
|
||||||
|
mn.instructions.clear();
|
||||||
|
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,0));
|
||||||
|
mn.instructions.add(new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/resources/SkinManager", "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;"));
|
||||||
|
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,1));
|
||||||
|
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,2));
|
||||||
|
mn.instructions.add(new VarInsnNode(Opcodes.ILOAD,3));
|
||||||
|
mn.instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL,"customskinloader/fake/FakeSkinManager","loadProfileTextures",
|
||||||
|
"(Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V", false));
|
||||||
|
mn.instructions.add(new InsnNode(Opcodes.RETURN));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@TransformTarget(className="net.minecraft.client.resources.SkinManager",
|
||||||
|
methodNames={"func_152788_a","loadSkinFromCache"},
|
||||||
|
desc="(Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;")
|
||||||
|
public static class LoadSkinFromCacheTransformer implements IMethodTransformer{
|
||||||
|
@Override
|
||||||
|
public void transform(ClassNode cn,MethodNode mn) {
|
||||||
|
mn.instructions.clear();
|
||||||
|
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,0));
|
||||||
|
mn.instructions.add(new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/resources/SkinManager", "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;"));
|
||||||
|
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,1));
|
||||||
|
mn.instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL,"customskinloader/fake/FakeSkinManager","loadSkinFromCache",
|
||||||
|
"(Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;", false));
|
||||||
|
mn.instructions.add(new InsnNode(Opcodes.ARETURN));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package customskinloader.forge.transformer;
|
||||||
|
|
||||||
|
import java.util.ListIterator;
|
||||||
|
|
||||||
|
import customskinloader.forge.TransformerManager;
|
||||||
|
import net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
|
||||||
|
import org.objectweb.asm.Opcodes;
|
||||||
|
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
import org.objectweb.asm.tree.InsnList;
|
||||||
|
import org.objectweb.asm.tree.MethodInsnNode;
|
||||||
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
|
||||||
|
import customskinloader.forge.TransformerManager.IMethodTransformer;
|
||||||
|
import customskinloader.forge.TransformerManager.TransformTarget;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transformer of Spectator Menu for 1.13-
|
||||||
|
*/
|
||||||
|
public class SpectatorMenuTransformer {
|
||||||
|
@TransformTarget(className = "net.minecraft.client.gui.spectator.PlayerMenuObject",
|
||||||
|
methodNames = {"<init>"},
|
||||||
|
desc = "(Lcom/mojang/authlib/GameProfile;)V")
|
||||||
|
public static class PlayerMenuObjectTransformer implements IMethodTransformer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void transform(ClassNode cn, MethodNode mn) {
|
||||||
|
InsnList il = mn.instructions;
|
||||||
|
ListIterator<AbstractInsnNode> li = il.iterator();
|
||||||
|
|
||||||
|
boolean flag = false;
|
||||||
|
while (li.hasNext()) {
|
||||||
|
AbstractInsnNode ain = li.next();
|
||||||
|
if (ain.getOpcode() != Opcodes.INVOKESTATIC)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!flag) {
|
||||||
|
//First InvokeStatic
|
||||||
|
il.set(ain, new MethodInsnNode(Opcodes.INVOKESTATIC,
|
||||||
|
"customskinloader/fake/FakeClientPlayer",
|
||||||
|
"getLocationSkin",
|
||||||
|
"(Ljava/lang/String;)Lnet/minecraft/util/ResourceLocation;", false));
|
||||||
|
flag = true;
|
||||||
|
} else {
|
||||||
|
//Second InvokeStatic
|
||||||
|
il.set(ain, new MethodInsnNode(Opcodes.INVOKESTATIC,
|
||||||
|
"customskinloader/fake/FakeClientPlayer",
|
||||||
|
"getDownloadImageSkin",
|
||||||
|
"(Lnet/minecraft/util/ResourceLocation;Ljava/lang/String;)Lnet/minecraft/client/renderer/ThreadDownloadImageData;", false));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package customskinloader.forge.transformer;
|
||||||
|
|
||||||
|
import customskinloader.forge.TransformerManager;
|
||||||
|
import org.objectweb.asm.Opcodes;
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
import org.objectweb.asm.tree.InsnList;
|
||||||
|
import org.objectweb.asm.tree.InsnNode;
|
||||||
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
import org.objectweb.asm.tree.VarInsnNode;
|
||||||
|
|
||||||
|
public class TileEntitySkullTransformer {
|
||||||
|
@TransformerManager.TransformTarget(
|
||||||
|
className = "net.minecraft.tileentity.TileEntitySkull",
|
||||||
|
methodNames = {"updateGameProfile", "func_174884_b"},
|
||||||
|
desc = "(Lcom/mojang/authlib/GameProfile;)Lcom/mojang/authlib/GameProfile;"
|
||||||
|
)
|
||||||
|
public static class UpdateGameProfileTransformer implements TransformerManager.IMethodTransformer {
|
||||||
|
@Override
|
||||||
|
public void transform(ClassNode cn, MethodNode mn) {
|
||||||
|
InsnList il = new InsnList();
|
||||||
|
il.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
||||||
|
il.add(new InsnNode(Opcodes.ARETURN));
|
||||||
|
mn.instructions.insert(il);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package net.minecraft.client.resources;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||||
|
import customskinloader.fake.FakeSkinManager;
|
||||||
|
import net.minecraft.client.renderer.texture.TextureManager;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
public class SkinManager {
|
||||||
|
private FakeSkinManager fakeManager;
|
||||||
|
|
||||||
|
public SkinManager(TextureManager textureManagerInstance, File skinCacheDirectory, MinecraftSessionService sessionService) {
|
||||||
|
this.fakeManager = new FakeSkinManager(textureManagerInstance, skinCacheDirectory, sessionService);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResourceLocation loadSkin(MinecraftProfileTexture profileTexture, MinecraftProfileTexture.Type textureType) {
|
||||||
|
return this.loadSkin(profileTexture, textureType, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResourceLocation loadSkin(MinecraftProfileTexture profileTexture, MinecraftProfileTexture.Type textureType, SkinManager.SkinAvailableCallback skinAvailableCallback) {
|
||||||
|
return this.fakeManager.loadSkin(profileTexture, textureType, skinAvailableCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
// For 1.14+
|
||||||
|
public ResourceLocation func_152789_a(MinecraftProfileTexture profileTexture, MinecraftProfileTexture.Type textureType, SkinManager.ISkinAvailableCallback skinAvailableCallback) {
|
||||||
|
return this.loadSkin(profileTexture, textureType, skinAvailableCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadProfileTextures(GameProfile profile, SkinManager.SkinAvailableCallback skinAvailableCallback, boolean requireSecure) {
|
||||||
|
this.fakeManager.loadProfileTextures(profile, skinAvailableCallback, requireSecure);
|
||||||
|
}
|
||||||
|
|
||||||
|
// For 1.14+
|
||||||
|
public void func_152790_a(GameProfile profile, SkinManager.ISkinAvailableCallback skinAvailableCallback, boolean requireSecure) {
|
||||||
|
this.loadProfileTextures(profile, skinAvailableCallback, requireSecure);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadSkinFromCache(GameProfile profile) {
|
||||||
|
return this.fakeManager.loadSkinFromCache(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface SkinAvailableCallback {
|
||||||
|
default void skinAvailable(MinecraftProfileTexture.Type typeIn, ResourceLocation location, MinecraftProfileTexture profileTexture) {
|
||||||
|
this.onSkinTextureAvailable(typeIn, location, profileTexture);
|
||||||
|
}
|
||||||
|
|
||||||
|
default void onSkinTextureAvailable(MinecraftProfileTexture.Type typeIn, ResourceLocation location, MinecraftProfileTexture profileTexture) {
|
||||||
|
this.skinAvailable(typeIn, location, profileTexture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface ISkinAvailableCallback extends SkinAvailableCallback {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package net.minecraftforge.fml.common;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
//https://github.com/MinecraftForge/MinecraftForge/blob/1.13.x/src/main/java/net/minecraftforge/fml/common/Mod.java
|
||||||
|
//https://github.com/MinecraftForge/MinecraftForge/blob/1.12.x/src/main/java/net/minecraftforge/fml/common/Mod.java
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.TYPE)
|
||||||
|
public @interface Mod {
|
||||||
|
String value();
|
||||||
|
|
||||||
|
String modid();
|
||||||
|
|
||||||
|
String name() default "";
|
||||||
|
|
||||||
|
String version() default "";
|
||||||
|
|
||||||
|
boolean clientSideOnly() default false;
|
||||||
|
|
||||||
|
String acceptedMinecraftVersions() default "";
|
||||||
|
|
||||||
|
String acceptableRemoteVersions() default "";
|
||||||
|
|
||||||
|
String certificateFingerprint() default "";
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@interface EventHandler {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,3 +1,92 @@
|
|||||||
MCCustomSkinLoader
|
# CustomSkinLoader
|
||||||
==================
|
## What's this?
|
||||||
|
Custom Skin Loader mod for Minecraft.
|
||||||
|
It's a mod which can load skins and capes from any online source or from your local.
|
||||||
|
|
||||||
|
## Download
|
||||||
|
Build Server : [CircleCI](https://circleci.com/gh/xfl03/MCCustomSkinLoader) & ~~[Infinity Studio CI](https://ci.infstudio.net/job/CustomSkinLoader/)~~
|
||||||
|
Release Page : [MCBBS](http://www.mcbbs.net/thread-269807-1-1.html) & [GitHub](https://github.com/xfl03/MCCustomSkinLoader/releases) & [CurseForge](https://minecraft.curseforge.com/projects/customskinloader)
|
||||||
|
|
||||||
|
## Feature
|
||||||
|
### Support Plenty of Skin Load API and Customizable Skin Load List
|
||||||
|
Supported Skin Load APIs:
|
||||||
|
- [Mojang API](http://wiki.vg/Mojang_API)
|
||||||
|
- [CustomSkinAPI](https://github.com/xfl03/CustomSkinLoaderAPI/tree/master/CustomSkinAPI)
|
||||||
|
- CustomSkinAPIPlus (Test Only)
|
||||||
|
- [UniSkinAPI](https://github.com/RecursiveG/UniSkinServer/tree/master/doc)
|
||||||
|
- [ElyByAPI](http://docs.ely.by/api.html)
|
||||||
|
- Legacy
|
||||||
|
|
||||||
|
You can use this feature to customize your skin load list so as to load your skins from any skin server you want.
|
||||||
|
If you are the owner of skin server, you can use CustomSkinLoader to load skins from your server if one of the APIs has been actualized by your server.
|
||||||
|
|
||||||
|
### HD Skins Support
|
||||||
|
Even though you don't have OptiFine and MCPatcher, CustomSkinLoader can still load and render HD skins.
|
||||||
|
You can easily to get a better view of skins.
|
||||||
|
|
||||||
|
### Skull Support
|
||||||
|
Fixed skull loading bug, you can apply any skin to your skull now.
|
||||||
|
Dynamic skull supported.
|
||||||
|
|
||||||
|
### Profile Cache
|
||||||
|
- Decrease the frenquency of using the network.
|
||||||
|
- Meanwhile, you can still load profiles when network is unavailable.(*)
|
||||||
|
|
||||||
|
*Only when it is opened in configratulation.
|
||||||
|
|
||||||
|
### Local Skin
|
||||||
|
Load skins without a skin server.
|
||||||
|
Furthermore, by using this function you can preview your skins in game and even change the default skin and model.
|
||||||
|
You can load local skins by using any API (excluding MojangAPI).
|
||||||
|
*While using default configratulation, just put your skins into `.minecraft/CustomSkinLoader/LocalSkin/(skin|cape)s/{USERNAME}.png`.
|
||||||
|
|
||||||
|
### Extra List
|
||||||
|
A json file generated by skin servers which supports this feature.
|
||||||
|
To add a server to your load list, users just need to put the file into `.minecraft/CustomSkinLoader/ExtraList` .
|
||||||
|
|
||||||
|
### Transparent Skin Support
|
||||||
|
The problem of incorrectly rendering textures has been fixed.
|
||||||
|
|
||||||
|
### Spectator Menu Fixed
|
||||||
|
By using this mod, you can see correct avatar of players in Spectator Menu rather than steve and alex.
|
||||||
|
|
||||||
|
## Default Load List
|
||||||
|
- [Mojang](http://www.minecraft.net/) (Mojang API)
|
||||||
|
- [LittleSkin](https://littleskin.cn/) (CustomSkinAPI)
|
||||||
|
- [Blessing Skin](http://skin.prinzeugen.net/) (CustomSkinAPI)
|
||||||
|
- [ElyBy](http://docs.ely.by/) (ElyByAPI)
|
||||||
|
- SkinMe (UniSkinAPI)
|
||||||
|
- LocalSkin (Legacy)
|
||||||
|
If you want to apply to add other skin server to default list, please go to [issue](https://github.com/JLChnToZ/MCCustomSkinLoader/issues).
|
||||||
|
|
||||||
|
## To Skin Server Owner
|
||||||
|
CustomSkinLoader is designed for loading from any server, which makes the mod complex.
|
||||||
|
It's not a good idea to refer to CustomSkinLoader's source code to develop your own skin mod.
|
||||||
|
It's recommended to use CustomSkinLoader for your server directly.
|
||||||
|
Furthermore, you can add your server to 'Default Load List'.
|
||||||
|
You can also use 'ExtraList' which makes it easier for users to add your server into load list.
|
||||||
|
|
||||||
|
## Copyright & LICENSE
|
||||||
|
### Binary File
|
||||||
|
You could not modify binary file.
|
||||||
|
Feel free to use and share this mod and unmodified file in anyway like modpack.
|
||||||
|
When using in modpack, you must put 'CustomSkinLoader' in mod list.
|
||||||
|
You could not repost this mod to any website without permission.
|
||||||
|
You could not earn money with this mod excluding modpack.
|
||||||
|
### Source Code
|
||||||
|
#### Package 'customskinloader'
|
||||||
|
Including some codes from
|
||||||
|
- [AsteriskTeam/TabIconHackForge](http://git.oschina.net/AsteriskTeam/TabIconHackForge) (GPLv3)
|
||||||
|
- [RecursiveG/UniSkinMod](https://github.com/RecursiveG/UniSkinMod) (GPLv3)
|
||||||
|
- [NekoCaffeine/Alchemy](https://github.com/NekoCaffeine/Alchemy) (GPLv3)
|
||||||
|
|
||||||
|
Copyright © 2013-2014 Jeremy Lam "JLChnToZ".
|
||||||
|
Copyright © 2014-2019 Alexander Xia "xfl03".
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
GPLv3: http://www.gnu.org/licenses/gpl.html
|
||||||
|
|
||||||
|
You should change the name of the package to avoid others' misunderstanding.
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
net/minecraft/client/gui/GuiPlayerTabOverlay bjq
|
||||||
|
net/minecraft/client/gui/spectator/PlayerMenuObject boo
|
||||||
|
net/minecraft/client/Minecraft bib
|
||||||
|
field_71412_D w
|
||||||
|
func_110432_I ()Lnet/minecraft/util/Session; K
|
||||||
|
func_110434_K ()Lnet/minecraft/client/renderer/texture/TextureManager; N
|
||||||
|
func_147104_D ()Lnet/minecraft/client/multiplayer/ServerData; C
|
||||||
|
func_152342_ad ()Lnet/minecraft/client/resources/SkinManager; Y
|
||||||
|
func_152344_a (Ljava/lang/Runnable;)Lcom/google/common/util/concurrent/ListenableFuture; a
|
||||||
|
func_152347_ac ()Lcom/mojang/authlib/minecraft/MinecraftSessionService; X
|
||||||
|
func_71410_x ()Lnet/minecraft/client/Minecraft; z
|
||||||
|
net/minecraft/client/multiplayer/ServerData bse
|
||||||
|
field_78845_b b
|
||||||
|
net/minecraft/client/renderer/IImageBuffer but
|
||||||
|
func_152634_a ()V a
|
||||||
|
func_78432_a (Ljava/awt/image/BufferedImage;)Ljava/awt/image/BufferedImage; a
|
||||||
|
net/minecraft/client/renderer/ThreadDownloadImageData cdh
|
||||||
|
net/minecraft/client/renderer/texture/DownloadingTexture cdh
|
||||||
|
net/minecraft/client/renderer/texture/ITextureObject cds
|
||||||
|
net/minecraft/client/renderer/texture/SimpleTexture cdm
|
||||||
|
net/minecraft/client/renderer/texture/Texture cdf
|
||||||
|
net/minecraft/client/renderer/texture/TextureManager cdr
|
||||||
|
func_110579_a (Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/client/renderer/texture/ITextureObject;)Z a
|
||||||
|
func_110581_b (Lnet/minecraft/util/ResourceLocation;)Lnet/minecraft/client/renderer/texture/ITextureObject; b
|
||||||
|
net/minecraft/client/renderer/texture/ThreadDownloadImageData cdh
|
||||||
|
net/minecraft/client/resources/DefaultPlayerSkin cef
|
||||||
|
func_177334_a (Ljava/util/UUID;)Lnet/minecraft/util/ResourceLocation; a
|
||||||
|
func_177335_a ()Lnet/minecraft/util/ResourceLocation; a
|
||||||
|
net/minecraft/client/resources/SkinManager cex
|
||||||
|
func_152790_a (Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V a
|
||||||
|
net/minecraft/client/resources/SkinManager$SkinAvailableCallback cex$a
|
||||||
|
func_180521_a (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/util/ResourceLocation;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)V a
|
||||||
|
net/minecraft/tileentity/TileEntitySkull awd
|
||||||
|
net/minecraft/util/ResourceLocation nf
|
||||||
|
net/minecraft/util/Session bii
|
||||||
|
func_148256_e ()Lcom/mojang/authlib/GameProfile; e
|
||||||
|
net/minecraft/util/StringUtils rp
|
||||||
|
func_76338_a (Ljava/lang/String;)Ljava/lang/String; a
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
minecraft_version=1.12.2
|
||||||
|
minecraft_full_versions=1.12.2
|
||||||
|
#forge gradle needs forge version
|
||||||
|
forge_mc_version=1.12.2
|
||||||
|
forge_version=14.23.5.2768
|
||||||
|
mappings_version=stable_39
|
||||||
|
srg_notch_map=1.12.2.tsrg
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
CL: net/minecraft/client/entity/AbstractClientPlayer bua
|
||||||
|
CL: net/minecraft/client/gui/GuiPlayerTabOverlay bjq
|
||||||
|
CL: net/minecraft/client/gui/spectator/PlayerMenuObject boo
|
||||||
|
CL: net/minecraft/client/Minecraft bib
|
||||||
|
CL: net/minecraft/client/renderer/ThreadDownloadImageData cdh
|
||||||
|
CL: net/minecraft/client/renderer/texture/TextureManager cdr
|
||||||
|
CL: net/minecraft/client/resources/SkinManager cex
|
||||||
|
CL: net/minecraft/client/resources/SkinManager$SkinAvailableCallback cex$a
|
||||||
|
CL: net/minecraft/scoreboard/ScoreObjective bhg
|
||||||
|
CL: net/minecraft/scoreboard/Scoreboard bhk
|
||||||
|
CL: net/minecraft/tileentity/TileEntitySkull awd
|
||||||
|
CL: net/minecraft/util/ResourceLocation nf
|
||||||
|
FD: net/minecraft/client/renderer/ThreadDownloadImageData/processTask cdh/field_229155_i_
|
||||||
|
MD: net/minecraft/client/entity/AbstractClientPlayer/getDownloadImageSkin (Lnet/minecraft/util/ResourceLocation;Ljava/lang/String;)Lnet/minecraft/client/renderer/ThreadDownloadImageData; bua/a (Lnf;Ljava/lang/String;)Lcdh;
|
||||||
|
MD: net/minecraft/client/entity/AbstractClientPlayer/getLocationSkin (Ljava/lang/String;)Lnet/minecraft/util/ResourceLocation; bua/e (Ljava/lang/String;)Lnf;
|
||||||
|
MD: net/minecraft/client/gui/GuiPlayerTabOverlay/renderPlayerlist (ILnet/minecraft/scoreboard/Scoreboard;Lnet/minecraft/scoreboard/ScoreObjective;)V bjq/a (ILbhk;Lbhg;)V
|
||||||
|
MD: net/minecraft/client/gui/GuiPlayerTabOverlay/renderPlayerlist (Lcom/mojang/blaze3d/matrix/MatrixStack;ILnet/minecraft/scoreboard/Scoreboard;Lnet/minecraft/scoreboard/ScoreObjective;)V bjq/func_238523_a_ (Lcom/mojang/blaze3d/matrix/MatrixStack;ILbhk;Lbhg;)V
|
||||||
|
MD: net/minecraft/client/Minecraft/isIntegratedServerRunning ()Z bib/D ()Z
|
||||||
|
MD: net/minecraft/client/renderer/ThreadDownloadImageData/loadTexture (Ljava/io/InputStream;)Lnet/minecraft/client/renderer/texture/NativeImage; cdh/func_229159_a_ (Ljava/io/InputStream;)Lnet/minecraft/client/renderer/texture/NativeImage;
|
||||||
|
MD: net/minecraft/client/renderer/ThreadDownloadImageData/processLegacySkin (Lnet/minecraft/client/renderer/texture/NativeImage;)Lnet/minecraft/client/renderer/texture/NativeImage; cdh/func_229163_c_ (Lnet/minecraft/client/renderer/texture/NativeImage;)Lnet/minecraft/client/renderer/texture/NativeImage;
|
||||||
|
MD: net/minecraft/client/resources/SkinManager/loadProfileTextures (Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V cex/a (Lcom/mojang/authlib/GameProfile;Lcex$a;Z)V
|
||||||
|
MD: net/minecraft/client/resources/SkinManager/loadSkin (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)Lnet/minecraft/util/ResourceLocation; cex/a (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lcex$a;)Lnf;
|
||||||
|
MD: net/minecraft/client/resources/SkinManager/loadSkinFromCache (Lcom/mojang/authlib/GameProfile;)Ljava/util/Map; cex/a (Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;
|
||||||
|
MD: net/minecraft/tileentity/TileEntitySkull/updateGameProfile (Lcom/mojang/authlib/GameProfile;)Lcom/mojang/authlib/GameProfile; awd/b (Lcom/mojang/authlib/GameProfile;)Lcom/mojang/authlib/GameProfile;
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"compatibilityLevel": "JAVA_8",
|
||||||
|
"package": "customskinloader.mixin",
|
||||||
|
"client": [
|
||||||
|
"MixinGuiPlayerTabOverlay",
|
||||||
|
"MixinMinecraft",
|
||||||
|
"MixinPlayerMenuObject",
|
||||||
|
"MixinSkinManager",
|
||||||
|
"MixinTextureManager",
|
||||||
|
"MixinTileEntitySkull"
|
||||||
|
],
|
||||||
|
"refmap": "mixins.customskinloader.refmap.json",
|
||||||
|
"injectors": {
|
||||||
|
"defaultRequire": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
customskinloader/fake/itf/IFakeTextureManager_1 customskinloader/fake/itf/IFakeTextureManager_1
|
||||||
|
func_229267_b_ (Lnet/minecraft/util/ResourceLocation;)Lnet/minecraft/client/renderer/texture/Texture; b
|
||||||
|
customskinloader/fake/itf/IFakeTextureManager_2 customskinloader/fake/itf/IFakeTextureManager_2
|
||||||
|
func_229263_a_ (Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/client/renderer/texture/Texture;)V a
|
||||||
|
net/minecraft/client/gui/GuiPlayerTabOverlay ddj
|
||||||
|
net/minecraft/client/gui/spectator/PlayerMenuObject djn
|
||||||
|
net/minecraft/client/Minecraft dbn
|
||||||
|
field_71412_D m
|
||||||
|
func_110432_I ()Lnet/minecraft/util/Session; E
|
||||||
|
func_110434_K ()Lnet/minecraft/client/renderer/texture/TextureManager; H
|
||||||
|
func_147104_D ()Lnet/minecraft/client/multiplayer/ServerData; z
|
||||||
|
func_152342_ad ()Lnet/minecraft/client/resources/SkinManager; S
|
||||||
|
func_152347_ac ()Lcom/mojang/authlib/minecraft/MinecraftSessionService; R
|
||||||
|
func_71410_x ()Lnet/minecraft/client/Minecraft; x
|
||||||
|
net/minecraft/client/multiplayer/ServerData dnu
|
||||||
|
field_78845_b b
|
||||||
|
net/minecraft/client/renderer/ThreadDownloadImageData dzz
|
||||||
|
net/minecraft/client/renderer/texture/DownloadingTexture dzz
|
||||||
|
net/minecraft/client/renderer/texture/NativeImage cxr
|
||||||
|
func_195699_a (IIIIIIZZ)V a
|
||||||
|
func_195700_a (III)V a
|
||||||
|
func_195702_a ()I a
|
||||||
|
func_195703_a (Lnet/minecraft/client/renderer/texture/NativeImage;)V a
|
||||||
|
func_195709_a (II)I a
|
||||||
|
func_195714_b ()I b
|
||||||
|
func_195715_a (IIIII)V a
|
||||||
|
net/minecraft/client/renderer/texture/SimpleTexture eaf
|
||||||
|
net/minecraft/client/renderer/texture/Texture dzw
|
||||||
|
net/minecraft/client/renderer/texture/TextureManager eak
|
||||||
|
net/minecraft/client/renderer/texture/ThreadDownloadImageData dzz
|
||||||
|
net/minecraft/client/resources/DefaultPlayerSkin eaq
|
||||||
|
func_177334_a (Ljava/util/UUID;)Lnet/minecraft/util/ResourceLocation; a
|
||||||
|
func_177335_a ()Lnet/minecraft/util/ResourceLocation; a
|
||||||
|
net/minecraft/client/resources/SkinManager eaz
|
||||||
|
func_152790_a (Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V a
|
||||||
|
net/minecraft/client/resources/SkinManager$SkinAvailableCallback eaz$a
|
||||||
|
func_180521_a (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/util/ResourceLocation;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)V onSkinTextureAvailable
|
||||||
|
net/minecraft/tileentity/TileEntitySkull bxi
|
||||||
|
net/minecraft/util/ResourceLocation sm
|
||||||
|
net/minecraft/util/Session dbz
|
||||||
|
func_148256_e ()Lcom/mojang/authlib/GameProfile; e
|
||||||
|
net/minecraft/util/StringUtils aby
|
||||||
|
func_76338_a (Ljava/lang/String;)Ljava/lang/String; a
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
minecraft_version=1.15.2
|
||||||
|
minecraft_full_versions=1.15.2
|
||||||
|
#forge gradle needs forge version
|
||||||
|
forge_mc_version=1.12.2
|
||||||
|
forge_version=14.23.5.2768
|
||||||
|
mappings_version=stable_39
|
||||||
|
srg_notch_map=1.15.2.tsrg
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
CL: com/mojang/blaze3d/matrix/MatrixStack cyl
|
||||||
|
CL: net/minecraft/client/entity/AbstractClientPlayer dpy
|
||||||
|
CL: net/minecraft/client/gui/GuiPlayerTabOverlay ddj
|
||||||
|
CL: net/minecraft/client/Minecraft dbn
|
||||||
|
CL: net/minecraft/client/renderer/ThreadDownloadImageData dzz
|
||||||
|
CL: net/minecraft/client/renderer/texture/NativeImage cxr
|
||||||
|
CL: net/minecraft/client/renderer/texture/TextureManager eak
|
||||||
|
CL: net/minecraft/client/resources/SkinManager eaz
|
||||||
|
CL: net/minecraft/client/resources/SkinManager$SkinAvailableCallback eaz$a
|
||||||
|
CL: net/minecraft/scoreboard/ScoreObjective cwi
|
||||||
|
CL: net/minecraft/scoreboard/Scoreboard cwl
|
||||||
|
CL: net/minecraft/tileentity/TileEntitySkull bxi
|
||||||
|
CL: net/minecraft/util/ResourceLocation sm
|
||||||
|
FD: net/minecraft/client/renderer/ThreadDownloadImageData/processTask dzz/i
|
||||||
|
MD: net/minecraft/client/entity/AbstractClientPlayer/getDownloadImageSkin (Lnet/minecraft/util/ResourceLocation;Ljava/lang/String;)Lnet/minecraft/client/renderer/ThreadDownloadImageData; dpy/a (Lsm;Ljava/lang/String;)Ldzz;
|
||||||
|
MD: net/minecraft/client/entity/AbstractClientPlayer/getLocationSkin (Ljava/lang/String;)Lnet/minecraft/util/ResourceLocation; dpy/d (Ljava/lang/String;)Lsm;
|
||||||
|
MD: net/minecraft/client/gui/GuiPlayerTabOverlay/renderPlayerlist (ILnet/minecraft/scoreboard/Scoreboard;Lnet/minecraft/scoreboard/ScoreObjective;)V ddj/a (ILcwl;Lcwi;)V
|
||||||
|
MD: net/minecraft/client/gui/GuiPlayerTabOverlay/renderPlayerlist (Lcom/mojang/blaze3d/matrix/MatrixStack;ILnet/minecraft/scoreboard/Scoreboard;Lnet/minecraft/scoreboard/ScoreObjective;)V ddj/func_238523_a_ (Lcyl;ILbhk;Lbhg;)V
|
||||||
|
MD: net/minecraft/client/Minecraft/isIntegratedServerRunning ()Z dbn/A ()Z
|
||||||
|
MD: net/minecraft/client/renderer/ThreadDownloadImageData/loadTexture (Ljava/io/InputStream;)Lnet/minecraft/client/renderer/texture/NativeImage; dzz/a (Ljava/io/InputStream;)Lcxr;
|
||||||
|
MD: net/minecraft/client/renderer/ThreadDownloadImageData/processLegacySkin (Lnet/minecraft/client/renderer/texture/NativeImage;)Lnet/minecraft/client/renderer/texture/NativeImage; dzz/c (Lcxr;)Lcxr;
|
||||||
|
MD: net/minecraft/client/resources/SkinManager/loadProfileTextures (Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V eaz/a (Lcom/mojang/authlib/GameProfile;Leaz$a;Z)V
|
||||||
|
MD: net/minecraft/client/resources/SkinManager/loadSkin (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)Lnet/minecraft/util/ResourceLocation; eaz/a (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Leaz$a;)Lsm;
|
||||||
|
MD: net/minecraft/client/resources/SkinManager/loadSkinFromCache (Lcom/mojang/authlib/GameProfile;)Ljava/util/Map; eaz/a (Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;
|
||||||
|
MD: net/minecraft/tileentity/TileEntitySkull/updateGameProfile (Lcom/mojang/authlib/GameProfile;)Lcom/mojang/authlib/GameProfile; bxi/b (Lcom/mojang/authlib/GameProfile;)Lcom/mojang/authlib/GameProfile;
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"compatibilityLevel": "JAVA_8",
|
||||||
|
"package": "customskinloader.mixin",
|
||||||
|
"client": [
|
||||||
|
"MixinGuiPlayerTabOverlay",
|
||||||
|
"MixinMinecraft",
|
||||||
|
"MixinSkinManager",
|
||||||
|
"MixinTextureManager",
|
||||||
|
"MixinThreadDownloadImageData",
|
||||||
|
"MixinTileEntitySkull"
|
||||||
|
],
|
||||||
|
"refmap": "mixins.customskinloader.refmap.json",
|
||||||
|
"injectors": {
|
||||||
|
"defaultRequire": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
customskinloader/fake/itf/IFakeTextureManager_1 customskinloader/fake/itf/IFakeTextureManager_1
|
||||||
|
func_229267_b_ (Lnet/minecraft/util/ResourceLocation;)Lnet/minecraft/client/renderer/texture/Texture; b
|
||||||
|
customskinloader/fake/itf/IFakeTextureManager_2 customskinloader/fake/itf/IFakeTextureManager_2
|
||||||
|
func_229263_a_ (Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/client/renderer/texture/Texture;)V a
|
||||||
|
net/minecraft/client/gui/GuiPlayerTabOverlay dnw
|
||||||
|
net/minecraft/client/gui/spectator/PlayerMenuObject duh
|
||||||
|
net/minecraft/client/Minecraft dlx
|
||||||
|
field_71412_D n
|
||||||
|
func_110432_I ()Lnet/minecraft/util/Session; I
|
||||||
|
func_110434_K ()Lnet/minecraft/client/renderer/texture/TextureManager; L
|
||||||
|
func_147104_D ()Lnet/minecraft/client/multiplayer/ServerData; D
|
||||||
|
func_152342_ad ()Lnet/minecraft/client/resources/SkinManager; Y
|
||||||
|
func_152347_ac ()Lcom/mojang/authlib/minecraft/MinecraftSessionService; X
|
||||||
|
func_71410_x ()Lnet/minecraft/client/Minecraft; B
|
||||||
|
net/minecraft/client/multiplayer/ServerData dys
|
||||||
|
field_78845_b b
|
||||||
|
net/minecraft/client/renderer/ThreadDownloadImageData elm
|
||||||
|
net/minecraft/client/renderer/texture/DownloadingTexture elm
|
||||||
|
net/minecraft/client/renderer/texture/NativeImage dgs
|
||||||
|
func_195699_a (IIIIIIZZ)V a
|
||||||
|
func_195700_a (III)V a
|
||||||
|
func_195702_a ()I a
|
||||||
|
func_195703_a (Lnet/minecraft/client/renderer/texture/NativeImage;)V a
|
||||||
|
func_195709_a (II)I a
|
||||||
|
func_195714_b ()I b
|
||||||
|
func_195715_a (IIIII)V a
|
||||||
|
net/minecraft/client/renderer/texture/SimpleTexture elr
|
||||||
|
net/minecraft/client/renderer/texture/Texture elj
|
||||||
|
net/minecraft/client/renderer/texture/TextureManager elw
|
||||||
|
net/minecraft/client/renderer/texture/ThreadDownloadImageData elm
|
||||||
|
net/minecraft/client/resources/DefaultPlayerSkin emc
|
||||||
|
func_177334_a (Ljava/util/UUID;)Lnet/minecraft/util/ResourceLocation; a
|
||||||
|
func_177335_a ()Lnet/minecraft/util/ResourceLocation; a
|
||||||
|
net/minecraft/client/resources/SkinManager emm
|
||||||
|
func_152790_a (Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V a
|
||||||
|
net/minecraft/client/resources/SkinManager$SkinAvailableCallback emm$a
|
||||||
|
func_180521_a (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/util/ResourceLocation;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)V onSkinTextureAvailable
|
||||||
|
net/minecraft/tileentity/TileEntitySkull cei
|
||||||
|
net/minecraft/util/ResourceLocation uh
|
||||||
|
net/minecraft/util/Session dml
|
||||||
|
func_148256_e ()Lcom/mojang/authlib/GameProfile; e
|
||||||
|
net/minecraft/util/StringUtils aei
|
||||||
|
func_76338_a (Ljava/lang/String;)Ljava/lang/String; a
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
minecraft_version=1.16.1
|
||||||
|
minecraft_full_versions=1.16.1
|
||||||
|
#forge gradle needs forge version
|
||||||
|
forge_mc_version=1.12.2
|
||||||
|
forge_version=14.23.5.2768
|
||||||
|
mappings_version=stable_39
|
||||||
|
srg_notch_map=1.16.1.tsrg
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
CL: com/mojang/blaze3d/matrix/MatrixStack dhl
|
||||||
|
CL: net/minecraft/client/entity/AbstractClientPlayer ebc
|
||||||
|
CL: net/minecraft/client/gui/GuiPlayerTabOverlay dnw
|
||||||
|
CL: net/minecraft/client/Minecraft dlx
|
||||||
|
CL: net/minecraft/client/renderer/ThreadDownloadImageData elm
|
||||||
|
CL: net/minecraft/client/renderer/texture/NativeImage dgs
|
||||||
|
CL: net/minecraft/client/renderer/texture/TextureManager elw
|
||||||
|
CL: net/minecraft/client/resources/SkinManager emm
|
||||||
|
CL: net/minecraft/client/resources/SkinManager$SkinAvailableCallback emm$a
|
||||||
|
CL: net/minecraft/scoreboard/ScoreObjective dfj
|
||||||
|
CL: net/minecraft/scoreboard/Scoreboard dfm
|
||||||
|
CL: net/minecraft/tileentity/TileEntitySkull cei
|
||||||
|
CL: net/minecraft/util/ResourceLocation uh
|
||||||
|
FD: net/minecraft/client/renderer/ThreadDownloadImageData/processTask elm/i
|
||||||
|
MD: net/minecraft/client/entity/AbstractClientPlayer/getDownloadImageSkin (Lnet/minecraft/util/ResourceLocation;Ljava/lang/String;)Lnet/minecraft/client/renderer/ThreadDownloadImageData; ebc/a (Luh;Ljava/lang/String;)Lelm;
|
||||||
|
MD: net/minecraft/client/entity/AbstractClientPlayer/getLocationSkin (Ljava/lang/String;)Lnet/minecraft/util/ResourceLocation; ebc/d (Ljava/lang/String;)Luh;
|
||||||
|
MD: net/minecraft/client/gui/GuiPlayerTabOverlay/renderPlayerlist (ILnet/minecraft/scoreboard/Scoreboard;Lnet/minecraft/scoreboard/ScoreObjective;)V dnw/func_175249_a (ILcwl;Lcwi;)V
|
||||||
|
MD: net/minecraft/client/gui/GuiPlayerTabOverlay/renderPlayerlist (Lcom/mojang/blaze3d/matrix/MatrixStack;ILnet/minecraft/scoreboard/Scoreboard;Lnet/minecraft/scoreboard/ScoreObjective;)V dnw/a (Ldhl;ILdfm;Ldfj;)V
|
||||||
|
MD: net/minecraft/client/Minecraft/isIntegratedServerRunning ()Z dlx/E ()Z
|
||||||
|
MD: net/minecraft/client/renderer/ThreadDownloadImageData/loadTexture (Ljava/io/InputStream;)Lnet/minecraft/client/renderer/texture/NativeImage; elm/a (Ljava/io/InputStream;)Ldgs;
|
||||||
|
MD: net/minecraft/client/renderer/ThreadDownloadImageData/processLegacySkin (Lnet/minecraft/client/renderer/texture/NativeImage;)Lnet/minecraft/client/renderer/texture/NativeImage; elm/c (Ldgs;)Ldgs;
|
||||||
|
MD: net/minecraft/client/resources/SkinManager/loadProfileTextures (Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V emm/a (Lcom/mojang/authlib/GameProfile;Lemm$a;Z)V
|
||||||
|
MD: net/minecraft/client/resources/SkinManager/loadSkin (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)Lnet/minecraft/util/ResourceLocation; emm/a (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lemm$a;)Luh;
|
||||||
|
MD: net/minecraft/client/resources/SkinManager/loadSkinFromCache (Lcom/mojang/authlib/GameProfile;)Ljava/util/Map; emm/a (Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;
|
||||||
|
MD: net/minecraft/tileentity/TileEntitySkull/updateGameProfile (Lcom/mojang/authlib/GameProfile;)Lcom/mojang/authlib/GameProfile; cei/b (Lcom/mojang/authlib/GameProfile;)Lcom/mojang/authlib/GameProfile;
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"compatibilityLevel": "JAVA_8",
|
||||||
|
"package": "customskinloader.mixin",
|
||||||
|
"client": [
|
||||||
|
"MixinGuiPlayerTabOverlay",
|
||||||
|
"MixinMinecraft",
|
||||||
|
"MixinSkinManager",
|
||||||
|
"MixinTextureManager",
|
||||||
|
"MixinThreadDownloadImageData",
|
||||||
|
"MixinTileEntitySkull"
|
||||||
|
],
|
||||||
|
"refmap": "mixins.customskinloader.refmap.json",
|
||||||
|
"injectors": {
|
||||||
|
"defaultRequire": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
net/minecraft/client/gui/GuiPlayerTabOverlay awh
|
||||||
|
net/minecraft/client/gui/spectator/PlayerMenuObject bad
|
||||||
|
net/minecraft/client/Minecraft ave
|
||||||
|
field_71412_D v
|
||||||
|
func_110432_I ()Lnet/minecraft/util/Session; L
|
||||||
|
func_110434_K ()Lnet/minecraft/client/renderer/texture/TextureManager; P
|
||||||
|
func_147104_D ()Lnet/minecraft/client/multiplayer/ServerData; D
|
||||||
|
func_152342_ad ()Lnet/minecraft/client/resources/SkinManager; ab
|
||||||
|
func_152344_a (Ljava/lang/Runnable;)Lcom/google/common/util/concurrent/ListenableFuture; a
|
||||||
|
func_152347_ac ()Lcom/mojang/authlib/minecraft/MinecraftSessionService; aa
|
||||||
|
func_71410_x ()Lnet/minecraft/client/Minecraft; A
|
||||||
|
net/minecraft/client/multiplayer/ServerData bde
|
||||||
|
field_78845_b b
|
||||||
|
net/minecraft/client/renderer/IImageBuffer bfm
|
||||||
|
func_152634_a ()V a
|
||||||
|
func_78432_a (Ljava/awt/image/BufferedImage;)Ljava/awt/image/BufferedImage; a
|
||||||
|
net/minecraft/client/renderer/ThreadDownloadImageData bma
|
||||||
|
net/minecraft/client/renderer/texture/DownloadingTexture bma
|
||||||
|
net/minecraft/client/renderer/texture/ITextureObject bmk
|
||||||
|
net/minecraft/client/renderer/texture/SimpleTexture bme
|
||||||
|
net/minecraft/client/renderer/texture/Texture bly
|
||||||
|
net/minecraft/client/renderer/texture/TextureManager bmj
|
||||||
|
func_110579_a (Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/client/renderer/texture/ITextureObject;)Z a
|
||||||
|
func_110581_b (Lnet/minecraft/util/ResourceLocation;)Lnet/minecraft/client/renderer/texture/ITextureObject; b
|
||||||
|
net/minecraft/client/renderer/texture/ThreadDownloadImageData bma
|
||||||
|
net/minecraft/client/resources/DefaultPlayerSkin bmz
|
||||||
|
func_177334_a (Ljava/util/UUID;)Lnet/minecraft/util/ResourceLocation; a
|
||||||
|
func_177335_a ()Lnet/minecraft/util/ResourceLocation; a
|
||||||
|
net/minecraft/client/resources/SkinManager bnp
|
||||||
|
func_152790_a (Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V a
|
||||||
|
net/minecraft/client/resources/SkinManager$SkinAvailableCallback bnp$a
|
||||||
|
func_180521_a (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/util/ResourceLocation;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)V a
|
||||||
|
net/minecraft/tileentity/TileEntitySkull alo
|
||||||
|
net/minecraft/util/ResourceLocation jy
|
||||||
|
net/minecraft/util/Session avm
|
||||||
|
func_148256_e ()Lcom/mojang/authlib/GameProfile; e
|
||||||
|
net/minecraft/util/StringUtils nx
|
||||||
|
func_76338_a (Ljava/lang/String;)Ljava/lang/String; a
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
minecraft_version=1.8.9
|
||||||
|
minecraft_full_versions=1.8.9
|
||||||
|
#forge gradle needs forge version
|
||||||
|
forge_mc_version=1.12.2
|
||||||
|
forge_version=14.23.5.2768
|
||||||
|
mappings_version=stable_39
|
||||||
|
srg_notch_map=1.8.9.tsrg
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
CL: net/minecraft/client/entity/AbstractClientPlayer bet
|
||||||
|
CL: net/minecraft/client/gui/GuiPlayerTabOverlay awh
|
||||||
|
CL: net/minecraft/client/gui/spectator/PlayerMenuObject bad
|
||||||
|
CL: net/minecraft/client/Minecraft ave
|
||||||
|
CL: net/minecraft/client/renderer/ThreadDownloadImageData bma
|
||||||
|
CL: net/minecraft/client/renderer/texture/TextureManager bmj
|
||||||
|
CL: net/minecraft/client/resources/SkinManager bnp
|
||||||
|
CL: net/minecraft/client/resources/SkinManager$SkinAvailableCallback bnp$a
|
||||||
|
CL: net/minecraft/scoreboard/ScoreObjective auk
|
||||||
|
CL: net/minecraft/scoreboard/Scoreboard auo
|
||||||
|
CL: net/minecraft/tileentity/TileEntitySkull alo
|
||||||
|
CL: net/minecraft/util/ResourceLocation jy
|
||||||
|
FD: net/minecraft/client/renderer/ThreadDownloadImageData/processTask bma/field_229155_i_
|
||||||
|
MD: net/minecraft/client/entity/AbstractClientPlayer/getDownloadImageSkin (Lnet/minecraft/util/ResourceLocation;Ljava/lang/String;)Lnet/minecraft/client/renderer/ThreadDownloadImageData; bet/a (Ljy;Ljava/lang/String;)Lbma;
|
||||||
|
MD: net/minecraft/client/entity/AbstractClientPlayer/getLocationSkin (Ljava/lang/String;)Lnet/minecraft/util/ResourceLocation; bet/c (Ljava/lang/String;)Ljy;
|
||||||
|
MD: net/minecraft/client/gui/GuiPlayerTabOverlay/renderPlayerlist (ILnet/minecraft/scoreboard/Scoreboard;Lnet/minecraft/scoreboard/ScoreObjective;)V awh/a (ILauo;Lauk;)V
|
||||||
|
MD: net/minecraft/client/gui/GuiPlayerTabOverlay/renderPlayerlist (Lcom/mojang/blaze3d/matrix/MatrixStack;ILnet/minecraft/scoreboard/Scoreboard;Lnet/minecraft/scoreboard/ScoreObjective;)V awh/func_238523_a_ (Lcom/mojang/blaze3d/matrix/MatrixStack;ILbhk;Lbhg;)V
|
||||||
|
MD: net/minecraft/client/Minecraft/isIntegratedServerRunning ()Z ave/E ()Z
|
||||||
|
MD: net/minecraft/client/renderer/ThreadDownloadImageData/loadTexture (Ljava/io/InputStream;)Lnet/minecraft/client/renderer/texture/NativeImage; bma/func_229159_a_ (Ljava/io/InputStream;)Lnet/minecraft/client/renderer/texture/NativeImage;
|
||||||
|
MD: net/minecraft/client/renderer/ThreadDownloadImageData/processLegacySkin (Lnet/minecraft/client/renderer/texture/NativeImage;)Lnet/minecraft/client/renderer/texture/NativeImage; bma/func_229163_c_ (Lnet/minecraft/client/renderer/texture/NativeImage;)Lnet/minecraft/client/renderer/texture/NativeImage;
|
||||||
|
MD: net/minecraft/client/resources/SkinManager/loadProfileTextures (Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V bnp/a (Lcom/mojang/authlib/GameProfile;Lbnp$a;Z)V
|
||||||
|
MD: net/minecraft/client/resources/SkinManager/loadSkin (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)Lnet/minecraft/util/ResourceLocation; bnp/a (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lbnp$a;)Ljy;
|
||||||
|
MD: net/minecraft/client/resources/SkinManager/loadSkinFromCache (Lcom/mojang/authlib/GameProfile;)Ljava/util/Map; bnp/a (Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;
|
||||||
|
MD: net/minecraft/tileentity/TileEntitySkull/updateGameProfile (Lcom/mojang/authlib/GameProfile;)Lcom/mojang/authlib/GameProfile; alo/b (Lcom/mojang/authlib/GameProfile;)Lcom/mojang/authlib/GameProfile;
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
{
|
||||||
|
"arguments": {
|
||||||
|
"game": [
|
||||||
|
"--tweakClass",
|
||||||
|
"customskinloader.tweaker.Tweaker"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"id": "${mcVersion}-CSL-${modShortFullVersion}",
|
||||||
|
"inheritsFrom": "${mcVersion}",
|
||||||
|
"libraries": [
|
||||||
|
{
|
||||||
|
"downloads": {
|
||||||
|
"artifact": {
|
||||||
|
"path": "customskinloader/CustomSkinLoader_${mcVersion}/${modFullVersion}/CustomSkinLoader_${mcVersion}-${modFullVersion}.jar",
|
||||||
|
"sha1": "{SHA1}",
|
||||||
|
"size": -1,
|
||||||
|
"url": "https://csl.littleservice.cn/libraries/customskinloader/CustomSkinLoader_${mcVersion}/${modFullVersion}/CustomSkinLoader_${mcVersion}-${modFullVersion}.jar"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": "customskinloader:CustomSkinLoader_${mcVersion}:${modFullVersion}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"downloads": {
|
||||||
|
"artifact": {
|
||||||
|
"path": "net/minecraft/launchwrapper/1.12/launchwrapper-1.12.jar",
|
||||||
|
"sha1": "111e7bea9c968cdb3d06ef4632bf7ff0824d0f36",
|
||||||
|
"size": 32999,
|
||||||
|
"url": "https://libraries.minecraft.net/net/minecraft/launchwrapper/1.12/launchwrapper-1.12.jar"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": "net.minecraft:launchwrapper:1.12"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"downloads": {
|
||||||
|
"artifact": {
|
||||||
|
"path": "org/spongepowered/mixin/0.7.11-SNAPSHOT/mixin-0.7.11-20180703.121122-1.jar",
|
||||||
|
"sha1": "7a670207bdb97db418118ad1e9bb42424ff3776d",
|
||||||
|
"size": 1017668,
|
||||||
|
"url": "https://repo.spongepowered.org/maven/org/spongepowered/mixin/0.7.11-SNAPSHOT/mixin-0.7.11-20180703.121122-1.jar"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": "org.spongepowered:mixin:0.7.11-SNAPSHOT"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"mainClass": "net.minecraft.launchwrapper.Launch",
|
||||||
|
"releaseTime": "${releaseTime}",
|
||||||
|
"time": "${releaseTime}",
|
||||||
|
"type": "release"
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"compatibilityLevel": "JAVA_8",
|
||||||
|
"package": "customskinloader.mixin",
|
||||||
|
"client": [
|
||||||
|
"MixinGuiPlayerTabOverlay",
|
||||||
|
"MixinMinecraft",
|
||||||
|
"MixinPlayerMenuObject",
|
||||||
|
"MixinSkinManager",
|
||||||
|
"MixinTextureManager",
|
||||||
|
"MixinTileEntitySkull"
|
||||||
|
],
|
||||||
|
"refmap": "mixins.customskinloader.refmap.json",
|
||||||
|
"injectors": {
|
||||||
|
"defaultRequire": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
{
|
||||||
|
"arguments": {
|
||||||
|
"game": [
|
||||||
|
"--tweakClass",
|
||||||
|
"customskinloader.tweaker.Tweaker"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"id": "${mcVersion}-CSL-${modShortFullVersion}",
|
||||||
|
"inheritsFrom": "${mcVersion}",
|
||||||
|
"libraries": [
|
||||||
|
{
|
||||||
|
"downloads": {
|
||||||
|
"artifact": {
|
||||||
|
"path": "customskinloader/CustomSkinLoader_${mcVersion}/${modFullVersion}/CustomSkinLoader_${mcVersion}-${modFullVersion}.jar",
|
||||||
|
"sha1": "{SHA1}",
|
||||||
|
"size": -1,
|
||||||
|
"url": "https://csl.littleservice.cn/libraries/customskinloader/CustomSkinLoader_${mcVersion}/${modFullVersion}/CustomSkinLoader_${mcVersion}-${modFullVersion}.jar"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": "customskinloader:CustomSkinLoader_${mcVersion}:${modFullVersion}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"downloads": {
|
||||||
|
"artifact": {
|
||||||
|
"path": "customskinloader/launchwrapper/2.1.4/launchwrapper-2.1.4.jar",
|
||||||
|
"sha1": "32145fe60ea650e44636ab093ada31648e0de781",
|
||||||
|
"size": 16603,
|
||||||
|
"url": "https://csl.littleservice.cn/libraries/customskinloader/launchwrapper/2.1.4/launchwrapper-2.1.4.jar"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": "customskinloader:launchwrapper:2.1.4"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"downloads": {
|
||||||
|
"artifact": {
|
||||||
|
"path": "javax/annotation/javax.annotation-api/1.3.2/javax.annotation-api-1.3.2.jar",
|
||||||
|
"sha1": "934c04d3cfef185a8008e7bf34331b79730a9d43",
|
||||||
|
"size": 26586,
|
||||||
|
"url": "https://repo1.maven.org/maven2/javax/annotation/javax.annotation-api/1.3.2/javax.annotation-api-1.3.2.jar"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": "javax.annotation:javax.annotation-api:1.3.2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"downloads": {
|
||||||
|
"artifact": {
|
||||||
|
"path": "org/ow2/asm/asm/8.0.1/asm-8.0.1.jar",
|
||||||
|
"sha1": "3f5199523fb95304b44563f5d56d9f5a07270669",
|
||||||
|
"size": 121772,
|
||||||
|
"url": "https://repo1.maven.org/maven2/org/ow2/asm/asm/8.0.1/asm-8.0.1.jar"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": "org.ow2.asm:asm:8.0.1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"downloads": {
|
||||||
|
"artifact": {
|
||||||
|
"path": "org/ow2/asm/asm-analysis/8.0.1/asm-analysis-8.0.1.jar",
|
||||||
|
"sha1": "6c2c7b3006b3a54dd63467a020263c0756fd5e80",
|
||||||
|
"size": 33438,
|
||||||
|
"url": "https://repo1.maven.org/maven2/org/ow2/asm/asm-analysis/8.0.1/asm-analysis-8.0.1.jar"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": "org.ow2.asm:asm-analysis:8.0.1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"downloads": {
|
||||||
|
"artifact": {
|
||||||
|
"path": "org/ow2/asm/asm-commons/8.0.1/asm-commons-8.0.1.jar",
|
||||||
|
"sha1": "019c7ba355f0737815205518e332a8dc08b417c6",
|
||||||
|
"size": 71563,
|
||||||
|
"url": "https://repo1.maven.org/maven2/org/ow2/asm/asm-commons/8.0.1/asm-commons-8.0.1.jar"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": "org.ow2.asm:asm-commons:8.0.1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"downloads": {
|
||||||
|
"artifact": {
|
||||||
|
"path": "org/ow2/asm/asm-tree/8.0.1/asm-tree-8.0.1.jar",
|
||||||
|
"sha1": "dfcad5abbcff36f8bdad5647fe6f4972e958ad59",
|
||||||
|
"size": 52628,
|
||||||
|
"url": "https://repo1.maven.org/maven2/org/ow2/asm/asm-tree/8.0.1/asm-tree-8.0.1.jar"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": "org.ow2.asm:asm-tree:8.0.1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"downloads": {
|
||||||
|
"artifact": {
|
||||||
|
"path": "org/ow2/asm/asm-util/8.0.1/asm-util-8.0.1.jar",
|
||||||
|
"sha1": "a8f978fbad00c565210bebedb28e5d6f73327134",
|
||||||
|
"size": 84795,
|
||||||
|
"url": "https://repo1.maven.org/maven2/org/ow2/asm/asm-util/8.0.1/asm-util-8.0.1.jar"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": "org.ow2.asm:asm-util:8.0.1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"downloads": {
|
||||||
|
"artifact": {
|
||||||
|
"path": "org/spongepowered/mixin/0.8.1-SNAPSHOT/mixin-0.8.1-20200124.185151-1.jar",
|
||||||
|
"sha1": "c7c000c209a33783cf80f7105032b8d89e1f65d2",
|
||||||
|
"size": 934746,
|
||||||
|
"url": "https://repo.spongepowered.org/maven/org/spongepowered/mixin/0.8.1-SNAPSHOT/mixin-0.8.1-20200124.185151-1.jar"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": "org.spongepowered:mixin:0.8.1-SNAPSHOT"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"mainClass": "net.minecraft.launchwrapper.Launch",
|
||||||
|
"releaseTime": "${releaseTime}",
|
||||||
|
"time": "${releaseTime}",
|
||||||
|
"type": "release"
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package customskinloader.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.GuiPlayerTabOverlay;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
|
@Mixin(GuiPlayerTabOverlay.class)
|
||||||
|
@SuppressWarnings("target")
|
||||||
|
public abstract class MixinGuiPlayerTabOverlay {
|
||||||
|
@Redirect(
|
||||||
|
method = {
|
||||||
|
"Lnet/minecraft/client/gui/GuiPlayerTabOverlay;renderPlayerlist(ILnet/minecraft/scoreboard/Scoreboard;Lnet/minecraft/scoreboard/ScoreObjective;)V",
|
||||||
|
"Lnet/minecraft/client/gui/GuiPlayerTabOverlay;renderPlayerlist(Lcom/mojang/blaze3d/matrix/MatrixStack;ILnet/minecraft/scoreboard/Scoreboard;Lnet/minecraft/scoreboard/ScoreObjective;)V"
|
||||||
|
},
|
||||||
|
at = @At(
|
||||||
|
value = "INVOKE",
|
||||||
|
target = "Lnet/minecraft/client/Minecraft;isIntegratedServerRunning()Z"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
private boolean redirect_renderPlayerlist(Minecraft mc) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package customskinloader.mixin;
|
||||||
|
|
||||||
|
import customskinloader.fake.itf.IFakeMinecraft;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
|
||||||
|
@Mixin(Minecraft.class)
|
||||||
|
public abstract class MixinMinecraft implements IFakeMinecraft {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package customskinloader.mixin;
|
||||||
|
|
||||||
|
import customskinloader.fake.FakeClientPlayer;
|
||||||
|
import net.minecraft.client.gui.spectator.PlayerMenuObject;
|
||||||
|
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
|
@Mixin(PlayerMenuObject.class)
|
||||||
|
public abstract class MixinPlayerMenuObject {
|
||||||
|
@Redirect(
|
||||||
|
method = "Lnet/minecraft/client/gui/spectator/PlayerMenuObject;<init>(Lcom/mojang/authlib/GameProfile;)V",
|
||||||
|
at = @At(
|
||||||
|
value = "INVOKE",
|
||||||
|
target = "Lnet/minecraft/client/entity/AbstractClientPlayer;getLocationSkin(Ljava/lang/String;)Lnet/minecraft/util/ResourceLocation;"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
private ResourceLocation redirect_init(String username) {
|
||||||
|
return FakeClientPlayer.getLocationSkin(username);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(
|
||||||
|
method = "Lnet/minecraft/client/gui/spectator/PlayerMenuObject;<init>(Lcom/mojang/authlib/GameProfile;)V",
|
||||||
|
at = @At(
|
||||||
|
value = "INVOKE",
|
||||||
|
target = "Lnet/minecraft/client/entity/AbstractClientPlayer;getDownloadImageSkin(Lnet/minecraft/util/ResourceLocation;Ljava/lang/String;)Lnet/minecraft/client/renderer/ThreadDownloadImageData;"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
private ThreadDownloadImageData redirect_init(ResourceLocation resourceLocationIn, String username) {
|
||||||
|
return FakeClientPlayer.getDownloadImageSkin(resourceLocationIn, username);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package customskinloader.mixin;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||||
|
import customskinloader.fake.FakeSkinManager;
|
||||||
|
import net.minecraft.client.renderer.texture.TextureManager;
|
||||||
|
import net.minecraft.client.resources.SkinManager;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
@Mixin(SkinManager.class)
|
||||||
|
public abstract class MixinSkinManager {
|
||||||
|
private FakeSkinManager fakeManager;
|
||||||
|
|
||||||
|
@Inject(
|
||||||
|
method = "Lnet/minecraft/client/resources/SkinManager;<init>(Lnet/minecraft/client/renderer/texture/TextureManager;Ljava/io/File;Lcom/mojang/authlib/minecraft/MinecraftSessionService;)V",
|
||||||
|
at = @At("RETURN")
|
||||||
|
)
|
||||||
|
private void inject_init(TextureManager textureManagerInstance, File skinCacheDirectory, MinecraftSessionService sessionService, CallbackInfo callbackInfo) {
|
||||||
|
this.fakeManager = new FakeSkinManager(textureManagerInstance, skinCacheDirectory, sessionService);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(
|
||||||
|
method = "Lnet/minecraft/client/resources/SkinManager;loadSkin(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)Lnet/minecraft/util/ResourceLocation;",
|
||||||
|
at = @At("HEAD"),
|
||||||
|
cancellable = true
|
||||||
|
)
|
||||||
|
private void inject_loadSkin(MinecraftProfileTexture profileTexture, MinecraftProfileTexture.Type textureType, SkinManager.SkinAvailableCallback skinAvailableCallback, CallbackInfoReturnable<ResourceLocation> callbackInfoReturnable) {
|
||||||
|
callbackInfoReturnable.setReturnValue(this.fakeManager.loadSkin(profileTexture, textureType, skinAvailableCallback));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(
|
||||||
|
method = "Lnet/minecraft/client/resources/SkinManager;loadProfileTextures(Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V",
|
||||||
|
at = @At("HEAD"),
|
||||||
|
cancellable = true
|
||||||
|
)
|
||||||
|
private void inject_loadProfileTextures(GameProfile profile, SkinManager.SkinAvailableCallback skinAvailableCallback, boolean requireSecure, CallbackInfo callbackInfo) {
|
||||||
|
this.fakeManager.loadProfileTextures(profile, skinAvailableCallback, requireSecure);
|
||||||
|
callbackInfo.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(
|
||||||
|
method = "Lnet/minecraft/client/resources/SkinManager;loadSkinFromCache(Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;",
|
||||||
|
at = @At("HEAD"),
|
||||||
|
cancellable = true
|
||||||
|
)
|
||||||
|
private void inject_loadSkinFromCache(GameProfile profile, CallbackInfoReturnable<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>> callbackInfoReturnable) {
|
||||||
|
callbackInfoReturnable.setReturnValue(this.fakeManager.loadSkinFromCache(profile));
|
||||||
|
}
|
||||||
|
}
|
||||||
Loaded 100 of 110 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user