aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0171-Add-ItemStack-Recipe-API-helper-methods.patch
diff options
context:
space:
mode:
authorJake <[email protected]>2021-11-23 17:53:24 -0800
committerMiniDigger | Martin <[email protected]>2021-11-30 19:26:33 +0100
commit753267a57ebd3ae0ad534119e21364b5d8aa56c7 (patch)
tree4fa022e6c19fbfedce0308cdc65bae04582703a0 /patches/api/0171-Add-ItemStack-Recipe-API-helper-methods.patch
parentd9c1c30c58ecc5ef981599ccc219fdf555378206 (diff)
downloadPaper-753267a57ebd3ae0ad534119e21364b5d8aa56c7.tar.gz
Paper-753267a57ebd3ae0ad534119e21364b5d8aa56c7.zip
and here's some more patches
Diffstat (limited to 'patches/api/0171-Add-ItemStack-Recipe-API-helper-methods.patch')
-rw-r--r--patches/api/0171-Add-ItemStack-Recipe-API-helper-methods.patch70
1 files changed, 70 insertions, 0 deletions
diff --git a/patches/api/0171-Add-ItemStack-Recipe-API-helper-methods.patch b/patches/api/0171-Add-ItemStack-Recipe-API-helper-methods.patch
new file mode 100644
index 0000000000..9b2dfc0c72
--- /dev/null
+++ b/patches/api/0171-Add-ItemStack-Recipe-API-helper-methods.patch
@@ -0,0 +1,70 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Aikar <[email protected]>
+Date: Tue, 28 Jan 2014 19:13:57 -0500
+Subject: [PATCH] Add ItemStack Recipe API helper methods
+
+Allows using ExactChoice Recipes with easier methodss
+
+diff --git a/src/main/java/org/bukkit/inventory/ShapedRecipe.java b/src/main/java/org/bukkit/inventory/ShapedRecipe.java
+index d742c4058ba9aed4fbe1591fd755a06608b06e98..222a12baa8e93ad686ab59426653f066d5876e38 100644
+--- a/src/main/java/org/bukkit/inventory/ShapedRecipe.java
++++ b/src/main/java/org/bukkit/inventory/ShapedRecipe.java
+@@ -145,6 +145,13 @@ public class ShapedRecipe implements Recipe, Keyed {
+ return this;
+ }
+
++ // Paper start
++ @NotNull
++ public ShapedRecipe setIngredient(char key, @NotNull ItemStack item) {
++ return setIngredient(key, new RecipeChoice.ExactChoice(item));
++ }
++ // Paper end
++
+ /**
+ * Get a copy of the ingredients map.
+ *
+diff --git a/src/main/java/org/bukkit/inventory/ShapelessRecipe.java b/src/main/java/org/bukkit/inventory/ShapelessRecipe.java
+index 84062dd719cb8a6142dc8c806777cb208c6b42b2..7f6d3c71c5b3a9aa54c84a4c3b7c3614a0d477ce 100644
+--- a/src/main/java/org/bukkit/inventory/ShapelessRecipe.java
++++ b/src/main/java/org/bukkit/inventory/ShapelessRecipe.java
+@@ -143,6 +143,40 @@ public class ShapelessRecipe implements Recipe, Keyed {
+ return this;
+ }
+
++ // Paper start
++ @NotNull
++ public ShapelessRecipe addIngredient(@NotNull ItemStack item) {
++ return addIngredient(item.getAmount(), item);
++ }
++
++ @NotNull
++ public ShapelessRecipe addIngredient(int count, @NotNull ItemStack item) {
++ Validate.isTrue(ingredients.size() + count <= 9, "Shapeless recipes cannot have more than 9 ingredients");
++ while (count-- > 0) {
++ ingredients.add(new RecipeChoice.ExactChoice(item));
++ }
++ return this;
++ }
++
++ @NotNull
++ public ShapelessRecipe removeIngredient(@NotNull ItemStack item) {
++ return removeIngredient(1, item);
++ }
++
++ @NotNull
++ public ShapelessRecipe removeIngredient(int count, @NotNull ItemStack item) {
++ Iterator<RecipeChoice> iterator = ingredients.iterator();
++ while (count > 0 && iterator.hasNext()) {
++ ItemStack stack = iterator.next().getItemStack();
++ if (stack.equals(item)) {
++ iterator.remove();
++ count--;
++ }
++ }
++ return this;
++ }
++ // Paper end
++
+ /**
+ * Removes an ingredient from the list.
+ *