Small fix
This commit is contained in:
parent
9e067499eb
commit
67340033bc
2 changed files with 9 additions and 5 deletions
|
@ -238,8 +238,8 @@ public class AlloyingRecipe implements Recipe<Inventory> {
|
||||||
JsonArray ingredients = JsonHelper.getArray(json, "ingredients");
|
JsonArray ingredients = JsonHelper.getArray(json, "ingredients");
|
||||||
Ingredient primaryInput = Ingredient.fromJson(ingredients.get(0));
|
Ingredient primaryInput = Ingredient.fromJson(ingredients.get(0));
|
||||||
Ingredient secondaryInput = Ingredient.fromJson(ingredients.get(1));
|
Ingredient secondaryInput = Ingredient.fromJson(ingredients.get(1));
|
||||||
JsonObject result = JsonHelper.getObject(json, "result");
|
|
||||||
String group = JsonHelper.getString(json, "group", "");
|
String group = JsonHelper.getString(json, "group", "");
|
||||||
|
JsonObject result = JsonHelper.getObject(json, "result");
|
||||||
ItemStack output = ItemUtil.fromJsonRecipe(result);
|
ItemStack output = ItemUtil.fromJsonRecipe(result);
|
||||||
if (output == null) {
|
if (output == null) {
|
||||||
throw new IllegalStateException("Output item does not exists!");
|
throw new IllegalStateException("Output item does not exists!");
|
||||||
|
|
|
@ -31,14 +31,18 @@ public class ItemUtil {
|
||||||
public static ItemStack fromStackString(String stackString) {
|
public static ItemStack fromStackString(String stackString) {
|
||||||
if (stackString == null || stackString.equals("")) return null;
|
if (stackString == null || stackString.equals("")) return null;
|
||||||
String[] parts = stackString.split(":");
|
String[] parts = stackString.split(":");
|
||||||
|
if (parts.length < 2) return null;
|
||||||
|
if (parts.length == 2) {
|
||||||
|
Identifier itemId = new Identifier(stackString);
|
||||||
|
Item item = Registry.ITEM.getOrEmpty(itemId).orElse(null);
|
||||||
|
if (item == null) return null;
|
||||||
|
return new ItemStack(item);
|
||||||
|
}
|
||||||
Identifier itemId = new Identifier(parts[0], parts[1]);
|
Identifier itemId = new Identifier(parts[0], parts[1]);
|
||||||
Item item = Registry.ITEM.getOrEmpty(itemId).orElse(null);
|
Item item = Registry.ITEM.getOrEmpty(itemId).orElse(null);
|
||||||
if (item == null) return null;
|
if (item == null) return null;
|
||||||
if (parts.length > 2) {
|
|
||||||
return new ItemStack(item, Integer.valueOf(parts[2]));
|
return new ItemStack(item, Integer.valueOf(parts[2]));
|
||||||
}
|
}
|
||||||
return new ItemStack(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static ItemStack fromJsonRecipe(JsonObject recipe) {
|
public static ItemStack fromJsonRecipe(JsonObject recipe) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue