Skip to content

Commit

Permalink
Allow getting UID for empty itemstack
Browse files Browse the repository at this point in the history
  • Loading branch information
mezz committed Oct 2, 2024
1 parent 4d89747 commit 2d509e3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
11 changes: 0 additions & 11 deletions Common/src/main/java/mezz/jei/common/util/ErrorUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion Common/src/main/java/mezz/jei/common/util/StackHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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)
Expand Down Expand Up @@ -141,7 +141,7 @@ public Iterable<Integer> getColors(ItemStack ingredient) {

@Override
public ResourceLocation getResourceLocation(ItemStack ingredient) {
ErrorUtil.checkNotEmpty(ingredient);
ErrorUtil.checkNotNull(ingredient, "ingredient");

Item item = ingredient.getItem();
ResourceLocation key = RegistryUtil
Expand Down

0 comments on commit 2d509e3

Please sign in to comment.