Added functions for safeguarding scripted item textures erroring.

This commit is contained in:
Luis C.M committed 2023-04-11 23:25:29 -05:00
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;
}