Skip to content

Commit 1cb4cf4

Browse files
authored
1.21.4 (xfl03#321)
* 1.21.4 * Disable making the source jar.
1 parent a9b2484 commit 1cb4cf4

File tree

93 files changed

+762
-181
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+762
-181
lines changed

Common/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// This subproject is only to provide dependency for other subprojects.
2+
3+
dependencies {
4+
implementation project(':Dummy')
5+
}

Common/src/main/java/customskinloader/fake/FakeCapeBuffer.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,27 @@
22

33
import java.io.IOException;
44
import java.io.InputStream;
5-
import java.util.NoSuchElementException;
65
import java.util.function.BiPredicate;
76
import java.util.function.Predicate;
87

8+
import customskinloader.CustomSkinLoader;
99
import customskinloader.fake.itf.FakeInterfaceManager;
1010
import customskinloader.fake.texture.FakeImage;
1111
import net.minecraft.client.Minecraft;
1212
import net.minecraft.util.ResourceLocation;
1313

1414
public class FakeCapeBuffer extends FakeSkinBuffer {
15-
private static final ResourceLocation TEXTURE_ELYTRA = new ResourceLocation("minecraft", "textures/entity/elytra.png");
15+
private static final ResourceLocation TEXTURE_ELYTRA_V1 = new ResourceLocation("minecraft", "textures/entity/elytra.png");
16+
private static final ResourceLocation TEXTURE_ELYTRA_V2 = new ResourceLocation("minecraft", "textures/entity/equipment/wings/elytra.png");
1617
private static int loadedGlobal = 0;
1718
private static FakeImage elytraImage;
1819

1920
private static FakeImage loadElytra(FakeImage originalImage) {
2021
loadedGlobal++;
2122
try {
22-
InputStream is = FakeInterfaceManager.IResource_getInputStream(FakeInterfaceManager.IResourceManager_getResource(FakeInterfaceManager.Minecraft_getResourceManager(Minecraft.getMinecraft()), TEXTURE_ELYTRA).get());
23+
Object resourceManager = FakeInterfaceManager.Minecraft_getResourceManager(Minecraft.getMinecraft());
24+
InputStream is = FakeInterfaceManager.IResource_getInputStream(FakeInterfaceManager.IResourceManager_getResource(resourceManager, TEXTURE_ELYTRA_V1)
25+
.orElseGet(() -> FakeInterfaceManager.IResourceManager_getResource(resourceManager, TEXTURE_ELYTRA_V2).orElse(null)));
2326
if (is != null) {
2427
FakeImage image = originalImage.createImage(is);
2528
if (image.getWidth() % 64 != 0 || image.getHeight() % 32 != 0) { // wtf?
@@ -28,7 +31,8 @@ private static FakeImage loadElytra(FakeImage originalImage) {
2831
image = resetImageFormat(image, 22, 0, 46, 22);
2932
return image;
3033
}
31-
} catch (IOException | NoSuchElementException ignored) {
34+
} catch (IOException e) {
35+
CustomSkinLoader.logger.warning(e);
3236
}
3337
return null;
3438
}

Common/src/main/java/customskinloader/fake/FakeClientPlayer.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import com.mojang.authlib.GameProfile;
88
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
99
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
10-
1110
import customskinloader.CustomSkinLoader;
1211
import customskinloader.utils.MinecraftUtil;
1312
import net.minecraft.client.renderer.ThreadDownloadImageData;
@@ -16,15 +15,15 @@
1615
import net.minecraft.client.renderer.texture.TextureManager;
1716
import net.minecraft.client.resources.DefaultPlayerSkin;
1817
import net.minecraft.client.resources.SkinManager;
19-
import net.minecraft.client.resources.SkinManager.SkinAvailableCallback;
18+
import net.minecraft.client.resources.SkinManager$SkinAvailableCallback;
2019
import net.minecraft.util.ResourceLocation;
2120
import net.minecraft.util.StringUtils;
2221

2322
public class FakeClientPlayer {
2423
/**
25-
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinManager.SkinAvailableCallback)}
24+
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinManager$SkinAvailableCallback)}
2625
*/
27-
public static ThreadDownloadImageData putCache(ThreadDownloadImageData threaddownloadimagedata, SkinManager.SkinAvailableCallback skinAvailableCallback, ResourceLocation resourcelocation) {
26+
public static ThreadDownloadImageData putCache(ThreadDownloadImageData threaddownloadimagedata, SkinManager$SkinAvailableCallback skinAvailableCallback, ResourceLocation resourcelocation) {
2827
if (skinAvailableCallback instanceof FakeClientPlayer.LegacyBuffer) {//Cache for client player
2928
textureCache.put(resourcelocation, threaddownloadimagedata);
3029
}
@@ -69,7 +68,7 @@ public static UUID getOfflineUUID(String username) {
6968

7069
public static Map<ResourceLocation, ITextureObject> textureCache = Maps.newHashMap();
7170

72-
public static class LegacyBuffer implements SkinAvailableCallback {
71+
public static class LegacyBuffer implements SkinManager$SkinAvailableCallback {
7372
ResourceLocation resourceLocationIn;
7473
boolean loaded = false;
7574

Common/src/main/java/customskinloader/fake/FakeSkinBuffer.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,39 @@
11
package customskinloader.fake;
22

33
import java.awt.image.BufferedImage;
4+
import java.io.InputStream;
45
import java.util.function.Function;
56
import java.util.function.Predicate;
67

78
import customskinloader.CustomSkinLoader;
89
import customskinloader.fake.texture.FakeBufferedImage;
910
import customskinloader.fake.texture.FakeImage;
1011
import customskinloader.fake.texture.FakeNativeImage;
12+
import customskinloader.fake.texture.FakeThreadDownloadImageData;
1113
import net.minecraft.client.renderer.IImageBuffer;
14+
import net.minecraft.client.renderer.ThreadDownloadImageData;
1215
import net.minecraft.client.renderer.texture.NativeImage;
16+
import net.minecraft.client.resources.IResourceManager;
1317

1418
public class FakeSkinBuffer implements IImageBuffer {
1519
private int ratio = 1;
1620
FakeImage image = null;
1721

18-
//parseUserSkin for 1.15+
22+
/**
23+
* 19w38a ~ 24w45a
24+
* Invoked from {@link ThreadDownloadImageData#loadTexture(InputStream)}
25+
*
26+
* 24w46a+
27+
* Invoked from {@link FakeThreadDownloadImageData#loadContents(IResourceManager)}
28+
*/
1929
public static NativeImage processLegacySkin(NativeImage image, Runnable processTask, Function<NativeImage, NativeImage> processLegacySkin) {
2030
if (processTask instanceof IImageBuffer) {
2131
return ((IImageBuffer) processTask).func_195786_a(image);
32+
} else if (processLegacySkin != null) {
33+
return processLegacySkin.apply(image);
34+
} else {
35+
return image;
2236
}
23-
return processLegacySkin.apply(image);
2437
}
2538

2639
//parseUserSkin for 1.13+

Common/src/main/java/customskinloader/fake/FakeSkinManager.java

Lines changed: 59 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import java.io.File;
55
import java.nio.file.Path;
66
import java.util.Map;
7+
import java.util.concurrent.CompletableFuture;
8+
import java.util.concurrent.Executor;
79
import java.util.function.Supplier;
810

911
import com.google.common.cache.CacheLoader;
@@ -17,6 +19,7 @@
1719
import com.mojang.authlib.properties.Property;
1820
import customskinloader.CustomSkinLoader;
1921
import customskinloader.fake.itf.FakeInterfaceManager;
22+
import customskinloader.fake.texture.FakeThreadDownloadImageData;
2023
import customskinloader.loader.MojangAPILoader;
2124
import customskinloader.profile.ModelManager0;
2225
import customskinloader.profile.UserProfile;
@@ -25,65 +28,91 @@
2528
import net.minecraft.client.Minecraft;
2629
import net.minecraft.client.renderer.IImageBuffer;
2730
import net.minecraft.client.renderer.texture.NativeImage;
31+
import net.minecraft.client.renderer.texture.TextureManager;
32+
import net.minecraft.client.resources.PlayerSkin$Model;
2833
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;
2938

3039
public class FakeSkinManager {
3140
/**
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)}
3343
*/
3444
public static void setSkinCacheDir(File skinCacheDirectory) {
3545
HttpTextureUtil.defaultCacheDir = skinCacheDirectory;
3646
}
3747

3848
/**
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)}
4051
*/
4152
public static void setSkinCacheDir(Path skinCacheDirectory) {
4253
HttpTextureUtil.defaultCacheDir = skinCacheDirectory.toFile();
4354
}
4455

4556
private static CacheLoader<Object, ?> cacheLoader;
4657
/**
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)}
4860
*/
4961
public static CacheLoader<Object, ?> setCacheLoader(CacheLoader<Object, ?> loader) {
5062
return cacheLoader = loader;
5163
}
5264

5365
/**
66+
* 23w42a+
5467
* Invoked from {@link SkinManager#getOrLoad(GameProfile)}
5568
*/
5669
public static Property createProperty(Property property) {
5770
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));
5871
}
5972

6073
/**
74+
* 23w31a+
6175
* Invoked from {@link SkinManager#getOrLoad(GameProfile)}
6276
*/
6377
public static Object loadCache(LoadingCache<?, ?> loadingCache, Object cacheKey, GameProfile profile) throws Exception {
6478
return cacheLoader.load(FakeCacheKey.wrapCacheKey(cacheKey, profile));
6579
}
6680

6781
/**
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)}
6987
*/
7088
public static Object[] createThreadDownloadImageData(ImmutableList<Object> list, MinecraftProfileTexture profileTexture, MinecraftProfileTexture.Type textureType) {
7189
Object[] params = list.toArray();
72-
if (profileTexture instanceof FakeMinecraftProfileTexture && params.length > 1) {
90+
if (profileTexture instanceof FakeMinecraftProfileTexture) {
7391
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);
77106
}
78-
params[params.length - 1] = new BaseBuffer((Runnable) params[params.length - 1], textureType, fakeProfileTexture);
79107
}
80108
return params;
81109
}
82110

83111

84112
private final static String KEY = "CustomSkinLoaderInfo";
85113
/**
86-
* Invoked from {@link SkinManager#loadProfileTextures(GameProfile, SkinManager.SkinAvailableCallback, boolean)}
114+
* 1.20.1-
115+
* Invoked from {@link SkinManager#loadProfileTextures(GameProfile, SkinManager$SkinAvailableCallback, boolean)}
87116
*/
88117
public static void loadProfileTextures(Runnable runnable, GameProfile profile) {
89118
CustomSkinLoader.loadProfileTextures(() -> CustomSkinLoader.loadProfileLazily(profile, p -> {
@@ -95,7 +124,7 @@ public static void loadProfileTextures(Runnable runnable, GameProfile profile) {
95124

96125
/**
97126
* 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)}
99128
*/
100129
public static Object[] loadProfileTextures(ImmutableList<Object> list, Object cacheKey) {
101130
Object[] params = list.toArray();
@@ -115,16 +144,18 @@ public static Object[] loadProfileTextures(ImmutableList<Object> list, Object ca
115144
}
116145

117146
/**
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)}
119149
*/
120150
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> getUserProfile(MinecraftSessionService sessionService, GameProfile profile, boolean requireSecure) {
121151
return ModelManager0.fromUserProfile(UserProfile.fromProperties(profile.getProperties().values()));
122152
}
123153

124154
/**
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)}
126157
*/
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) {
128159
for (int i = 2; i < MinecraftProfileTexture.Type.values().length; i++) {
129160
MinecraftProfileTexture.Type type = MinecraftProfileTexture.Type.values()[i];
130161
if (map.containsKey(type)) {
@@ -133,6 +164,18 @@ public static void loadElytraTexture(SkinManager skinManager, Map<MinecraftProfi
133164
}
134165
}
135166

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+
136179
private final static String SKULL_KEY = "CSL$IsSkull";
137180
/**
138181
* 23w31a+
@@ -149,7 +192,7 @@ public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadSki
149192

150193
/**
151194
* 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)}
153196
*/
154197
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadSkinFromCache(MinecraftSessionService sessionService, GameProfile profile, boolean requireSecure) {
155198
if (profile.getProperties().containsKey(SKULL_KEY)) {
@@ -162,7 +205,7 @@ public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadSki
162205

163206
/**
164207
* 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)}
166209
*/
167210
public static Object loadSkinFromCache(MinecraftSessionService sessionService, Property property) {
168211
return FakeCacheKey.createMinecraftProfileTextures(loadSkinFromCache(sessionService, FakeCacheKey.unwrapProperty(property), false));

Common/src/main/java/customskinloader/fake/itf/FakeInterfaceManager.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static InputStream IResource_getInputStream(Object resource) {
1515
return ((IFakeIResource.V2) resource).open();
1616
}
1717

18-
public static Optional<IResource> IResourceManager_getResource(Object resourceManager, ResourceLocation location) throws IOException {
18+
public static Optional<IResource> IResourceManager_getResource(Object resourceManager, ResourceLocation location) {
1919
return ((IFakeIResourceManager) resourceManager).getResource(location);
2020
}
2121

@@ -31,6 +31,14 @@ public static void NativeImage_setPixel(Object nativeImage, int x, int y, int co
3131
((IFakeNativeImage) nativeImage).setPixel(x, y, color);
3232
}
3333

34+
public static Object ResourceLocation_getTexture(Object location) {
35+
return ((IFakeResourceLocation) location).customskinloader$getTexture();
36+
}
37+
38+
public static void ResourceLocation_setTexture(Object location, Object texture) {
39+
((IFakeResourceLocation) location).customskinloader$setTexture(texture);
40+
}
41+
3442
public static GameProfile SkinManagerCacheKey_profile(Object skinManagerCacheKey) {
3543
return ((IFakeSkinManagerCacheKey) skinManagerCacheKey).profile();
3644
}
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package customskinloader.fake.itf;
22

3-
import java.io.IOException;
43
import java.util.Optional;
54

65
import net.minecraft.client.resources.IResourceManager;
@@ -9,12 +8,12 @@
98

109
public interface IFakeIResourceManager {
1110
// 1.13.2 ~ 22w13a
12-
default IResource func_199002_a(ResourceLocation location) throws IOException {
11+
default IResource func_199002_a(ResourceLocation location) {
1312
return (IResource) ((IResourceManager) this).getResource(location);
1413
}
1514

1615
// 22w14a+
17-
default Optional getResource(ResourceLocation location) throws IOException {
16+
default Optional getResource(ResourceLocation location) {
1817
return Optional.ofNullable(this.func_199002_a(location));
1918
}
2019
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package customskinloader.fake.itf;
2+
3+
public interface IFakeResourceLocation {
4+
Object customskinloader$getTexture();
5+
void customskinloader$setTexture(Object texture);
6+
}

Common/src/main/java/customskinloader/fake/itf/IFakeSkinManagerCacheKey.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
import com.mojang.authlib.properties.Property;
55

66
public interface IFakeSkinManagerCacheKey {
7-
default GameProfile profile() {
8-
return null;
9-
}
10-
7+
default GameProfile profile() { return null; }
118
Property packedTextures();
129
}

0 commit comments

Comments
 (0)