Add RecipeChoice.ExactChoice API for NBT matches on ingredients

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2019-01-02 15:56:21 +11:00
parent 1336c4afb9
commit 5aff480181
5 changed files with 71 additions and 32 deletions

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/ShapedRecipes.java
+++ b/net/minecraft/server/ShapedRecipes.java
@@ -12,6 +12,13 @@
@@ -12,6 +12,15 @@
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
@@ -8,13 +8,15 @@
+import java.util.ArrayList;
+import java.util.List;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.craftbukkit.inventory.CraftRecipe;
+import org.bukkit.craftbukkit.inventory.CraftShapedRecipe;
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
+import org.bukkit.inventory.RecipeChoice;
+// CraftBukkit end
public class ShapedRecipes implements IRecipe {
@@ -31,6 +38,70 @@
@@ -31,6 +40,66 @@
this.result = itemstack;
}
@@ -67,15 +69,11 @@
+ }
+ char c = 'a';
+ for (RecipeItemStack list : this.items) {
+ list.buildChoices();
+ if (list.choices.length > 0) {
+ 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));
+ RecipeChoice choice = CraftRecipe.toBukkit(list);
+ if (choice != null) {
+ recipe.setIngredient(c, choice);
+ }
+
+ c++;
+ }
+ return recipe;