Fix uncaught ClassCastException from invalid recipe file (#4043)
A JsonSyntaxException will now be thrown, caught and logged when the conditions property of a recipe isn't an array
This commit is contained in:
parent
f670ec4f0b
commit
cb02f24cf2
2 changed files with 22 additions and 1 deletions
|
@ -735,7 +735,7 @@ public class CraftingHelper {
|
|||
{
|
||||
reader = Files.newBufferedReader(f);
|
||||
JsonObject json = JsonUtils.fromJson(GSON, reader, JsonObject.class);
|
||||
if (json.has("conditions") && !CraftingHelper.processConditions(json.getAsJsonArray("conditions"), ctx))
|
||||
if (json.has("conditions") && !CraftingHelper.processConditions(JsonUtils.getJsonArray(json, "conditions"), ctx))
|
||||
continue;
|
||||
IRecipe recipe = CraftingHelper.getRecipe(json, ctx);
|
||||
ForgeRegistries.RECIPES.register(recipe.setRegistryName(key));
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"conditions": {
|
||||
"not an array": "conditions property must be an array"
|
||||
},
|
||||
"type": "crafting_shaped",
|
||||
"group": "planks",
|
||||
"pattern": [
|
||||
"#"
|
||||
],
|
||||
"key": {
|
||||
"#": {
|
||||
"item": "minecraft:log2",
|
||||
"data": 0
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "minecraft:planks",
|
||||
"data": 4,
|
||||
"count": 4
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue