|
7 | 7 |
|
8 | 8 | import org.jspecify.annotations.Nullable; |
9 | 9 |
|
10 | | -import com.mojang.serialization.Codec; |
11 | | -import com.mojang.serialization.MapCodec; |
12 | | -import com.mojang.serialization.codecs.RecordCodecBuilder; |
13 | 10 | import com.tcm.MineTale.recipe.WorkbenchRecipe; |
14 | 11 | import com.tcm.MineTale.registry.ModRecipeDisplay; |
15 | 12 |
|
@@ -46,28 +43,28 @@ public class WorkbenchRecipeBuilder implements RecipeBuilder { |
46 | 43 | private int cookTime = 200; |
47 | 44 | @Nullable private String group; |
48 | 45 |
|
49 | | - /** |
50 | | - * Creates a MapCodec that serializes and deserializes WorkbenchRecipe instances bound to the given recipe type and serializer. |
51 | | - * |
52 | | - * The codec encodes the recipe's ingredients, results, and cookTime (default 200) and constructs a WorkbenchRecipe using the provided type and serializer. |
53 | | - * |
54 | | - * @param type the RecipeType associated with the encoded WorkbenchRecipe |
55 | | - * @param serializer the RecipeSerializer used to (de)serialize the WorkbenchRecipe |
56 | | - * @return a MapCodec for WorkbenchRecipe that reads/writes ingredients, results, and cookTime and produces WorkbenchRecipe instances tied to the given type and serializer |
57 | | - */ |
58 | | -public static final MapCodec<WorkbenchRecipe> CODEC(RecipeType<WorkbenchRecipe> type, RecipeSerializer<WorkbenchRecipe> serializer) { |
59 | | - return RecordCodecBuilder.mapCodec(inst -> inst.group( |
60 | | - Ingredient.CODEC.listOf().fieldOf("ingredients").forGetter(WorkbenchRecipe::ingredients), |
61 | | - ItemStack.STRICT_CODEC.listOf().fieldOf("results").forGetter(WorkbenchRecipe::results), |
62 | | - Codec.INT.optionalFieldOf("cookTime", 200).forGetter(WorkbenchRecipe::cookTime), |
63 | | - // Updated to CraftingBookCategory codec |
64 | | - CraftingBookCategory.CODEC.optionalFieldOf("category", CraftingBookCategory.MISC).forGetter(WorkbenchRecipe::category), |
65 | | - Identifier.CODEC.fieldOf("book_category").forGetter(WorkbenchRecipe::bookCategory) |
66 | | - ).apply(inst, (ingredients, results, cookTime, category, bookCategory) -> |
67 | | - // 2. Pass the new bookCategory into the constructor |
68 | | - new WorkbenchRecipe(ingredients, results, cookTime, type, serializer, category, bookCategory) |
69 | | - )); |
70 | | - } |
| 46 | +// /** |
| 47 | +// * Creates a MapCodec that serializes and deserializes WorkbenchRecipe instances bound to the given recipe type and serializer. |
| 48 | +// * |
| 49 | +// * The codec encodes the recipe's ingredients, results, and cookTime (default 200) and constructs a WorkbenchRecipe using the provided type and serializer. |
| 50 | +// * |
| 51 | +// * @param type the RecipeType associated with the encoded WorkbenchRecipe |
| 52 | +// * @param serializer the RecipeSerializer used to (de)serialize the WorkbenchRecipe |
| 53 | +// * @return a MapCodec for WorkbenchRecipe that reads/writes ingredients, results, and cookTime and produces WorkbenchRecipe instances tied to the given type and serializer |
| 54 | +// */ |
| 55 | +// public static final MapCodec<WorkbenchRecipe> CODEC(RecipeType<WorkbenchRecipe> type, RecipeSerializer<WorkbenchRecipe> serializer) { |
| 56 | +// return RecordCodecBuilder.mapCodec(inst -> inst.group( |
| 57 | +// Ingredient.CODEC.listOf().fieldOf("ingredients").forGetter(WorkbenchRecipe::ingredients), |
| 58 | +// ItemStack.STRICT_CODEC.listOf().fieldOf("results").forGetter(WorkbenchRecipe::results), |
| 59 | +// Codec.INT.optionalFieldOf("cookTime", 200).forGetter(WorkbenchRecipe::cookTime), |
| 60 | +// // Updated to CraftingBookCategory codec |
| 61 | +// CraftingBookCategory.CODEC.optionalFieldOf("category", CraftingBookCategory.MISC).forGetter(WorkbenchRecipe::category), |
| 62 | +// Identifier.CODEC.fieldOf("book_category").forGetter(WorkbenchRecipe::bookCategory) |
| 63 | +// ).apply(inst, (ingredients, results, cookTime, category, bookCategory) -> |
| 64 | +// // 2. Pass the new bookCategory into the constructor |
| 65 | +// new WorkbenchRecipe(ingredients, results, cookTime, type, serializer, category, bookCategory) |
| 66 | +// )); |
| 67 | +// } |
71 | 68 |
|
72 | 69 | /** |
73 | 70 | * Create a new WorkbenchRecipeBuilder configured for a specific recipe type and its serializer. |
|
0 commit comments