mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-10 12:02:36 +01:00
43702a9e10
By: md_5 <git@md-5.net>
83 lines
2.3 KiB
Diff
83 lines
2.3 KiB
Diff
--- a/net/minecraft/world/item/crafting/ShapedRecipes.java
|
|
+++ b/net/minecraft/world/item/crafting/ShapedRecipes.java
|
|
@@ -23,6 +23,13 @@
|
|
import net.minecraft.world.item.Items;
|
|
import net.minecraft.world.level.World;
|
|
|
|
+// CraftBukkit start
|
|
+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 int width;
|
|
@@ -41,6 +48,66 @@
|
|
this.result = itemstack;
|
|
}
|
|
|
|
+ // CraftBukkit start
|
|
+ public org.bukkit.inventory.ShapedRecipe toBukkitRecipe() {
|
|
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
|
+ CraftShapedRecipe recipe = new CraftShapedRecipe(result, this);
|
|
+ recipe.setGroup(this.group);
|
|
+
|
|
+ switch (this.height) {
|
|
+ case 1:
|
|
+ switch (this.width) {
|
|
+ case 1:
|
|
+ recipe.shape("a");
|
|
+ break;
|
|
+ case 2:
|
|
+ recipe.shape("ab");
|
|
+ break;
|
|
+ case 3:
|
|
+ recipe.shape("abc");
|
|
+ break;
|
|
+ }
|
|
+ break;
|
|
+ case 2:
|
|
+ switch (this.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.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 (RecipeItemStack list : this.recipeItems) {
|
|
+ RecipeChoice choice = CraftRecipe.toBukkit(list);
|
|
+ if (choice != null) {
|
|
+ recipe.setIngredient(c, choice);
|
|
+ }
|
|
+
|
|
+ c++;
|
|
+ }
|
|
+ return recipe;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
+
|
|
@Override
|
|
public MinecraftKey getId() {
|
|
return this.id;
|