mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-18 18:29:16 +00:00
1 parent
73c31593f2
commit
73beb4c29e
34 files changed
+513
-164
No files matched your search
+27
-8
@@ -6,11 +6,13 @@ import java.util.function.Function;
|
||||
import customskinloader.fake.FakeCapeBuffer;
|
||||
import customskinloader.fake.FakeSkinBuffer;
|
||||
import customskinloader.fake.FakeSkinManager;
|
||||
import customskinloader.fake.itf.FakeInterfaceManager;
|
||||
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.TextureContents;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
// 24w46a+
|
||||
@@ -18,16 +20,27 @@ public class FakeThreadDownloadImageData extends SimpleTexture {
|
||||
private FakeCapeBuffer buffer;
|
||||
private FakeNativeImage image;
|
||||
|
||||
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 -> {
|
||||
public static Function<NativeImage, CompletableFuture<?>> createTextureV1(Function<NativeImage, CompletableFuture<?>> function, ResourceLocation location, boolean bl) {
|
||||
return createTexture(function, _image -> _location -> {
|
||||
Minecraft.getMinecraft().getTextureManager().registerAndLoad(location, new FakeThreadDownloadImageData(location, copyImage(new FakeNativeImage(_image))));
|
||||
return _location;
|
||||
});
|
||||
}, location, bl);
|
||||
}
|
||||
|
||||
public static Function<NativeImage, CompletableFuture<?>> createTextureV2(Function<NativeImage, CompletableFuture<?>> function, Identifier identifier, boolean bl) {
|
||||
return createTexture(function, _image -> _location -> {
|
||||
Minecraft.getMinecraft().getTextureManager().registerAndLoad(identifier, new FakeThreadDownloadImageData(identifier, copyImage(new FakeNativeImage(_image)), null));
|
||||
return _location;
|
||||
}, identifier, bl);
|
||||
}
|
||||
|
||||
public static Function<NativeImage, CompletableFuture<?>> createTexture(Function<NativeImage, CompletableFuture<?>> function, Function<NativeImage, Function<Object, Object>> cape, Object location, boolean bl) {
|
||||
return bl ? _image -> {
|
||||
if (FakeInterfaceManager.ResourceLocation_getTexture(location) != null && _image instanceof FakeNativeImage.Extended) {
|
||||
FakeSkinManager.BaseBuffer.judgeType(FakeInterfaceManager.ResourceLocation_getTexture(location), () -> FakeSkinBuffer.judgeType0(((FakeNativeImage.Extended) _image).getFakeImage()));
|
||||
}
|
||||
return function.apply(_image);
|
||||
} : _image -> function.apply(_image).thenApply(cape.apply(_image));
|
||||
}
|
||||
|
||||
public FakeThreadDownloadImageData(ResourceLocation location, FakeNativeImage image) {
|
||||
@@ -36,6 +49,12 @@ public class FakeThreadDownloadImageData extends SimpleTexture {
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
public FakeThreadDownloadImageData(Identifier identifier, FakeNativeImage image, Object o) {
|
||||
super(identifier);
|
||||
this.buffer = new FakeCapeBuffer();
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureContents loadContents(IResourceManager resourceManager) {
|
||||
this.image = (FakeNativeImage) this.buffer.parseUserSkin(this.image);
|
||||
|
||||
Reference in new issue
Block a user