0
0
mirror of https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git synced 2024-11-25 15:06:14 +00:00
craftbukkit/nms-patches/net/minecraft/world/item/crafting/RecipeHolder.patch
2024-10-23 02:15:00 +11:00

23 lines
944 B
Diff

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