mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-02 17:32:03 +01:00
SPIGOT-7528: Fix certain custom shaped recipes
By: md_5 <git@md-5.net>
This commit is contained in:
parent
dd8ca5c2dc
commit
58cbbcd51a
1 changed files with 10 additions and 3 deletions
|
@ -1,7 +1,7 @@
|
|||
package org.bukkit.craftbukkit.inventory;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||
|
@ -50,8 +50,15 @@ public class CraftShapedRecipe extends ShapedRecipe implements CraftRecipe {
|
|||
public void addToCraftingManager() {
|
||||
String[] shape = this.getShape();
|
||||
Map<Character, org.bukkit.inventory.RecipeChoice> ingred = this.getChoiceMap();
|
||||
Map<Character, RecipeItemStack> data = Maps.transformValues(ingred, (bukkit) -> toNMS(bukkit, false));
|
||||
int width = shape[0].length();
|
||||
NonNullList<RecipeItemStack> data = NonNullList.withSize(shape.length * width, RecipeItemStack.EMPTY);
|
||||
|
||||
MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new ShapedRecipes(this.getGroup(), CraftRecipe.getCategory(this.getCategory()), ShapedRecipePattern.of(data, shape), CraftItemStack.asNMSCopy(this.getResult()))));
|
||||
for (int i = 0; i < shape.length; i++) {
|
||||
String row = shape[i];
|
||||
for (int j = 0; j < row.length(); j++) {
|
||||
data.set(i * width + j, toNMS(ingred.get(row.charAt(j)), false));
|
||||
}
|
||||
}
|
||||
MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new ShapedRecipes(this.getGroup(), CraftRecipe.getCategory(this.getCategory()), new ShapedRecipePattern(width, shape.length, data, Optional.empty()), CraftItemStack.asNMSCopy(this.getResult()))));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue