Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/main/kotlin/com/steelextractor/SteelExtractor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -112,7 +113,8 @@ object SteelExtractor : ModInitializer {
Strippables(),
Weathering(),
Waxables(),
PoiTypesExtractor()
PoiTypesExtractor(),
RecipePropertySets()
)


Expand Down
Original file line number Diff line number Diff line change
@@ -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<ResourceKey<RecipePropertySet>, 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<Holder<Item>>
val obj = JsonArray()

for (item in items) {
obj.add(item.registeredName)
}

topLevel.add(key.identifier().path, obj)
}


return topLevel
}
}
Loading