Archiviert
13
0
Dieses Repository wurde am 2024-12-25 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
Paper-Old/nms-patches/ShapedRecipes.patch

93 Zeilen
2.7 KiB
Diff

--- a/net/minecraft/server/ShapedRecipes.java
+++ b/net/minecraft/server/ShapedRecipes.java
@@ -14,6 +14,10 @@
import java.util.Map;
import java.util.Map.Entry;
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.craftbukkit.inventory.CraftShapedRecipe;
+// CraftBukkit end
public class ShapedRecipes implements IRecipe {
@@ -22,6 +26,14 @@
private final NonNullList<RecipeItemStack> items;
private final ItemStack result;
private final String e;
+ // CraftBukkit start
+ public MinecraftKey key;
+
+ @Override
+ public void setKey(MinecraftKey key) {
+ this.key = key;
+ }
+ // CraftBukkit end
public ShapedRecipes(String s, int i, int j, NonNullList<RecipeItemStack> nonnulllist, ItemStack itemstack) {
this.e = s;
@@ -31,6 +43,63 @@
this.result = itemstack;
}
+ // CraftBukkit start
+ public org.bukkit.inventory.ShapedRecipe toBukkitRecipe() {
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
+ CraftShapedRecipe recipe = new CraftShapedRecipe(result, this);
+ switch (this.height) {
+ case 1:
+ switch (this.width) {
+ case 1:
+ recipe.shape("a");
+ break;
+ case 2:
+ recipe.shape("ab");
+ break;
+ case 3:
+ recipe.shape("abc");
+ break;
+ }
+ break;
+ case 2:
+ switch (this.width) {
+ case 1:
+ recipe.shape("a","b");
+ break;
+ case 2:
+ recipe.shape("ab","cd");
+ break;
+ case 3:
+ recipe.shape("abc","def");
+ break;
+ }
+ break;
+ case 3:
+ switch (this.width) {
+ case 1:
+ recipe.shape("a","b","c");
+ break;
+ case 2:
+ recipe.shape("ab","cd","ef");
+ break;
+ case 3:
+ recipe.shape("abc","def","ghi");
+ break;
+ }
+ break;
+ }
+ char c = 'a';
+ for (RecipeItemStack list : this.items) {
+ if (list != null && list.choices.length > 0) {
+ net.minecraft.server.ItemStack stack = list.choices[0];
+ recipe.setIngredient(c, org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(stack.getItem()), (list.choices.length) > 1 ? 32767 : stack.getData());
+ }
+ c++;
+ }
+ return recipe;
+ }
+ // CraftBukkit end
+
public ItemStack b() {
return this.result;
}