Crash fixes for custom items

This commit is contained in:
Luis C.M committed 2023-04-12 00:18:43 -05:00
1 parent a10e427c1c
commit 8b0431340c
2 files changed
+10 -2

No files matched your search

@@ -49,8 +49,14 @@ public class CustomItemRenderer implements IItemRenderer {
public void renderItem(ItemRenderType type, ItemStack itemStack, Object... data) {
ScriptCustomItem scriptCustomItem = ItemScripted.GetWrapper(itemStack);
ImageData imageData = Client.getImageData(scriptCustomItem.texture);
if(imageData.getTotalWidth() == -1 || imageData.getTotalHeight() == -1 || imageData.invalidTexture())
BufferedImage bufferedImage = Client.getImageData(scriptCustomItem.texture).getBufferedImage();
if (bufferedImage != null && (scriptCustomItem.width != bufferedImage.getWidth() || scriptCustomItem.height != bufferedImage.getHeight())) {
scriptCustomItem.width = bufferedImage.getWidth();
scriptCustomItem.height = bufferedImage.getHeight();
scriptCustomItem.saveItemData();
}
if(scriptCustomItem.width < 1 || scriptCustomItem.height < 1)
return;
if (type == ItemRenderType.INVENTORY) {
@@ -43,6 +43,8 @@ public class ScriptCustomItem extends ScriptItemStack implements IItemCustom, IS
public float rotationX, rotationY, rotationZ;
public float rotationXRate, rotationYRate, rotationZRate;
public int width = -1, height = -1;
public ScriptCustomItem(ItemStack item) {
super(item);
loadScriptData();