You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently developing a mod that uses a custom Codec to serialize and de-serialize recipes.
publicstaticfinalCodec<MapleSyrupRecipe> CODEC = RecordCodecBuilder.create(in -> in.group(
validateAmount(Ingredient.CODEC_NONEMPTY, 9).fieldOf("ingredients").forGetter(MapleSyrupRecipe::getIngredients),
ItemStack.ITEM_WITH_COUNT_CODEC.fieldOf("output").forGetter(r -> r.output)
).apply(in, MapleSyrupRecipe::new));
privatestaticCodec<List<Ingredient>> validateAmount(Codec<Ingredient> codec, intmax) {
returnExtraCodecs.validate(ExtraCodecs.validate(
codec.listOf(), list -> list.size() > max ? DataResult.error(() -> "Recipe has too many ingredients!") : DataResult.success(list)
), list -> list.isEmpty() ? DataResult.error(() -> "Recipe has no ingredients!") : DataResult.success(list));
}
I also know that there is a new MapCodec method in RecipeSerializer and packet codec method, and I don't know how to use these since the original method is Codec, not MapCodec.
How would I use and upgrade these from 1.20.4 -> 1.20.6?
Thanks!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Description
I'm currently developing a mod that uses a custom Codec to serialize and de-serialize recipes.
I also know that there is a new MapCodec method in RecipeSerializer and packet codec method, and I don't know how to use these since the original method is Codec, not MapCodec.
How would I use and upgrade these from 1.20.4 -> 1.20.6?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions