2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/ShapedRecipes.java
|
|
|
|
+++ b/net/minecraft/server/ShapedRecipes.java
|
2018-09-01 03:04:48 +02:00
|
|
|
@@ -13,6 +13,13 @@
|
2018-07-15 02:00:00 +02:00
|
|
|
import java.util.Iterator;
|
2017-05-14 04:00:00 +02:00
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map.Entry;
|
2014-11-25 22:32:16 +01:00
|
|
|
+// CraftBukkit start
|
2018-09-01 03:04:48 +02:00
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
|
|
|
+import org.bukkit.craftbukkit.inventory.CraftShapedRecipe;
|
2018-09-01 03:04:48 +02:00
|
|
|
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
2014-11-25 22:32:16 +01:00
|
|
|
+// CraftBukkit end
|
|
|
|
|
2017-05-30 13:25:59 +02:00
|
|
|
public class ShapedRecipes implements IRecipe {
|
2017-05-14 04:00:00 +02:00
|
|
|
|
2018-09-01 03:04:48 +02:00
|
|
|
@@ -32,6 +39,70 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
this.result = itemstack;
|
|
|
|
}
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ public org.bukkit.inventory.ShapedRecipe toBukkitRecipe() {
|
|
|
|
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
|
|
|
+ CraftShapedRecipe recipe = new CraftShapedRecipe(result, this);
|
2018-08-26 04:00:00 +02:00
|
|
|
+ recipe.setGroup(this.group);
|
2018-08-17 12:40:54 +02:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ 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) {
|
2018-07-15 02:00:00 +02:00
|
|
|
+ list.buildChoices();
|
|
|
|
+ if (list.choices.length > 0) {
|
2018-09-01 03:04:48 +02:00
|
|
|
+ List<org.bukkit.Material> choices = new ArrayList<>(list.choices.length);
|
|
|
|
+ for (ItemStack i : list.choices) {
|
|
|
|
+ choices.add(CraftMagicNumbers.getMaterial(i.getItem()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ recipe.setIngredient(c, new org.bukkit.inventory.RecipeChoice.MaterialChoice(choices));
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ c++;
|
|
|
|
+ }
|
|
|
|
+ return recipe;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2018-07-15 02:00:00 +02:00
|
|
|
public MinecraftKey getKey() {
|
2018-08-26 04:00:00 +02:00
|
|
|
return this.key;
|
2018-07-15 02:00:00 +02:00
|
|
|
}
|