/* * Decompiled with CFR 0.152. * * Could not load the following classes: * com.mojang.datafixers.kinds.App * com.mojang.datafixers.kinds.Applicative * com.mojang.serialization.MapCodec * com.mojang.serialization.codecs.RecordCodecBuilder */ package net.minecraft.world.item.crafting; import com.mojang.datafixers.kinds.App; import com.mojang.datafixers.kinds.Applicative; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; import net.minecraft.world.item.crafting.CraftingBookCategory; import net.minecraft.world.item.crafting.CraftingRecipe; import net.minecraft.world.item.crafting.PlacementInfo; import net.minecraft.world.item.crafting.RecipeSerializer; public abstract class CustomRecipe implements CraftingRecipe { private final CraftingBookCategory category; public CustomRecipe(CraftingBookCategory category) { this.category = category; } @Override public boolean isSpecial() { return true; } @Override public CraftingBookCategory category() { return this.category; } @Override public PlacementInfo placementInfo() { return PlacementInfo.NOT_PLACEABLE; } @Override public abstract RecipeSerializer getSerializer(); public static class Serializer implements RecipeSerializer { private final MapCodec codec = RecordCodecBuilder.mapCodec(r -> r.group((App)CraftingBookCategory.CODEC.fieldOf("category").orElse((Object)CraftingBookCategory.MISC).forGetter(CraftingRecipe::category)).apply((Applicative)r, constructor::create)); private final StreamCodec streamCodec = StreamCodec.composite(CraftingBookCategory.STREAM_CODEC, CraftingRecipe::category, constructor::create); public Serializer(Factory constructor) { } @Override public MapCodec codec() { return this.codec; } @Override public StreamCodec streamCodec() { return this.streamCodec; } @FunctionalInterface public static interface Factory { public T create(CraftingBookCategory var1); } } }