From 8a689e7bb2f0aa13af09d57e824b93d1421312c8 Mon Sep 17 00:00:00 2001 From: P3pp3rF1y Date: Thu, 1 Feb 2024 00:39:49 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Fix=20anvil=20NPE=20crash?= =?UTF-8?q?=20in=20some=20packs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 2 +- .../upgrades/anvil/AnvilUpgradeContainer.java | 4 ++++ .../upgrades/anvil/AnvilUpgradeTab.java | 5 +++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index da074921..03c5f686 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false minecraft_version=1.19.2 forge_version=43.2.13 -mod_version=3.19.5 +mod_version=3.19.6 jei_mc_version=1.19.2-forge jei_version=11.6.0.1018 curios_version=1.19.2-5.1.4.3 diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/anvil/AnvilUpgradeContainer.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/anvil/AnvilUpgradeContainer.java index 4e46f24c..15768232 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/anvil/AnvilUpgradeContainer.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/anvil/AnvilUpgradeContainer.java @@ -13,6 +13,8 @@ import net.p3pp3rf1y.sophisticatedcore.common.gui.UpgradeContainerType; import net.p3pp3rf1y.sophisticatedcore.util.NBTHelper; +import javax.annotation.Nullable; + public class AnvilUpgradeContainer extends UpgradeContainerBase { private static final String DATA_SHIFT_CLICK_INTO_STORAGE = "shiftClickIntoStorage"; private final Slot resultSlot; @@ -77,6 +79,7 @@ public int getCost() { return anvilMenuDelegate.getCost(); } + @Nullable public String getItemName() { return anvilMenuDelegate.getItemName(); } @@ -95,6 +98,7 @@ public PersistableAnvilMenu(Inventory playerInventory, AnvilUpgradeWrapper wrapp initializing = false; } + @Nullable public String getItemName() { return itemName; } diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/anvil/AnvilUpgradeTab.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/anvil/AnvilUpgradeTab.java index 70c19b07..d23f8cc7 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/anvil/AnvilUpgradeTab.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/anvil/AnvilUpgradeTab.java @@ -77,8 +77,9 @@ protected void renderBg(PoseStack poseStack, Minecraft minecraft, int mouseX, in private String getInitialNameValue() { ItemStack firstItem = getContainer().getSlots().get(0).getItem(); - if (!firstItem.isEmpty() && !getContainer().getItemName().isEmpty()) { - return getContainer().getItemName(); + String itemName = getContainer().getItemName(); + if (!firstItem.isEmpty() && itemName != null && !itemName.isEmpty()) { + return itemName; } return firstItem.isEmpty() ? "" : firstItem.getHoverName().getString(); }