geforkt von Mirrors/Paper
[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.
Dieser Commit ist enthalten in:
Ursprung
b8143c63c2
Commit
fef9f9692f
@ -80,7 +80,7 @@ public class RecipesFurnace {
|
|||||||
do {
|
do {
|
||||||
if (!iterator.hasNext()) {
|
if (!iterator.hasNext()) {
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
if (!vanilla) {
|
if (!vanilla && recipes.size() != 0) {
|
||||||
iterator = this.recipes.entrySet().iterator();
|
iterator = this.recipes.entrySet().iterator();
|
||||||
vanilla = true;
|
vanilla = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -10,20 +10,18 @@ import net.minecraft.server.RecipesFurnace;
|
|||||||
|
|
||||||
public class RecipeIterator implements Iterator<Recipe> {
|
public class RecipeIterator implements Iterator<Recipe> {
|
||||||
private final Iterator<IRecipe> recipes;
|
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;
|
private Iterator<?> removeFrom = null;
|
||||||
|
|
||||||
public RecipeIterator() {
|
public RecipeIterator() {
|
||||||
this.recipes = CraftingManager.getInstance().getRecipes().iterator();
|
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() {
|
public boolean hasNext() {
|
||||||
if (recipes.hasNext()) {
|
return recipes.hasNext() || smeltingCustom.hasNext() || smeltingVanilla.hasNext();
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return smelting.hasNext();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Recipe next() {
|
public Recipe next() {
|
||||||
@ -31,8 +29,15 @@ public class RecipeIterator implements Iterator<Recipe> {
|
|||||||
removeFrom = recipes;
|
removeFrom = recipes;
|
||||||
return recipes.next().toBukkitRecipe();
|
return recipes.next().toBukkitRecipe();
|
||||||
} else {
|
} else {
|
||||||
removeFrom = smelting;
|
net.minecraft.server.ItemStack item;
|
||||||
net.minecraft.server.ItemStack item = smelting.next();
|
if (smeltingCustom.hasNext()) {
|
||||||
|
removeFrom = smeltingCustom;
|
||||||
|
item = smeltingCustom.next();
|
||||||
|
} else {
|
||||||
|
removeFrom = smeltingVanilla;
|
||||||
|
item = smeltingVanilla.next();
|
||||||
|
}
|
||||||
|
|
||||||
CraftItemStack stack = CraftItemStack.asCraftMirror(RecipesFurnace.getInstance().getResult(item));
|
CraftItemStack stack = CraftItemStack.asCraftMirror(RecipesFurnace.getInstance().getResult(item));
|
||||||
|
|
||||||
return new CraftFurnaceRecipe(stack, CraftItemStack.asCraftMirror(item));
|
return new CraftFurnaceRecipe(stack, CraftItemStack.asCraftMirror(item));
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren