SPIGOT-7924: Registering a ShapelessRecipe throws an IndexOutOfBoundsException

This commit is contained in:
md_5 2024-10-24 06:53:07 +11:00
parent 270be4863b
commit 7b5b63b222
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11

View File

@ -41,8 +41,8 @@ public class CraftShapelessRecipe extends ShapelessRecipe implements CraftRecipe
public void addToCraftingManager() { public void addToCraftingManager() {
List<org.bukkit.inventory.RecipeChoice> ingred = this.getChoiceList(); List<org.bukkit.inventory.RecipeChoice> ingred = this.getChoiceList();
List<RecipeItemStack> data = new ArrayList<>(ingred.size()); List<RecipeItemStack> data = new ArrayList<>(ingred.size());
for (int i = 0; i < ingred.size(); i++) { for (org.bukkit.inventory.RecipeChoice i : ingred) {
data.set(i, toNMS(ingred.get(i), true)); data.add(toNMS(i, true));
} }
MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftRecipe.toMinecraft(this.getKey()), new ShapelessRecipes(this.getGroup(), CraftRecipe.getCategory(this.getCategory()), CraftItemStack.asNMSCopy(this.getResult()), data))); MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftRecipe.toMinecraft(this.getKey()), new ShapelessRecipes(this.getGroup(), CraftRecipe.getCategory(this.getCategory()), CraftItemStack.asNMSCopy(this.getResult()), data)));