do use recipe_type for crafting recipe finder
for things like create mechanical crafting support
This commit is contained in:
parent
bd34ad8d3b
commit
03c12c5737
@ -471,10 +471,19 @@ object MatterManager {
|
||||
|
||||
registrar.register("crafting") {
|
||||
Finder { server, data ->
|
||||
val location = (data["recipe_type"] ?: throw JsonSyntaxException("Missing recipe type")).let { ResourceLocation.tryParse(it.asString) } ?: throw JsonSyntaxException("Invalid recipe type: ${data["recipe_type"]}")
|
||||
|
||||
if (!ForgeRegistries.RECIPE_TYPES.containsKey(location)) {
|
||||
LOGGER.error("Invalid or missing recipe category: $location!")
|
||||
return@Finder Stream.empty()
|
||||
}
|
||||
|
||||
val findRecipeType = ForgeRegistries.RECIPE_TYPES.getValue(location) as RecipeType<Recipe<Container>>? ?: throw ConcurrentModificationException()
|
||||
|
||||
val allowBacktrack = data["allow_backtrack"]?.asBoolean ?: true
|
||||
val ignoreDamageables = data["ignore_damageables"]?.asBoolean ?: false
|
||||
val isCritical = data["is_critical"]?.asBoolean ?: true
|
||||
var stream = server.recipeManager.byType(RecipeType.CRAFTING).values.stream().filter { !it.isIncomplete }
|
||||
var stream = server.recipeManager.byType(findRecipeType).values.stream().filter { !it.isIncomplete }
|
||||
|
||||
if (ignoreDamageables) {
|
||||
stream = stream.filter { it.ingredients.stream().flatMap { it.items.stream() }.noneMatch { it.isDamageableItem } }
|
||||
|
Loading…
Reference in New Issue
Block a user