[Bleeding] Recipe API improvements and fixes. Addresses BUKKIT-738 and BUKKIT-624
Add a recipe iterator to make it possible to retrieve and remove recipes (BUKKIT-738), and updated the recipe classes to not clip the data to 127 (BUKKIT-624)
This commit is contained in:
committed by
EvilSeph
parent
84ecdb5439
commit
326091c130
@@ -1,5 +1,11 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.inventory.CraftShapedRecipe;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
// CraftBukkit end
|
||||
|
||||
public class ShapedRecipes implements CraftingRecipe {
|
||||
|
||||
private int b;
|
||||
@@ -16,6 +22,62 @@ public class ShapedRecipes implements CraftingRecipe {
|
||||
this.e = itemstack;
|
||||
}
|
||||
|
||||
// CraftBukkit start
|
||||
public ShapedRecipe toBukkitRecipe() {
|
||||
CraftItemStack result = new CraftItemStack(this.e);
|
||||
CraftShapedRecipe recipe = new CraftShapedRecipe(result, this);
|
||||
switch (this.b) {
|
||||
case 1:
|
||||
switch (this.c) {
|
||||
case 1:
|
||||
recipe.shape("a");
|
||||
break;
|
||||
case 2:
|
||||
recipe.shape("ab");
|
||||
break;
|
||||
case 3:
|
||||
recipe.shape("abc");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
switch (this.c) {
|
||||
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.c) {
|
||||
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';
|
||||
for (ItemStack stack : this.d) {
|
||||
if (stack != null) {
|
||||
recipe.setIngredient(c, org.bukkit.Material.getMaterial(stack.id), stack.getData());
|
||||
}
|
||||
c++;
|
||||
}
|
||||
return recipe;
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
public ItemStack b() {
|
||||
return this.e;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user