2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/item/crafting/ShapedRecipes.java
|
|
|
|
+++ b/net/minecraft/world/item/crafting/ShapedRecipes.java
|
2024-04-23 17:15:00 +02:00
|
|
|
@@ -11,6 +11,14 @@
|
2023-12-05 17:40:00 +01:00
|
|
|
import net.minecraft.world.item.ItemStack;
|
2021-03-15 23:00:00 +01:00
|
|
|
import net.minecraft.world.level.World;
|
2021-03-08 22:47:33 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+// CraftBukkit start
|
2023-09-21 18:40:00 +02:00
|
|
|
+import org.bukkit.NamespacedKey;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
2019-01-02 05:56:21 +01:00
|
|
|
+import org.bukkit.craftbukkit.inventory.CraftRecipe;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.craftbukkit.inventory.CraftShapedRecipe;
|
2019-01-02 05:56:21 +01:00
|
|
|
+import org.bukkit.inventory.RecipeChoice;
|
2014-11-25 22:32:16 +01:00
|
|
|
+// CraftBukkit end
|
2021-03-08 22:47:33 +01:00
|
|
|
+
|
2019-04-23 04:00:00 +02:00
|
|
|
public class ShapedRecipes implements RecipeCrafting {
|
2017-05-14 04:00:00 +02:00
|
|
|
|
2023-12-05 17:40:00 +01:00
|
|
|
final ShapedRecipePattern pattern;
|
2024-04-23 17:15:00 +02:00
|
|
|
@@ -31,6 +39,68 @@
|
2023-12-05 17:40:00 +01:00
|
|
|
this(s, craftingbookcategory, shapedrecipepattern, itemstack, true);
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
2023-09-21 18:40:00 +02:00
|
|
|
+ @Override
|
|
|
|
+ public org.bukkit.inventory.ShapedRecipe toBukkitRecipe(NamespacedKey id) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
2023-09-21 18:40:00 +02:00
|
|
|
+ CraftShapedRecipe recipe = new CraftShapedRecipe(id, result, this);
|
2018-08-26 04:00:00 +02:00
|
|
|
+ recipe.setGroup(this.group);
|
2022-12-07 17:00:00 +01:00
|
|
|
+ recipe.setCategory(CraftRecipe.getCategory(this.category()));
|
2018-08-17 12:40:54 +02:00
|
|
|
+
|
2023-12-05 17:40:00 +01:00
|
|
|
+ switch (this.pattern.height()) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ case 1:
|
2023-12-05 17:40:00 +01:00
|
|
|
+ switch (this.pattern.width()) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ case 1:
|
|
|
|
+ recipe.shape("a");
|
|
|
|
+ break;
|
|
|
|
+ case 2:
|
|
|
|
+ recipe.shape("ab");
|
|
|
|
+ break;
|
|
|
|
+ case 3:
|
|
|
|
+ recipe.shape("abc");
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 2:
|
2023-12-05 17:40:00 +01:00
|
|
|
+ switch (this.pattern.width()) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ case 1:
|
|
|
|
+ recipe.shape("a","b");
|
|
|
|
+ break;
|
|
|
|
+ case 2:
|
|
|
|
+ recipe.shape("ab","cd");
|
|
|
|
+ break;
|
|
|
|
+ case 3:
|
|
|
|
+ recipe.shape("abc","def");
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 3:
|
2023-12-05 17:40:00 +01:00
|
|
|
+ switch (this.pattern.width()) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ 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';
|
2023-12-05 17:40:00 +01:00
|
|
|
+ for (RecipeItemStack list : this.pattern.ingredients()) {
|
2019-01-02 05:56:21 +01:00
|
|
|
+ RecipeChoice choice = CraftRecipe.toBukkit(list);
|
|
|
|
+ if (choice != null) {
|
|
|
|
+ recipe.setIngredient(c, choice);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
2019-01-02 05:56:21 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ c++;
|
|
|
|
+ }
|
|
|
|
+ return recipe;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
2023-09-21 18:40:00 +02:00
|
|
|
public RecipeSerializer<?> getSerializer() {
|
|
|
|
return RecipeSerializer.SHAPED_RECIPE;
|