mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-19 11:59:25 +00:00
Catch json parsing errors from constants/factories files (#5258)
This commit is contained in:
1 parent
931105123e
commit
45902676fd
1 file changed
+7
-2
@@ -237,7 +237,7 @@ public class CraftingHelper
|
||||
if(element.isJsonObject())
|
||||
nbt = JsonToNBT.getTagFromJson(GSON.toJson(element));
|
||||
else
|
||||
nbt = JsonToNBT.getTagFromJson(element.getAsString());
|
||||
nbt = JsonToNBT.getTagFromJson(JsonUtils.getString(element, "nbt"));
|
||||
|
||||
NBTTagCompound tmp = new NBTTagCompound();
|
||||
if (nbt.hasKey("ForgeCaps"))
|
||||
@@ -261,6 +261,11 @@ public class CraftingHelper
|
||||
return new ItemStack(item, JsonUtils.getInt(json, "count", 1));
|
||||
}
|
||||
|
||||
public static boolean processConditions(JsonObject json, String memberName)
|
||||
{
|
||||
return !json.has(memberName) || processConditions(JsonUtils.getJsonArray(json, memberName));
|
||||
}
|
||||
|
||||
public static boolean processConditions(JsonArray conditions)
|
||||
{
|
||||
for (int x = 0; x < conditions.size(); x++)
|
||||
@@ -312,7 +317,7 @@ public class CraftingHelper
|
||||
|
||||
if (json == null || json.size() == 0)
|
||||
LOGGER.error(CRAFTHELPER, "Couldn't load constant #{} from {} as it's null or empty", x, key);
|
||||
else if (json.has("conditions") && !processConditions(JsonUtils.getJsonArray(json, "conditions")))
|
||||
else if (!processConditions(json, "conditions"))
|
||||
LOGGER.info(CRAFTHELPER, "Skipping loading constant #{} from {} as it's conditions were not met", x, key);
|
||||
else if (name == null)
|
||||
LOGGER.error(CRAFTHELPER, "Couldn't load constant #{} from {} as it's missing `name`", x, key);
|
||||
|
||||
Reference in new issue
Block a user