TransmuteRecipeBuilder .java

net.minecraft.data.recipes.TransmuteRecipeBuilder (class): members: addMaterialCountToOutput, setMaterialCount, transmute, materialCount, defaultId, group.

net.minecraft.data.recipesclass88 linescommon3.2 KB

Implements

API Surface (8)

TransmuteRecipeBuilder transmute(final RecipeCategory category, final Ingredient input, final Ingredient material, final Item result)
TransmuteRecipeBuilder transmute(final RecipeCategory category, final Ingredient input, final Ingredient material, final ItemStackTemplate result)
TransmuteRecipeBuilder transmute(final RecipeCategory category, final Ingredient input, final Ingredient material, final TransmuteResult result)
TransmuteRecipeBuilder unlockedBy(final String name, final Criterion<?> criterion)
TransmuteRecipeBuilder group(final @Nullable String group)
TransmuteRecipeBuilder addMaterialCountToOutput()
TransmuteRecipeBuilder setMaterialCount(final MinMaxBounds.Ints materialCount)
void save(final RecipeOutput output, final ResourceKey<Recipe<?>> id)

Fields & Constants (8)

category
result
input
material
advancementBuilder
group
materialCount
addMaterialCountToOutput

Full Source

TransmuteRecipeBuilder.java88 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.data.recipes;
2
3
import net.minecraft.advancements.predicates.MinMaxBounds;
4
import net.minecraft.advancements.triggers.Criterion;
5
import net.minecraft.core.Holder;
6
import net.minecraft.resources.ResourceKey;
7
import net.minecraft.world.item.Item;
8
import net.minecraft.world.item.ItemStackTemplate;
9
import net.minecraft.world.item.crafting.Ingredient;
10
import net.minecraft.world.item.crafting.Recipe;
11
import net.minecraft.world.item.crafting.TransmuteRecipe;
12
import net.minecraft.world.item.crafting.TransmuteResult;
13
import org.jspecify.annotations.Nullable;
14
15
public class TransmuteRecipeBuilder implements RecipeBuilder {
16
	private final RecipeCategory category;
17
	private final TransmuteResult result;
18
	private final Ingredient input;
19
	private final Ingredient material;
20
	private final RecipeUnlockAdvancementBuilder advancementBuilder = new RecipeUnlockAdvancementBuilder();
21
	private @Nullable String group;
22
	private MinMaxBounds.Ints materialCount = TransmuteRecipe.DEFAULT_MATERIAL_COUNT;
23
	private boolean addMaterialCountToOutput;
24
25
	private TransmuteRecipeBuilder(final RecipeCategory category, final TransmuteResult result, final Ingredient input, final Ingredient material) {
26
		this.category = category;
27
		this.result = result;
28
		this.input = input;
29
		this.material = material;
30
	}
31
32
	public static TransmuteRecipeBuilder transmute(final RecipeCategory category, final Ingredient input, final Ingredient material, final Item result) {
33
		return transmute(category, input, material, new TransmuteResult(result));
34
	}
35
36
	public static TransmuteRecipeBuilder transmute(
37
		final RecipeCategory category, final Ingredient input, final Ingredient material, final ItemStackTemplate result
38
	) {
39
		return transmute(category, input, material, TransmuteResult.fromTemplate(result));
40
	}
41
42
	public static TransmuteRecipeBuilder transmute(final RecipeCategory category, final Ingredient input, final Ingredient material, final TransmuteResult result) {
43
		return new TransmuteRecipeBuilder(category, result, input, material);
44
	}
45
46
	public TransmuteRecipeBuilder unlockedBy(final String name, final Criterion<?> criterion) {
47
		this.advancementBuilder.unlockedBy(name, criterion);
48
		return this;
49
	}
50
51
	public TransmuteRecipeBuilder group(final @Nullable String group) {
52
		this.group = group;
53
		return this;
54
	}
55
56
	public TransmuteRecipeBuilder addMaterialCountToOutput() {
57
		this.addMaterialCountToOutput = true;
58
		return this;
59
	}
60
61
	public TransmuteRecipeBuilder setMaterialCount(final MinMaxBounds.Ints materialCount) {
62
		this.materialCount = materialCount;
63
		return this;
64
	}
65
66
	@Override
67
	public @Nullable ResourceKey<Recipe<?>> defaultId() {
68
		return this.result
69
			.item()
70
			.map(item -> RecipeBuilder.getDefaultRecipeId(new ItemStackTemplate((Holder<Item>)item, this.result.count(), this.result.components())))
71
			.orElse(null);
72
	}
73
74
	@Override
75
	public void save(final RecipeOutput output, final ResourceKey<Recipe<?>> id) {
76
		TransmuteRecipe recipe = new TransmuteRecipe(
77
			RecipeBuilder.createCraftingCommonInfo(true),
78
			RecipeBuilder.createCraftingBookInfo(this.category, this.group),
79
			this.input,
80
			this.material,
81
			this.materialCount,
82
			this.result,
83
			this.addMaterialCountToOutput
84
		);
85
		output.accept(id, recipe, this.advancementBuilder.build(output, id, this.category));
86
	}
87
}
88

Decompiled Minecraft 26.3 source of TransmuteRecipeBuilder (net/minecraft/data/recipes/TransmuteRecipeBuilder.java) with Mojang official mappings, stored verbatim on the site.