From 0dc86a08f3820dd06a51d207a6e106801eba7513 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Thu, 21 Mar 2013 21:03:30 -0500 Subject: [PATCH] Map old wildcard recipe data to new 1.5 value. Fixes BUKKIT-3849 By: Travis Watkins --- .../src/main/java/org/bukkit/inventory/ShapedRecipe.java | 6 ++++++ .../src/main/java/org/bukkit/inventory/ShapelessRecipe.java | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/inventory/ShapedRecipe.java b/paper-api/src/main/java/org/bukkit/inventory/ShapedRecipe.java index 4d057ae089..9156621ff8 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/ShapedRecipe.java +++ b/paper-api/src/main/java/org/bukkit/inventory/ShapedRecipe.java @@ -96,6 +96,12 @@ public class ShapedRecipe implements Recipe { */ public ShapedRecipe setIngredient(char key, Material ingredient, int raw) { Validate.isTrue(ingredients.containsKey(key), "Symbol does not appear in the shape:", key); + + // -1 is the old wildcard, map to Short.MAX_VALUE as the new one + if (raw == -1) { + raw = Short.MAX_VALUE; + } + ingredients.put(key, new ItemStack(ingredient, 1, (short) raw)); return this; } diff --git a/paper-api/src/main/java/org/bukkit/inventory/ShapelessRecipe.java b/paper-api/src/main/java/org/bukkit/inventory/ShapelessRecipe.java index 2263043fcd..c296e3a284 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/ShapelessRecipe.java +++ b/paper-api/src/main/java/org/bukkit/inventory/ShapelessRecipe.java @@ -97,6 +97,11 @@ public class ShapelessRecipe implements Recipe { public ShapelessRecipe addIngredient(int count, Material ingredient, int rawdata) { Validate.isTrue(ingredients.size() + count <= 9, "Shapeless recipes cannot have more than 9 ingredients"); + // -1 is the old wildcard, map to Short.MAX_VALUE as the new one + if (rawdata == -1) { + rawdata = Short.MAX_VALUE; + } + while (count-- > 0) { ingredients.add(new ItemStack(ingredient, 1, (short) rawdata)); }