mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-22 17:07:34 +01:00
SPIGOT-5802: Add SmithingRecipe API
This commit is contained in:
parent
ab3875418c
commit
76d2add0bb
34
nms-patches/RecipeSmithing.patch
Normal file
34
nms-patches/RecipeSmithing.patch
Normal file
@ -0,0 +1,34 @@
|
||||
--- a/net/minecraft/server/RecipeSmithing.java
|
||||
+++ b/net/minecraft/server/RecipeSmithing.java
|
||||
@@ -2,6 +2,13 @@
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftRecipe;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftSmithingRecipe;
|
||||
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
+import org.bukkit.inventory.Recipe;
|
||||
+// CraftBukkit end
|
||||
|
||||
public class RecipeSmithing implements IRecipe<IInventory> {
|
||||
|
||||
@@ -58,6 +65,17 @@
|
||||
return Recipes.SMITHING;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Recipe toBukkitRecipe() {
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.c);
|
||||
+
|
||||
+ CraftSmithingRecipe recipe = new CraftSmithingRecipe(CraftNamespacedKey.fromMinecraft(this.d), result, CraftRecipe.toBukkit(this.a), CraftRecipe.toBukkit(this.b));
|
||||
+
|
||||
+ return recipe;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public static class a implements RecipeSerializer<RecipeSmithing> {
|
||||
|
||||
public a() {}
|
@ -0,0 +1,29 @@
|
||||
package org.bukkit.craftbukkit.inventory;
|
||||
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.RecipeChoice;
|
||||
import org.bukkit.inventory.SmithingRecipe;
|
||||
|
||||
public class CraftSmithingRecipe extends SmithingRecipe implements CraftRecipe {
|
||||
public CraftSmithingRecipe(NamespacedKey key, ItemStack result, RecipeChoice base, RecipeChoice addition) {
|
||||
super(key, result, base, addition);
|
||||
}
|
||||
|
||||
public static CraftSmithingRecipe fromBukkitRecipe(SmithingRecipe recipe) {
|
||||
if (recipe instanceof CraftSmithingRecipe) {
|
||||
return (CraftSmithingRecipe) recipe;
|
||||
}
|
||||
CraftSmithingRecipe ret = new CraftSmithingRecipe(recipe.getKey(), recipe.getResult(), recipe.getBase(), recipe.getAddition());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addToCraftingManager() {
|
||||
ItemStack result = this.getResult();
|
||||
|
||||
MinecraftServer.getServer().getCraftingManager().addRecipe(new net.minecraft.server.RecipeSmithing(CraftNamespacedKey.toMinecraft(this.getKey()), toNMS(this.getBase(), true), toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result)));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user