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