SPIGOT-7922: ExactChoice recipe fails to be added

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2024-10-23 19:38:39 +11:00
parent cd2a2a27ff
commit adbb925fc4
2 changed files with 4 additions and 4 deletions

View file

@ -16,9 +16,9 @@
+ return this.itemStacks;
+ }
+
+ public static RecipeItemStack ofStacks(Stream<ItemStack> stacks) {
+ RecipeItemStack recipe = RecipeItemStack.of(stacks.map(ItemStack::getItem));
+ recipe.itemStacks = stacks.toList();
+ public static RecipeItemStack ofStacks(List<ItemStack> stacks) {
+ RecipeItemStack recipe = RecipeItemStack.of(stacks.stream().map(ItemStack::getItem));
+ recipe.itemStacks = stacks;
+ return recipe;
+ }
+ // CraftBukkit end

View file

@ -33,7 +33,7 @@ public interface CraftRecipe extends Recipe {
} else if (bukkit instanceof RecipeChoice.MaterialChoice) {
stack = RecipeItemStack.of(((RecipeChoice.MaterialChoice) bukkit).getChoices().stream().map((mat) -> CraftItemType.bukkitToMinecraft(mat)));
} else if (bukkit instanceof RecipeChoice.ExactChoice) {
stack = RecipeItemStack.ofStacks(((RecipeChoice.ExactChoice) bukkit).getChoices().stream().map((mat) -> CraftItemStack.asNMSCopy(mat)));
stack = RecipeItemStack.ofStacks(((RecipeChoice.ExactChoice) bukkit).getChoices().stream().map((mat) -> CraftItemStack.asNMSCopy(mat)).toList());
} else {
throw new IllegalArgumentException("Unknown recipe stack instance " + bukkit);
}