Skip to content

Commit

Permalink
fix: 🐛 Fix anvil NPE crash in some packs
Browse files Browse the repository at this point in the history
  • Loading branch information
P3pp3rF1y committed Jan 31, 2024
1 parent c92879b commit 8a689e7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<AnvilUpgradeWrapper, AnvilUpgradeContainer> {
private static final String DATA_SHIFT_CLICK_INTO_STORAGE = "shiftClickIntoStorage";
private final Slot resultSlot;
Expand Down Expand Up @@ -77,6 +79,7 @@ public int getCost() {
return anvilMenuDelegate.getCost();
}

@Nullable
public String getItemName() {
return anvilMenuDelegate.getItemName();
}
Expand All @@ -95,6 +98,7 @@ public PersistableAnvilMenu(Inventory playerInventory, AnvilUpgradeWrapper wrapp
initializing = false;
}

@Nullable
public String getItemName() {
return itemName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 8a689e7

Please sign in to comment.