Support 1.21.9. (#347)

This commit is contained in:
ZekerZhayard authored and GitHub committed 2025-10-07 08:31:05 +09:00
1 parent 1fbe258365
commit 1f3d19ac6e
60 files changed
+635 -722

No files matched your search

@@ -1,38 +1,46 @@
package customskinloader.fake.texture;
import java.nio.file.Path;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;
import customskinloader.fake.FakeCapeBuffer;
import customskinloader.fake.FakeSkinBuffer;
import customskinloader.fake.FakeSkinManager;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.NativeImage;
import net.minecraft.client.renderer.texture.SimpleTexture;
import net.minecraft.client.renderer.texture.SkinTextureDownloader;
import net.minecraft.client.renderer.texture.TextureContents;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.util.ResourceLocation;
// 24w46a+
public class FakeThreadDownloadImageData extends SimpleTexture {
private final Path cacheFile;
private final String imageUrl;
private final boolean legacySkin;
private final Runnable processTask;
private FakeCapeBuffer buffer;
private FakeNativeImage image;
public static Object createTexture(Object location, Object cacheFile, Object imageUrl, Object legacySkin, Object processTask) {
return new FakeThreadDownloadImageData((ResourceLocation) location, (Path) cacheFile, (String) imageUrl, (boolean) legacySkin, (Runnable) processTask);
public static Function<NativeImage, CompletableFuture<?>> createTexture(Function<NativeImage, CompletableFuture<?>> function, ResourceLocation location, boolean bl) {
return bl ? _image -> {
if (location instanceof FakeResourceLocation && _image instanceof FakeNativeImage.Extended) {
FakeSkinManager.BaseBuffer.judgeType(((FakeResourceLocation) location).getTexture(), () -> FakeSkinBuffer.judgeType0(((FakeNativeImage.Extended) _image).getFakeImage()));
}
return function.apply(_image);
} : _image -> function.apply(_image).thenApply(_location -> {
Minecraft.getMinecraft().getTextureManager().registerAndLoad(location, new FakeThreadDownloadImageData(location, _image));
return _location;
});
}
public FakeThreadDownloadImageData(ResourceLocation location, Path cacheFile, String imageUrl, boolean legacySkin, Runnable processTask) {
public FakeThreadDownloadImageData(ResourceLocation location, NativeImage image) {
super(location);
this.cacheFile = cacheFile;
this.imageUrl = imageUrl;
this.legacySkin = legacySkin;
this.processTask = processTask;
this.buffer = new FakeCapeBuffer();
this.image = new FakeNativeImage(image);
}
@Override
public TextureContents loadContents(IResourceManager resourceManager) {
NativeImage image = FakeSkinBuffer.processLegacySkin(SkinTextureDownloader.lambda$downloadAndRegisterSkin$0(this.cacheFile, this.imageUrl, this.legacySkin), this.processTask, i -> SkinTextureDownloader.processLegacySkin(i, this.imageUrl));
this.processTask.run();
return new TextureContents(image, null);
this.image = (FakeNativeImage) this.buffer.parseUserSkin(this.image);
FakeNativeImage local = (FakeNativeImage) this.image.createImage(this.image.getWidth(), this.image.getHeight());
local.copyImageData(this.image);
return new TextureContents(local.getImage(), null);
}
}