mirror of
https://github.com/Pumpkin-MC/Pumpkin.git
synced 2026-08-30 20:14:23 +00:00
Extractor: Export Recipes
This commit is contained in:
18554
assets/recipes.json
Normal file
18554
assets/recipes.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -27,7 +27,7 @@ class Items : Extractor.Extractor {
|
||||
val realItem: Item = item.value()
|
||||
|
||||
itemJson.addProperty("id", Registries.ITEM.getRawId(realItem))
|
||||
itemJson.addProperty("name", Registries.ITEM.getId(realItem).toString())
|
||||
itemJson.addProperty("name", Registries.ITEM.getId(realItem).toString())
|
||||
itemJson.addProperty("translation_key", realItem.translationKey)
|
||||
itemJson.addProperty("max_stack", realItem.maxCount)
|
||||
itemJson.addProperty("max_durability", realItem.defaultStack.maxDamage)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package de.snowii.extractor.extractors
|
||||
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.JsonArray
|
||||
import com.google.gson.JsonElement
|
||||
import com.google.gson.JsonObject
|
||||
import com.mojang.serialization.JsonOps
|
||||
import de.snowii.extractor.Extractor
|
||||
import net.minecraft.recipe.Recipe
|
||||
import net.minecraft.registry.RegistryOps
|
||||
import net.minecraft.server.MinecraftServer
|
||||
|
||||
class Recipes : Extractor.Extractor {
|
||||
@@ -15,40 +15,15 @@ class Recipes : Extractor.Extractor {
|
||||
|
||||
override fun extract(server: MinecraftServer): JsonElement {
|
||||
val recipesJson = JsonArray()
|
||||
val gson = Gson()
|
||||
|
||||
for (recipeRaw in server.recipeManager.values()) {
|
||||
val recipeJson = JsonObject()
|
||||
|
||||
recipeJson.addProperty("name", recipeRaw.id.value.toString())
|
||||
val recipe: Recipe<*> = recipeRaw.value()
|
||||
recipeJson.addProperty("category", recipe.group)
|
||||
recipeJson.addProperty("group", recipe.group)
|
||||
recipeJson.addProperty("type", recipe.type.toString())
|
||||
val placementArray = JsonArray()
|
||||
for (slot in recipe.ingredientPlacement.placementSlots) {
|
||||
val placementJson = JsonObject()
|
||||
if (slot.isPresent) {
|
||||
placementJson.addProperty("position", slot.orElseThrow().placerOutputPosition)
|
||||
}
|
||||
placementArray.add(placementJson)
|
||||
}
|
||||
recipeJson.add("placementSlots", placementArray)
|
||||
|
||||
val ingredientArray = JsonArray()
|
||||
for (ingredient in recipe.ingredientPlacement.ingredients) {
|
||||
if (ingredient != null) {
|
||||
val items = ingredient.matchingItems
|
||||
val ingredientJson = JsonObject()
|
||||
for (item in items) {
|
||||
ingredientJson.addProperty("id", item.idAsString)
|
||||
}
|
||||
ingredientArray.add(ingredientJson)
|
||||
}
|
||||
}
|
||||
recipeJson.add("ingredients", ingredientArray)
|
||||
|
||||
recipesJson.add(recipeJson)
|
||||
val recipe = recipeRaw.value
|
||||
recipesJson.add(
|
||||
Recipe.CODEC.encodeStart(
|
||||
RegistryOps.of(JsonOps.INSTANCE, server.registryManager),
|
||||
recipe
|
||||
).getOrThrow()
|
||||
)
|
||||
}
|
||||
return recipesJson
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user