mirror of
https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git
synced 2024-11-22 10:06:16 +00:00
55 lines
2.5 KiB
Diff
55 lines
2.5 KiB
Diff
--- a/net/minecraft/world/item/crafting/IRecipeComplex.java
|
|
+++ b/net/minecraft/world/item/crafting/IRecipeComplex.java
|
|
@@ -8,6 +8,15 @@
|
|
import net.minecraft.network.RegistryFriendlyByteBuf;
|
|
import net.minecraft.network.codec.StreamCodec;
|
|
|
|
+// CraftBukkit start
|
|
+import net.minecraft.world.item.ItemStack;
|
|
+import org.bukkit.NamespacedKey;
|
|
+import org.bukkit.craftbukkit.inventory.CraftComplexRecipe;
|
|
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
|
+import org.bukkit.craftbukkit.inventory.CraftRecipe;
|
|
+import org.bukkit.inventory.Recipe;
|
|
+// CraftBukkit end
|
|
+
|
|
public abstract class IRecipeComplex implements RecipeCrafting {
|
|
|
|
private final CraftingBookCategory category;
|
|
@@ -34,6 +43,19 @@
|
|
@Override
|
|
public abstract RecipeSerializer<? extends IRecipeComplex> getSerializer();
|
|
|
|
+ // CraftBukkit start
|
|
+ @Override
|
|
+ public Recipe toBukkitRecipe(NamespacedKey id) {
|
|
+ CraftItemStack result = CraftItemStack.asCraftMirror(ItemStack.EMPTY);
|
|
+
|
|
+ CraftComplexRecipe recipe = new CraftComplexRecipe(id, result, this);
|
|
+ recipe.setGroup(this.group());
|
|
+ recipe.setCategory(CraftRecipe.getCategory(this.category()));
|
|
+
|
|
+ return recipe;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
+
|
|
public static class Serializer<T extends RecipeCrafting> implements RecipeSerializer<T> {
|
|
|
|
private final MapCodec<T> codec;
|
|
@@ -41,13 +63,13 @@
|
|
|
|
public Serializer(IRecipeComplex.Serializer.Factory<T> irecipecomplex_serializer_factory) {
|
|
this.codec = RecordCodecBuilder.mapCodec((instance) -> {
|
|
- P1 p1 = instance.group(CraftingBookCategory.CODEC.fieldOf("category").orElse(CraftingBookCategory.MISC).forGetter(RecipeCrafting::category));
|
|
+ P1<RecordCodecBuilder.Mu<T>, CraftingBookCategory> p1 = instance.group(CraftingBookCategory.CODEC.fieldOf("category").orElse(CraftingBookCategory.MISC).forGetter(RecipeCrafting::category)); // CraftBukkit - decompile error
|
|
|
|
Objects.requireNonNull(irecipecomplex_serializer_factory);
|
|
return p1.apply(instance, irecipecomplex_serializer_factory::create);
|
|
});
|
|
StreamCodec streamcodec = CraftingBookCategory.STREAM_CODEC;
|
|
- Function function = RecipeCrafting::category;
|
|
+ Function<RecipeCrafting, CraftingBookCategory> function = RecipeCrafting::category; // CraftBukkit - decompile error
|
|
|
|
Objects.requireNonNull(irecipecomplex_serializer_factory);
|
|
this.streamCodec = StreamCodec.composite(streamcodec, function, irecipecomplex_serializer_factory::create);
|