3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-16 04:50:05 +01:00
Paper/nms-patches/ShapedRecipes.patch

78 Zeilen
2.2 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/ShapedRecipes.java
+++ b/net/minecraft/server/ShapedRecipes.java
2017-05-14 04:00:00 +02:00
@@ -12,6 +12,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
2017-05-14 04:00:00 +02:00
public class ShapedRecipes extends IRecipe {
@@ -28,6 +32,63 @@
this.result = itemstack;
}
2015-02-26 23:41:06 +01:00
+ // 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';
2017-05-14 04:00:00 +02:00
+ 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()), stack.getData());
+ }
+ c++;
+ }
+ return recipe;
+ }
+ // CraftBukkit end
2015-02-26 23:41:06 +01:00
+
public ItemStack b() {
return this.result;
2016-11-17 02:41:03 +01:00
}