mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 16:09:05 +00:00
Added functions for safeguarding scripted item textures erroring.
This commit is contained in:
1 parent
09f36bb56c
commit
116dc23f2b
2 files changed
+21
-7
No files matched your search
@@ -18,7 +18,9 @@ public class ImageData {
|
||||
private ImageDownloadAlt imageDownloadAlt = null;
|
||||
private BufferedImage bufferedImage = null;
|
||||
private int totalWidth, totalHeight;
|
||||
|
||||
private boolean gotWidthHeight;
|
||||
private boolean invalid;
|
||||
|
||||
public ImageData(String directory) {
|
||||
this.location = new ResourceLocation(directory);
|
||||
@@ -32,6 +34,21 @@ public class ImageData {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean invalidTexture() {
|
||||
return this.invalid;
|
||||
}
|
||||
|
||||
public void bindTexture() {
|
||||
ResourceLocation location = this.getLocation();
|
||||
if (location != null && !this.invalid) {
|
||||
try {
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(location);
|
||||
} catch (Exception exception) {
|
||||
this.invalid = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ResourceLocation getLocation() {
|
||||
return this.isUrl && this.imageDownloadAlt.getBufferedImage() == null ? null : this.location;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user