mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-20 05:19:39 +00:00
1 parent
59a515ba61
commit
73c31593f2
2 files changed
+14
-7
No files matched your search
+13
-6
@@ -25,22 +25,29 @@ public class FakeThreadDownloadImageData extends SimpleTexture {
|
||||
}
|
||||
return function.apply(_image);
|
||||
} : _image -> function.apply(_image).thenApply(_location -> {
|
||||
Minecraft.getMinecraft().getTextureManager().registerAndLoad(location, new FakeThreadDownloadImageData(location, _image));
|
||||
Minecraft.getMinecraft().getTextureManager().registerAndLoad(location, new FakeThreadDownloadImageData(location, copyImage(new FakeNativeImage(_image))));
|
||||
return _location;
|
||||
});
|
||||
}
|
||||
|
||||
public FakeThreadDownloadImageData(ResourceLocation location, NativeImage image) {
|
||||
public FakeThreadDownloadImageData(ResourceLocation location, FakeNativeImage image) {
|
||||
super(location);
|
||||
this.buffer = new FakeCapeBuffer();
|
||||
this.image = new FakeNativeImage(image);
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureContents loadContents(IResourceManager resourceManager) {
|
||||
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);
|
||||
return new TextureContents(copyImage(this.image).getImage(), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Protects cached NativeImage instances from external interference (e.g. accidental close operations). All lifecycle management is handled internally by this cache.
|
||||
*/
|
||||
private static FakeNativeImage copyImage(FakeNativeImage from) {
|
||||
FakeNativeImage local = (FakeNativeImage) from.createImage(from.getWidth(), from.getHeight());
|
||||
local.copyImageData(from);
|
||||
return local;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user