Update ItemUtil.java
This commit is contained in:
parent
220b16fa42
commit
66c2506fa3
1 changed files with 3 additions and 2 deletions
|
@ -55,13 +55,14 @@ public class ItemUtil {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static ItemStack fromJsonRecipe(JsonObject recipe) {
|
public static ItemStack fromJsonRecipe(JsonObject recipe) {
|
||||||
if (!recipe.has("item")) return null;
|
|
||||||
try {
|
try {
|
||||||
|
if (!recipe.has("item")) {
|
||||||
|
throw new IllegalStateException("Invalid JsonObject. Entry 'item' does not exists!");
|
||||||
|
}
|
||||||
Identifier itemId = new Identifier(JsonHelper.getString(recipe, "item"));
|
Identifier itemId = new Identifier(JsonHelper.getString(recipe, "item"));
|
||||||
Item item = Registry.ITEM.getOrEmpty(itemId).orElseThrow(() -> {
|
Item item = Registry.ITEM.getOrEmpty(itemId).orElseThrow(() -> {
|
||||||
return new IllegalStateException("Output item " + itemId + " does not exists!");
|
return new IllegalStateException("Output item " + itemId + " does not exists!");
|
||||||
});
|
});
|
||||||
if (item == null) return null;
|
|
||||||
int count = JsonHelper.getInt(recipe, "count", 1);
|
int count = JsonHelper.getInt(recipe, "count", 1);
|
||||||
return new ItemStack(item, count);
|
return new ItemStack(item, count);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue