4
4
import java .io .File ;
5
5
import java .nio .file .Path ;
6
6
import java .util .Map ;
7
+ import java .util .concurrent .CompletableFuture ;
8
+ import java .util .concurrent .Executor ;
7
9
import java .util .function .Supplier ;
8
10
9
11
import com .google .common .cache .CacheLoader ;
17
19
import com .mojang .authlib .properties .Property ;
18
20
import customskinloader .CustomSkinLoader ;
19
21
import customskinloader .fake .itf .FakeInterfaceManager ;
22
+ import customskinloader .fake .texture .FakeThreadDownloadImageData ;
20
23
import customskinloader .loader .MojangAPILoader ;
21
24
import customskinloader .profile .ModelManager0 ;
22
25
import customskinloader .profile .UserProfile ;
25
28
import net .minecraft .client .Minecraft ;
26
29
import net .minecraft .client .renderer .IImageBuffer ;
27
30
import net .minecraft .client .renderer .texture .NativeImage ;
31
+ import net .minecraft .client .renderer .texture .TextureManager ;
32
+ import net .minecraft .client .resources .PlayerSkin$Model ;
28
33
import net .minecraft .client .resources .SkinManager ;
34
+ import net .minecraft .client .resources .SkinManager$1 ;
35
+ import net .minecraft .client .resources .SkinManager$CacheKey ;
36
+ import net .minecraft .client .resources .SkinManager$SkinAvailableCallback ;
37
+ import net .minecraft .client .resources .SkinManager$TextureCache ;
29
38
30
39
public class FakeSkinManager {
31
40
/**
32
- * Invoked from {@link SkinManager(net.minecraft.client.renderer.texture.TextureManager, File, MinecraftSessionService)}
41
+ * 1.20.1-
42
+ * Invoked from {@link SkinManager(TextureManager , File, MinecraftSessionService)}
33
43
*/
34
44
public static void setSkinCacheDir (File skinCacheDirectory ) {
35
45
HttpTextureUtil .defaultCacheDir = skinCacheDirectory ;
36
46
}
37
47
38
48
/**
39
- * Invoked from {@link SkinManager(net.minecraft.client.renderer.texture.TextureManager, Path, MinecraftSessionService, java.util.concurrent.Executor)}
49
+ * 23w31a+
50
+ * Invoked from {@link SkinManager(TextureManager, Path, MinecraftSessionService, Executor)}
40
51
*/
41
52
public static void setSkinCacheDir (Path skinCacheDirectory ) {
42
53
HttpTextureUtil .defaultCacheDir = skinCacheDirectory .toFile ();
43
54
}
44
55
45
56
private static CacheLoader <Object , ?> cacheLoader ;
46
57
/**
47
- * Invoked from {@link SkinManager(net.minecraft.client.renderer.texture.TextureManager, Path, MinecraftSessionService, java.util.concurrent.Executor)}
58
+ * 23w31a+
59
+ * Invoked from {@link SkinManager(TextureManager, Path, MinecraftSessionService, Executor)}
48
60
*/
49
61
public static CacheLoader <Object , ?> setCacheLoader (CacheLoader <Object , ?> loader ) {
50
62
return cacheLoader = loader ;
51
63
}
52
64
53
65
/**
66
+ * 23w42a+
54
67
* Invoked from {@link SkinManager#getOrLoad(GameProfile)}
55
68
*/
56
69
public static Property createProperty (Property property ) {
57
70
return property == null ? new Property (null , null ) : new Property (TextureUtil .AuthlibField .PROPERTY_NAME .get (property ), TextureUtil .AuthlibField .PROPERTY_VALUE .get (property ), TextureUtil .AuthlibField .PROPERTY_SIGNATURE .get (property ));
58
71
}
59
72
60
73
/**
74
+ * 23w31a+
61
75
* Invoked from {@link SkinManager#getOrLoad(GameProfile)}
62
76
*/
63
77
public static Object loadCache (LoadingCache <?, ?> loadingCache , Object cacheKey , GameProfile profile ) throws Exception {
64
78
return cacheLoader .load (FakeCacheKey .wrapCacheKey (cacheKey , profile ));
65
79
}
66
80
67
81
/**
68
- * Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinManager.SkinAvailableCallback)}
82
+ * 1.20.1-
83
+ * Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinManager$SkinAvailableCallback)}
84
+ *
85
+ * 23w31a+
86
+ * Invoked from {@link SkinManager$TextureCache#registerTexture(MinecraftProfileTexture)}
69
87
*/
70
88
public static Object [] createThreadDownloadImageData (ImmutableList <Object > list , MinecraftProfileTexture profileTexture , MinecraftProfileTexture .Type textureType ) {
71
89
Object [] params = list .toArray ();
72
- if (profileTexture instanceof FakeMinecraftProfileTexture && params . length > 1 ) {
90
+ if (profileTexture instanceof FakeMinecraftProfileTexture ) {
73
91
FakeMinecraftProfileTexture fakeProfileTexture = (FakeMinecraftProfileTexture ) profileTexture ;
74
- params [0 ] = fakeProfileTexture .getCacheFile ();
75
- if (params [params .length - 2 ] instanceof Boolean ) {
76
- params [params .length - 2 ] = true ;
92
+ File cacheFile = fakeProfileTexture .getCacheFile ();
93
+ if (params .length == 4 ) {
94
+ if (params [3 ] instanceof Boolean ) { // 24w46a+
95
+ FakeInterfaceManager .ResourceLocation_setTexture (params [0 ], FakeThreadDownloadImageData .createTexture (params [0 ], cacheFile .toPath (), params [2 ], false , new BaseBuffer (null , textureType , fakeProfileTexture )));
96
+ params [1 ] = cacheFile .toPath ();
97
+ params [3 ] = false ;
98
+ } else { // 19w37a-
99
+ params [0 ] = cacheFile ;
100
+ params [3 ] = new BaseBuffer ((Runnable ) params [3 ], textureType , fakeProfileTexture );
101
+ }
102
+ } else if (params .length == 5 ) { // 19w38a ~ 24w45a
103
+ params [0 ] = cacheFile ;
104
+ params [3 ] = true ;
105
+ params [4 ] = new BaseBuffer ((Runnable ) params [4 ], textureType , fakeProfileTexture );
77
106
}
78
- params [params .length - 1 ] = new BaseBuffer ((Runnable ) params [params .length - 1 ], textureType , fakeProfileTexture );
79
107
}
80
108
return params ;
81
109
}
82
110
83
111
84
112
private final static String KEY = "CustomSkinLoaderInfo" ;
85
113
/**
86
- * Invoked from {@link SkinManager#loadProfileTextures(GameProfile, SkinManager.SkinAvailableCallback, boolean)}
114
+ * 1.20.1-
115
+ * Invoked from {@link SkinManager#loadProfileTextures(GameProfile, SkinManager$SkinAvailableCallback, boolean)}
87
116
*/
88
117
public static void loadProfileTextures (Runnable runnable , GameProfile profile ) {
89
118
CustomSkinLoader .loadProfileTextures (() -> CustomSkinLoader .loadProfileLazily (profile , p -> {
@@ -95,7 +124,7 @@ public static void loadProfileTextures(Runnable runnable, GameProfile profile) {
95
124
96
125
/**
97
126
* 23w31a+
98
- * Invoked from net.minecraft.client.resources. SkinManager$1#load(net.minecraft.client.resources. SkinManager$CacheKey)
127
+ * Invoked from {@link SkinManager$1#load(SkinManager$CacheKey)}
99
128
*/
100
129
public static Object [] loadProfileTextures (ImmutableList <Object > list , Object cacheKey ) {
101
130
Object [] params = list .toArray ();
@@ -115,16 +144,18 @@ public static Object[] loadProfileTextures(ImmutableList<Object> list, Object ca
115
144
}
116
145
117
146
/**
118
- * Invoked from {@link SkinManager#lambda$loadProfileTextures$1(GameProfile, boolean, SkinAvailableCallback)}
147
+ * 1.20.1-
148
+ * Invoked from {@link SkinManager#func_210275_a(GameProfile, boolean, SkinManager$SkinAvailableCallback)}
119
149
*/
120
150
public static Map <MinecraftProfileTexture .Type , MinecraftProfileTexture > getUserProfile (MinecraftSessionService sessionService , GameProfile profile , boolean requireSecure ) {
121
151
return ModelManager0 .fromUserProfile (UserProfile .fromProperties (profile .getProperties ().values ()));
122
152
}
123
153
124
154
/**
125
- * Invoked from {@link SkinManager#lambda$null$0(Map, SkinAvailableCallback)}
155
+ * 1.20.1-
156
+ * Invoked from {@link SkinManager#func_210276_a(Map, SkinManager$SkinAvailableCallback)}
126
157
*/
127
- public static void loadElytraTexture (SkinManager skinManager , Map <MinecraftProfileTexture .Type , MinecraftProfileTexture > map , SkinManager . SkinAvailableCallback skinAvailableCallback ) {
158
+ public static void loadElytraTexture (SkinManager skinManager , Map <MinecraftProfileTexture .Type , MinecraftProfileTexture > map , SkinManager$ SkinAvailableCallback skinAvailableCallback ) {
128
159
for (int i = 2 ; i < MinecraftProfileTexture .Type .values ().length ; i ++) {
129
160
MinecraftProfileTexture .Type type = MinecraftProfileTexture .Type .values ()[i ];
130
161
if (map .containsKey (type )) {
@@ -133,6 +164,18 @@ public static void loadElytraTexture(SkinManager skinManager, Map<MinecraftProfi
133
164
}
134
165
}
135
166
167
+ /**
168
+ * 24w46a+
169
+ * Invoked from {@link SkinManager#lambda$registerTextures$1(CompletableFuture, String, CompletableFuture, CompletableFuture, PlayerSkin$Model, MinecraftProfileTextures, Void)}
170
+ */
171
+ public static PlayerSkin$Model loadSkinModel (PlayerSkin$Model model , MinecraftProfileTextures textures ) {
172
+ MinecraftProfileTexture texture = textures .skin ();
173
+ if (texture != null ) {
174
+ model = PlayerSkin$Model .byName (texture .getMetadata ("model" ));
175
+ }
176
+ return model ;
177
+ }
178
+
136
179
private final static String SKULL_KEY = "CSL$IsSkull" ;
137
180
/**
138
181
* 23w31a+
@@ -149,7 +192,7 @@ public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadSki
149
192
150
193
/**
151
194
* 23w31a ~ 23w41a
152
- * Invoked from net.minecraft.client.resources. SkinManager$1#lambda$load$0(GameProfile)
195
+ * Invoked from {@link SkinManager$1#lambda$load$0(MinecraftSessionService, GameProfile)}
153
196
*/
154
197
public static Map <MinecraftProfileTexture .Type , MinecraftProfileTexture > loadSkinFromCache (MinecraftSessionService sessionService , GameProfile profile , boolean requireSecure ) {
155
198
if (profile .getProperties ().containsKey (SKULL_KEY )) {
@@ -162,7 +205,7 @@ public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadSki
162
205
163
206
/**
164
207
* 23w42a+
165
- * Invoked from net.minecraft.client.resources. SkinManager$1#lambda$load$0(SkinManager. CacheKey, MinecraftSessionService)
208
+ * Invoked from {@link SkinManager$1#lambda$load$0(SkinManager$ CacheKey, MinecraftSessionService)}
166
209
*/
167
210
public static Object loadSkinFromCache (MinecraftSessionService sessionService , Property property ) {
168
211
return FakeCacheKey .createMinecraftProfileTextures (loadSkinFromCache (sessionService , FakeCacheKey .unwrapProperty (property ), false ));
0 commit comments