From 5c87d0f8abecf14fc0fb70a25f9c60a63a236cfb Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 14 Jan 2022 17:42:07 +0700 Subject: [PATCH] More recipes for plate press, ignore "unknown tag" errors --- .../ru/dbotthepony/mc/otm/datagen/DataGen.kt | 17 +++++++++++++++-- .../mc/otm/recipes/PlatePressRecipe.kt | 19 +++++++++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt index 25546049c..cb865c75f 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt @@ -290,8 +290,21 @@ object DataGen { } with(recipeProvider) { - plate("iron") - plate("tritanium") + val baselineMetals = arrayOf("iron", "silver", "bronze", "lead", "constantan") + val softMetals = arrayOf("gold", "aluminum", "aluminium", "brass", "copper", "electrum") + val hardMetals = arrayOf("tritanium", "steel", "tungsten", "uranium") + + for (thing in baselineMetals) { + plate(thing) + } + + for (thing in softMetals) { + plate(thing, workTicks = 140) + } + + for (thing in hardMetals) { + plate(thing, workTicks = 300) + } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipes/PlatePressRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipes/PlatePressRecipe.kt index 262c0f3d9..c1255e9d8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipes/PlatePressRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipes/PlatePressRecipe.kt @@ -12,6 +12,7 @@ import net.minecraft.world.item.crafting.RecipeSerializer import net.minecraft.world.item.crafting.RecipeType import net.minecraft.world.level.Level import net.minecraftforge.registries.ForgeRegistryEntry +import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.Registry import ru.dbotthepony.mc.otm.block.entity.BlockEntityPlatePress @@ -69,6 +70,8 @@ class PlatePressRecipe( } object PlatePressRecipeFactory : ForgeRegistryEntry>(), RecipeSerializer { + private val LOGGER = LogManager.getLogger() + init { registryName = Registry.Names.PLATE_PRESS } @@ -77,13 +80,25 @@ object PlatePressRecipeFactory : ForgeRegistryEntry>(), Reci val input = try { Ingredient.fromJson(obj["input"] ?: throw IllegalStateException("Recipe $loc has no input field defined")) } catch (err: Throwable) { - throw IllegalStateException("Input of $loc is malformed", err) + if (err.message?.lowercase()?.contains("unknown item tag") == true) { + LOGGER.warn("Ignoring recipe Input of $loc deserialization error") + LOGGER.warn(err) + Ingredient.of() + } else { + throw IllegalStateException("Input of $loc is malformed", err) + } } val result = try { Ingredient.fromJson(obj["result"] ?: throw IllegalStateException("Recipe $loc has no result field defined")) } catch (err: Throwable) { - throw IllegalStateException("Result of $loc is malformed", err) + if (err.message?.lowercase()?.contains("unknown item tag") == true) { + LOGGER.warn("Ignoring recipe Output of $loc deserialization error") + LOGGER.warn(err) + Ingredient.of() + } else { + throw IllegalStateException("Result of $loc is malformed", err) + } } val workTime = (obj["work_time"] as? JsonPrimitive)?.let { return@let try {it.asInt} catch(err: Throwable) {throw IllegalStateException("Invalid work_time")} } ?: 200