SPIGOT-5802: Add SmithingRecipe API

Dieser Commit ist enthalten in:
md_5 2020-06-25 12:41:55 +10:00
Ursprung ab3875418c
Commit 76d2add0bb
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: E8E901AC7C617C11
2 geänderte Dateien mit 63 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -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() {}

Datei anzeigen

@ -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)));
}
}