DBot — Сегодня, в 14:51
Считается что работает правильно Пока не доказано обратное
This commit is contained in:
parent
5be91b2f1a
commit
91c8100729
@ -42,8 +42,10 @@ import net.minecraft.world.inventory.AbstractContainerMenu
|
|||||||
import net.minecraft.world.inventory.TransientCraftingContainer
|
import net.minecraft.world.inventory.TransientCraftingContainer
|
||||||
import net.minecraft.world.item.Item
|
import net.minecraft.world.item.Item
|
||||||
import net.minecraft.world.item.ItemStack
|
import net.minecraft.world.item.ItemStack
|
||||||
|
import net.minecraft.world.item.crafting.Ingredient
|
||||||
import net.minecraft.world.item.crafting.Recipe
|
import net.minecraft.world.item.crafting.Recipe
|
||||||
import net.minecraft.world.item.crafting.RecipeType
|
import net.minecraft.world.item.crafting.RecipeType
|
||||||
|
import net.minecraft.world.item.crafting.SmithingTransformRecipe
|
||||||
import net.minecraft.world.level.ItemLike
|
import net.minecraft.world.level.ItemLike
|
||||||
import net.minecraftforge.common.capabilities.ForgeCapabilities
|
import net.minecraftforge.common.capabilities.ForgeCapabilities
|
||||||
import net.minecraftforge.common.crafting.IShapedRecipe
|
import net.minecraftforge.common.crafting.IShapedRecipe
|
||||||
@ -585,6 +587,55 @@ object MatterManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
registrar.register("smithing") {
|
||||||
|
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 isCritical = data["is_critical"]?.asBoolean ?: true
|
||||||
|
val allowBacktrack = data["allow_backtrack"]?.asBoolean ?: true
|
||||||
|
|
||||||
|
var stream = server.recipeManager.byType(findRecipeType).values.stream().filter { !it.value.isIncomplete }
|
||||||
|
stream = stream.filter { it.value is SmithingTransformRecipe }
|
||||||
|
|
||||||
|
stream.filter { it.value.getResultItem(server.registryAccess()).isNotEmpty }.map {
|
||||||
|
try {
|
||||||
|
val ingredients = ArrayList<Ingredient>()
|
||||||
|
|
||||||
|
val recipe = it.value as SmithingTransformRecipe
|
||||||
|
|
||||||
|
ingredients.add(recipe.base)
|
||||||
|
ingredients.add(recipe.addition)
|
||||||
|
|
||||||
|
ResolvedRecipe(
|
||||||
|
ingredients.stream()
|
||||||
|
.filter { !it.isActuallyEmpty }
|
||||||
|
.map { it.items.stream().filter { it.isNotEmpty }.map(::RecipeEntry) },
|
||||||
|
ImmutableStack(it.value.getResultItem(server.registryAccess())),
|
||||||
|
isCritical = isCritical,
|
||||||
|
name = it.id,
|
||||||
|
allowBacktrack = allowBacktrack
|
||||||
|
)
|
||||||
|
} catch(err: Throwable) {
|
||||||
|
throw RuntimeException("Processing smithing recipe ${it.id}", err)
|
||||||
|
}
|
||||||
|
}.filterNotNull().filter {
|
||||||
|
if (it.inputs.isEmpty()) {
|
||||||
|
LOGGER.warn("${it.formattedName} with output '${it.output.item.registryName}' ended up with no inputs!")
|
||||||
|
false
|
||||||
|
} else {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var foundResolvers: Map<ResourceLocation, Pair<Finder, JsonObject>> = ImmutableMap.of()
|
private var foundResolvers: Map<ResourceLocation, Pair<Finder, JsonObject>> = ImmutableMap.of()
|
||||||
|
@ -156,6 +156,9 @@ public net.minecraft.client.renderer.FogRenderer f_109010_ # fogRed
|
|||||||
|
|
||||||
public net.minecraft.world.item.crafting.RecipeManager m_44054_(Lnet/minecraft/world/item/crafting/RecipeType;)Ljava/util/Map; # byType
|
public net.minecraft.world.item.crafting.RecipeManager m_44054_(Lnet/minecraft/world/item/crafting/RecipeType;)Ljava/util/Map; # byType
|
||||||
|
|
||||||
|
public net.minecraft.world.item.crafting.SmithingTransformRecipe f_265888_ # base
|
||||||
|
public net.minecraft.world.item.crafting.SmithingTransformRecipe f_265907_ # addition
|
||||||
|
|
||||||
public net.minecraft.world.entity.boss.wither.WitherBoss f_31432_ # TARGETING_CONDITIONS
|
public net.minecraft.world.entity.boss.wither.WitherBoss f_31432_ # TARGETING_CONDITIONS
|
||||||
public-f net.minecraft.world.entity.boss.wither.WitherBoss f_31431_ # LIVING_ENTITY_SELECTOR
|
public-f net.minecraft.world.entity.boss.wither.WitherBoss f_31431_ # LIVING_ENTITY_SELECTOR
|
||||||
public net.minecraft.world.entity.ai.targeting.TargetingConditions f_26879_ # selector
|
public net.minecraft.world.entity.ai.targeting.TargetingConditions f_26879_ # selector
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"recipe_type": "minecraft:smithing",
|
"recipe_type": "minecraft:smithing",
|
||||||
"type": "overdrive_that_matters:simple",
|
"type": "overdrive_that_matters:smithing",
|
||||||
"is_critical": false
|
"is_critical": false
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user