74 lines
2.4 KiB
Java
74 lines
2.4 KiB
Java
/*
|
|
* 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<? extends CustomRecipe> getSerializer();
|
|
|
|
public static class Serializer<T extends CraftingRecipe>
|
|
implements RecipeSerializer<T> {
|
|
private final MapCodec<T> 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<RegistryFriendlyByteBuf, T> streamCodec = StreamCodec.composite(CraftingBookCategory.STREAM_CODEC, CraftingRecipe::category, constructor::create);
|
|
|
|
public Serializer(Factory<T> constructor) {
|
|
}
|
|
|
|
@Override
|
|
public MapCodec<T> codec() {
|
|
return this.codec;
|
|
}
|
|
|
|
@Override
|
|
public StreamCodec<RegistryFriendlyByteBuf, T> streamCodec() {
|
|
return this.streamCodec;
|
|
}
|
|
|
|
@FunctionalInterface
|
|
public static interface Factory<T extends CraftingRecipe> {
|
|
public T create(CraftingBookCategory var1);
|
|
}
|
|
}
|
|
}
|
|
|