mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 11:29:15 +00:00
Fix issues in the deserialization of empty ingredients (#9537)
This commit is contained in:
1 parent
7614e024ed
commit
622c47c075
3 files changed
+14
-3
No files matched your search
@@ -118,7 +118,13 @@ public class CraftingHelper
|
||||
ingredients.add(Ingredient.merge(vanilla));
|
||||
|
||||
if (ingredients.size() == 0)
|
||||
{
|
||||
if (allowEmpty)
|
||||
{
|
||||
return Ingredient.EMPTY;
|
||||
}
|
||||
throw new JsonSyntaxException("Item array cannot be empty, at least one item must be defined");
|
||||
}
|
||||
|
||||
if (ingredients.size() == 1)
|
||||
return ingredients.get(0);
|
||||
|
||||
@@ -120,8 +120,8 @@ public class DifferenceIngredient extends AbstractIngredient
|
||||
@Override
|
||||
public DifferenceIngredient parse(JsonObject json)
|
||||
{
|
||||
Ingredient base = Ingredient.fromJson(json.get("base"));
|
||||
Ingredient without = Ingredient.fromJson(json.get("subtracted"));
|
||||
Ingredient base = Ingredient.fromJson(json.get("base"), false);
|
||||
Ingredient without = Ingredient.fromJson(json.get("subtracted"), false);
|
||||
return new DifferenceIngredient(base, without);
|
||||
}
|
||||
|
||||
|
||||
@@ -152,7 +152,12 @@ public class IntersectionIngredient extends AbstractIngredient
|
||||
JsonArray children = GsonHelper.getAsJsonArray(json, "children");
|
||||
if (children.size() < 2)
|
||||
throw new JsonSyntaxException("Must have at least two children for an intersection ingredient");
|
||||
return new IntersectionIngredient(IntStream.range(0, children.size()).mapToObj(i -> Ingredient.fromJson(children.get(i))).toList());
|
||||
|
||||
return new IntersectionIngredient(
|
||||
IntStream.range(0, children.size())
|
||||
.mapToObj(i -> Ingredient.fromJson(children.get(i), false))
|
||||
.toList()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user