diff --git a/Common/src/main/java/customskinloader/fake/texture/FakeThreadDownloadImageData.java b/Common/src/main/java/customskinloader/fake/texture/FakeThreadDownloadImageData.java index 4c0ee8b..3f6742c 100644 --- a/Common/src/main/java/customskinloader/fake/texture/FakeThreadDownloadImageData.java +++ b/Common/src/main/java/customskinloader/fake/texture/FakeThreadDownloadImageData.java @@ -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; } } diff --git a/build.properties b/build.properties index 6238c74..ad10bb9 100644 --- a/build.properties +++ b/build.properties @@ -1,3 +1,3 @@ name=CustomSkinLoader group=customskinloader -version=14.26 +version=14.26.1