PaperMC/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeHolder.patch

23 lines
906 B
Diff
Raw Normal View History

--- a/net/minecraft/world/item/crafting/RecipeHolder.java
+++ b/net/minecraft/world/item/crafting/RecipeHolder.java
@@ -4,8 +4,19 @@
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.resources.MinecraftKey;
+// CraftBukkit start
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
+import org.bukkit.inventory.Recipe;
+// CraftBukkit end
+
public record RecipeHolder<T extends IRecipe<?>>(MinecraftKey id, T value) {
+ // CraftBukkit start
+ public final Recipe toBukkitRecipe() {
+ return this.value.toBukkitRecipe(CraftNamespacedKey.fromMinecraft(this.id));
+ }
+ // CraftBukkit end
+
public static final StreamCodec<RegistryFriendlyByteBuf, RecipeHolder<?>> STREAM_CODEC = StreamCodec.composite(MinecraftKey.STREAM_CODEC, RecipeHolder::id, IRecipe.STREAM_CODEC, RecipeHolder::value, RecipeHolder::new);
public boolean equals(Object object) {