Fix unbound shaped recipe ingredients

This commit is contained in:
md_5 2018-09-01 14:12:20 +10:00
parent 4c219e2a12
commit dc69d2b3db

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.inventory;
import net.minecraft.server.RecipeItemStack;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.RecipeChoice;
@ -9,8 +10,10 @@ public interface CraftRecipe extends Recipe {
void addToCraftingManager();
default net.minecraft.server.RecipeItemStack toNMS(RecipeChoice bukkit) {
if (bukkit instanceof RecipeChoice.MaterialChoice) {
return new net.minecraft.server.RecipeItemStack(((RecipeChoice.MaterialChoice) bukkit).getChoices().stream().map((mat) -> new net.minecraft.server.RecipeItemStack.StackProvider(CraftItemStack.asNMSCopy(new ItemStack(mat)))));
if (bukkit == null) {
return RecipeItemStack.a;
} else if (bukkit instanceof RecipeChoice.MaterialChoice) {
return new RecipeItemStack(((RecipeChoice.MaterialChoice) bukkit).getChoices().stream().map((mat) -> new net.minecraft.server.RecipeItemStack.StackProvider(CraftItemStack.asNMSCopy(new ItemStack(mat)))));
} else {
throw new IllegalArgumentException("Unknown recipe stack instance " + bukkit);
}