diff options
author | t00thpick1 <t00thpick1dirko@gmail.com> | 2014-01-05 00:41:06 -0500 |
---|---|---|
committer | feildmaster <admin@feildmaster.com> | 2014-01-18 15:52:22 -0600 |
commit | fef9f9692f5f5e494910e81af7ffd677c3e3e0f9 (patch) | |
tree | ceb2c4139424bff51fdd1048aaa9e00b5911649f /src/main/java/org | |
parent | b8143c63c20b6d578a77edc84a5049323e3bf567 (diff) | |
download | craftbukkit-fef9f9692f5f5e494910e81af7ffd677c3e3e0f9.tar craftbukkit-fef9f9692f5f5e494910e81af7ffd677c3e3e0f9.tar.gz craftbukkit-fef9f9692f5f5e494910e81af7ffd677c3e3e0f9.tar.lz craftbukkit-fef9f9692f5f5e494910e81af7ffd677c3e3e0f9.tar.xz craftbukkit-fef9f9692f5f5e494910e81af7ffd677c3e3e0f9.zip |
[Bleeding] Check that vanilla recipes actually exist. Fixes BUKKIT-5277
When falling back to vanilla recipes in the iteration of recipes,
a check is necessary to ensure that vanilla recipes are present.
RecipeIterator has been modified to account for the multi-map setup.
Diffstat (limited to 'src/main/java/org')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java b/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java index 568b2d08..53b53b79 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java @@ -10,20 +10,18 @@ import net.minecraft.server.RecipesFurnace; public class RecipeIterator implements Iterator<Recipe> { private final Iterator<IRecipe> recipes; - private final Iterator<net.minecraft.server.ItemStack> smelting; + private final Iterator<net.minecraft.server.ItemStack> smeltingCustom; + private final Iterator<net.minecraft.server.ItemStack> smeltingVanilla; private Iterator<?> removeFrom = null; public RecipeIterator() { this.recipes = CraftingManager.getInstance().getRecipes().iterator(); - this.smelting = RecipesFurnace.getInstance().getRecipes().keySet().iterator(); + this.smeltingCustom = RecipesFurnace.getInstance().customRecipes.keySet().iterator(); + this.smeltingVanilla = RecipesFurnace.getInstance().recipes.keySet().iterator(); } public boolean hasNext() { - if (recipes.hasNext()) { - return true; - } else { - return smelting.hasNext(); - } + return recipes.hasNext() || smeltingCustom.hasNext() || smeltingVanilla.hasNext(); } public Recipe next() { @@ -31,8 +29,15 @@ public class RecipeIterator implements Iterator<Recipe> { removeFrom = recipes; return recipes.next().toBukkitRecipe(); } else { - removeFrom = smelting; - net.minecraft.server.ItemStack item = smelting.next(); + net.minecraft.server.ItemStack item; + if (smeltingCustom.hasNext()) { + removeFrom = smeltingCustom; + item = smeltingCustom.next(); + } else { + removeFrom = smeltingVanilla; + item = smeltingVanilla.next(); + } + CraftItemStack stack = CraftItemStack.asCraftMirror(RecipesFurnace.getInstance().getResult(item)); return new CraftFurnaceRecipe(stack, CraftItemStack.asCraftMirror(item)); |