mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-20 09:59:42 +00:00
Implemented ImageData object caching for custom GUI button & rect elements
This commit is contained in:
1 parent
a9961ed740
commit
b49402f8bd
4 files changed
+77
-175
No files matched your search
@@ -13,12 +13,13 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class ImageData {
|
||||
private ResourceLocation location;
|
||||
private final ResourceLocation location;
|
||||
private final boolean isUrl;
|
||||
|
||||
private ImageDownloadAlt imageDownloadAlt = null;
|
||||
private BufferedImage bufferedImage = null;
|
||||
private int totalWidth, totalHeight;
|
||||
|
||||
private int totalWidth, totalHeight;
|
||||
private boolean gotWidthHeight;
|
||||
private boolean invalid;
|
||||
|
||||
@@ -28,14 +29,14 @@ public class ImageData {
|
||||
this.isUrl = true;
|
||||
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
|
||||
this.imageDownloadAlt = new ImageDownloadAlt(null, directory, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true, false));
|
||||
texturemanager.loadTexture(location, this.imageDownloadAlt);
|
||||
texturemanager.loadTexture(this.location, this.imageDownloadAlt);
|
||||
} else {
|
||||
this.isUrl = false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean invalidTexture() {
|
||||
return this.invalid;
|
||||
public boolean imageLoaded() {
|
||||
return !this.invalid && this.location != null && this.gotWidthHeight;
|
||||
}
|
||||
|
||||
public void bindTexture() {
|
||||
@@ -49,7 +50,7 @@ public class ImageData {
|
||||
}
|
||||
}
|
||||
|
||||
public ResourceLocation getLocation() {
|
||||
private ResourceLocation getLocation() {
|
||||
return this.isUrl && this.imageDownloadAlt.getBufferedImage() == null ? null : this.location;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user