Skip to content

Commit

Permalink
fix hover crash to unnamed item
Browse files Browse the repository at this point in the history
  • Loading branch information
slprime committed Aug 5, 2024
1 parent 83696ca commit 3b3227b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/java/codechicken/nei/ItemZoom.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class ItemZoom extends Widget implements IContainerInputHandler {
private Boolean previousKeyboardRepeatEnabled = null;

private ItemStack stack = null;
private String displayName = "";
private int availableAreaWidth = 0;
private float xPosition = 0;
private float yPosition = 0;
Expand Down Expand Up @@ -61,8 +62,7 @@ public void draw(int mx, int my) {
GL11.glPopMatrix();

if (NEIClientConfig.getBooleanSetting("inventory.itemzoom.showName")) {
String dispalyName = NEIClientUtils
.cropText(fontRenderer, this.stack.getDisplayName(), this.availableAreaWidth);
String dispalyName = NEIClientUtils.cropText(fontRenderer, this.displayName, this.availableAreaWidth);
drawStringC(
dispalyName,
(int) ((this.xPosition + size / 2) * screenScale),
Expand Down Expand Up @@ -114,9 +114,16 @@ public void resize(GuiContainer gui) {
this.xPosition += (gui.guiLeft + gui.xSize) * screenScale;;
}

try {
this.displayName = stack.getDisplayName();
} catch (Throwable ignored) {
this.displayName = "Unnamed";
}

this.stack = StackInfo.loadFromNBT(StackInfo.itemStackToNBT(stack), 0);
} else {
this.stack = null;
this.displayName = "";
}
}

Expand Down

0 comments on commit 3b3227b

Please sign in to comment.