From 2d509e3a232f1f3ec4df02c8da960f872197a932 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 2 Oct 2024 13:04:38 +0900 Subject: [PATCH] Allow getting UID for empty itemstack --- .../src/main/java/mezz/jei/common/util/ErrorUtil.java | 11 ----------- .../main/java/mezz/jei/common/util/StackHelper.java | 2 +- .../plugins/vanilla/ingredients/ItemStackHelper.java | 10 +++++----- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/Common/src/main/java/mezz/jei/common/util/ErrorUtil.java b/Common/src/main/java/mezz/jei/common/util/ErrorUtil.java index 31f42d4c3..4bf75f548 100644 --- a/Common/src/main/java/mezz/jei/common/util/ErrorUtil.java +++ b/Common/src/main/java/mezz/jei/common/util/ErrorUtil.java @@ -80,17 +80,6 @@ private static String getBlockName(BlockItem blockItem) { return block.getClass().getName(); } - - @SuppressWarnings("ConstantConditions") - public static void checkNotEmpty(ItemStack itemStack) { - if (itemStack == null) { - throw new NullPointerException("ItemStack must not be null."); - } else if (itemStack.isEmpty()) { - String info = getItemStackInfo(itemStack); - throw new IllegalArgumentException("ItemStack value must not be empty. " + info); - } - } - @SuppressWarnings("ConstantConditions") public static void checkNotEmpty(ItemStack itemStack, String name) { if (itemStack == null) { diff --git a/Common/src/main/java/mezz/jei/common/util/StackHelper.java b/Common/src/main/java/mezz/jei/common/util/StackHelper.java index c02d4f4d6..e04259f39 100644 --- a/Common/src/main/java/mezz/jei/common/util/StackHelper.java +++ b/Common/src/main/java/mezz/jei/common/util/StackHelper.java @@ -77,7 +77,7 @@ public boolean hasSubtypes(ItemStack stack) { } public static String getRegistryNameForStack(ItemStack stack) { - ErrorUtil.checkNotEmpty(stack, "stack"); + ErrorUtil.checkNotNull(stack, "stack"); Item item = stack.getItem(); ResourceLocation key = RegistryUtil diff --git a/Library/src/main/java/mezz/jei/library/plugins/vanilla/ingredients/ItemStackHelper.java b/Library/src/main/java/mezz/jei/library/plugins/vanilla/ingredients/ItemStackHelper.java index 3659d0322..e29a68725 100644 --- a/Library/src/main/java/mezz/jei/library/plugins/vanilla/ingredients/ItemStackHelper.java +++ b/Library/src/main/java/mezz/jei/library/plugins/vanilla/ingredients/ItemStackHelper.java @@ -64,13 +64,13 @@ public String getDisplayName(ItemStack ingredient) { @SuppressWarnings("removal") @Override public String getUniqueId(ItemStack ingredient, UidContext context) { - ErrorUtil.checkNotEmpty(ingredient); + ErrorUtil.checkNotNull(ingredient, "ingredient"); return stackHelper.getUniqueIdentifierForStack(ingredient, context); } @Override public Object getUid(ItemStack ingredient, UidContext context) { - ErrorUtil.checkNotEmpty(ingredient, "ingredient"); + ErrorUtil.checkNotNull(ingredient, "ingredient"); ErrorUtil.checkNotNull(context, "type"); return stackHelper.getUidForStack(ingredient, context); } @@ -96,13 +96,13 @@ public boolean hasSubtypes(ItemStack ingredient) { @SuppressWarnings("removal") @Override public String getWildcardId(ItemStack ingredient) { - ErrorUtil.checkNotEmpty(ingredient); + ErrorUtil.checkNotNull(ingredient, "ingredient"); return StackHelper.getRegistryNameForStack(ingredient); } @Override public String getDisplayModId(ItemStack ingredient) { - ErrorUtil.checkNotEmpty(ingredient); + ErrorUtil.checkNotNull(ingredient, "ingredient"); IPlatformItemStackHelper itemStackHelper = Services.PLATFORM.getItemStackHelper(); return itemStackHelper.getCreatorModId(ingredient) @@ -141,7 +141,7 @@ public Iterable getColors(ItemStack ingredient) { @Override public ResourceLocation getResourceLocation(ItemStack ingredient) { - ErrorUtil.checkNotEmpty(ingredient); + ErrorUtil.checkNotNull(ingredient, "ingredient"); Item item = ingredient.getItem(); ResourceLocation key = RegistryUtil