From 191dfab07fe18fc08299c95af868427ec197c43e Mon Sep 17 00:00:00 2001 From: CuzImClicks Date: Wed, 1 Apr 2026 15:20:49 +0200 Subject: [PATCH] extract RecipePropertySets --- .../com/steelextractor/SteelExtractor.kt | 4 +- .../extractors/RecipePropertySets.kt | 47 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/main/kotlin/com/steelextractor/extractors/RecipePropertySets.kt diff --git a/src/main/kotlin/com/steelextractor/SteelExtractor.kt b/src/main/kotlin/com/steelextractor/SteelExtractor.kt index 3bd6304..6f341f9 100644 --- a/src/main/kotlin/com/steelextractor/SteelExtractor.kt +++ b/src/main/kotlin/com/steelextractor/SteelExtractor.kt @@ -29,6 +29,7 @@ import net.minecraft.world.level.Level import net.minecraft.world.level.chunk.status.ChunkStatus import com.steelextractor.extractors.PoiTypesExtractor import com.steelextractor.extractors.Potions +import com.steelextractor.extractors.RecipePropertySets import com.steelextractor.extractors.StructureStarts import com.steelextractor.extractors.Tags import com.steelextractor.extractors.Waxables @@ -112,7 +113,8 @@ object SteelExtractor : ModInitializer { Strippables(), Weathering(), Waxables(), - PoiTypesExtractor() + PoiTypesExtractor(), + RecipePropertySets() ) diff --git a/src/main/kotlin/com/steelextractor/extractors/RecipePropertySets.kt b/src/main/kotlin/com/steelextractor/extractors/RecipePropertySets.kt new file mode 100644 index 0000000..ce2bd0d --- /dev/null +++ b/src/main/kotlin/com/steelextractor/extractors/RecipePropertySets.kt @@ -0,0 +1,47 @@ +package com.steelextractor.extractors + +import com.google.gson.JsonArray +import com.google.gson.JsonElement +import com.google.gson.JsonObject +import com.steelextractor.SteelExtractor +import net.minecraft.core.Holder +import net.minecraft.resources.ResourceKey +import net.minecraft.server.MinecraftServer +import net.minecraft.world.item.Item +import net.minecraft.world.item.crafting.RecipeManager +import net.minecraft.world.item.crafting.RecipePropertySet + +class RecipePropertySets : SteelExtractor.Extractor { + override fun fileName(): String { + return "steel-registry/build_assets/recipe_property_sets.json" + } + + override fun extract(server: MinecraftServer): JsonElement { + val topLevel = JsonObject() + + val field = RecipeManager::class.java.getDeclaredField("propertySets") + field.isAccessible = true + + @Suppress("UNCHECKED_CAST") + val propertySets = field.get(server.recipeManager) as Map, RecipePropertySet> + + val itemsField = RecipePropertySet::class.java.getDeclaredField("items") + itemsField.isAccessible = true + + for ((key, propertySet) in propertySets) { + + @Suppress("UNCHECKED_CAST") + val items = itemsField.get(propertySet) as Set> + val obj = JsonArray() + + for (item in items) { + obj.add(item.registeredName) + } + + topLevel.add(key.identifier().path, obj) + } + + + return topLevel + } +} \ No newline at end of file