mirror of
https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git
synced 2024-11-22 11:16:17 +00:00
87 lines
2.7 KiB
Diff
87 lines
2.7 KiB
Diff
--- a/net/minecraft/world/item/crafting/ShapedRecipes.java
|
|
+++ b/net/minecraft/world/item/crafting/ShapedRecipes.java
|
|
@@ -17,6 +17,14 @@
|
|
import net.minecraft.world.item.crafting.display.SlotDisplay;
|
|
import net.minecraft.world.level.World;
|
|
|
|
+// CraftBukkit start
|
|
+import org.bukkit.NamespacedKey;
|
|
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
|
+import org.bukkit.craftbukkit.inventory.CraftRecipe;
|
|
+import org.bukkit.craftbukkit.inventory.CraftShapedRecipe;
|
|
+import org.bukkit.inventory.RecipeChoice;
|
|
+// CraftBukkit end
|
|
+
|
|
public class ShapedRecipes implements RecipeCrafting {
|
|
|
|
final ShapedRecipePattern pattern;
|
|
@@ -39,6 +47,68 @@
|
|
this(s, craftingbookcategory, shapedrecipepattern, itemstack, true);
|
|
}
|
|
|
|
+ // CraftBukkit start
|
|
+ @Override
|
|
+ public org.bukkit.inventory.ShapedRecipe toBukkitRecipe(NamespacedKey id) {
|
|
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
|
+ CraftShapedRecipe recipe = new CraftShapedRecipe(id, result, this);
|
|
+ recipe.setGroup(this.group);
|
|
+ recipe.setCategory(CraftRecipe.getCategory(this.category()));
|
|
+
|
|
+ switch (this.pattern.height()) {
|
|
+ case 1:
|
|
+ switch (this.pattern.width()) {
|
|
+ case 1:
|
|
+ recipe.shape("a");
|
|
+ break;
|
|
+ case 2:
|
|
+ recipe.shape("ab");
|
|
+ break;
|
|
+ case 3:
|
|
+ recipe.shape("abc");
|
|
+ break;
|
|
+ }
|
|
+ break;
|
|
+ case 2:
|
|
+ switch (this.pattern.width()) {
|
|
+ case 1:
|
|
+ recipe.shape("a","b");
|
|
+ break;
|
|
+ case 2:
|
|
+ recipe.shape("ab","cd");
|
|
+ break;
|
|
+ case 3:
|
|
+ recipe.shape("abc","def");
|
|
+ break;
|
|
+ }
|
|
+ break;
|
|
+ case 3:
|
|
+ switch (this.pattern.width()) {
|
|
+ case 1:
|
|
+ recipe.shape("a","b","c");
|
|
+ break;
|
|
+ case 2:
|
|
+ recipe.shape("ab","cd","ef");
|
|
+ break;
|
|
+ case 3:
|
|
+ recipe.shape("abc","def","ghi");
|
|
+ break;
|
|
+ }
|
|
+ break;
|
|
+ }
|
|
+ char c = 'a';
|
|
+ for (Optional<RecipeItemStack> list : this.pattern.ingredients()) {
|
|
+ RecipeChoice choice = CraftRecipe.toBukkit(list);
|
|
+ if (choice != null) {
|
|
+ recipe.setIngredient(c, choice);
|
|
+ }
|
|
+
|
|
+ c++;
|
|
+ }
|
|
+ return recipe;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
+
|
|
@Override
|
|
public RecipeSerializer<? extends ShapedRecipes> getSerializer() {
|
|
return RecipeSerializer.SHAPED_RECIPE;
|