Map old wildcard recipe data to new 1.5 value. Fixes BUKKIT-3849

By: Travis Watkins <amaranth@ubuntu.com>
This commit is contained in:
Bukkit/Spigot 2013-03-21 21:03:30 -05:00
parent d347286b22
commit 0dc86a08f3
2 changed files with 11 additions and 0 deletions

View file

@ -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;
}

View file

@ -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));
}