mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
980b33a6d0
* Updated Upstream (Bukkit/CraftBukkit/Spigot) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: e86f4dc4 PR-1041: Improve getPlayer(String) docs to clarify it matches the name 9738f005 Fix spawner API documentation 69ebd9fd PR-1034: Add TrialSpawnerSpawnEvent 23cffd9c PR-973: Improve spawner API and add API for Trial Spawners 8bf19163 PR-1038: Clarify HumanEntity#openInventory(InventoryView) JavaDoc 1ff76351 SPIGOT-7732, SPIGOT-7786: Add freezing damage modifier 02161cb4 PR-1034: Add CreatureSpawnEvent.SpawnReason#TRIAL_SPAWNER f9cb6f34 SPIGOT-7777: All entity potion effects are removed on death 25d548eb PR-1031: Expose Creeper igniter ccbf0915 SPIGOT-7770: Reserve spaces in shaped recipes for blank ingredients 17f7097c Clarify ambiguity around what is API 71714f0c Remove note from InventoryView JavaDoc aaf49731 PR-1030: Deprecate more unused methods in UnsafeValues 3a9dc689 SPIGOT-7771: Material.getDefaultAttributes always returns an empty map CraftBukkit Changes: c3ceeb6f7 SPIGOT-7814: Call PlayerShearEntityEvent for Bogged 97b1e4f58 Fix wolf armor not dropping from use of shears fd2ef563a SPIGOT-7812: Revert "SPIGOT-7809: Restore shield/banner conversion for base colours" f672c351b SPIGOT-7811: Enchantments are applied on sweeping attack even if damage event is cancelled cfe29350b SPIGOT-7808: Fix implementation of Enchantment#getName() for bad name return 19335f69e SPIGOT-7809: Restore shield/banner conversion for base colours ae4f5a0be SPIGOT-7805: Fix jukebox deserialization 62e3b73a4 SPIGOT-7804: Fix written book serialization aac911d26 SPIGOT-7800, SPIGOT-7801: Keep vanilla behaviour for items dropped on player death 13ece474f PR-1429: Implement TrialSpawnerSpawnEvent bf13e9113 PR-1354: Improve spawner API and add API for Trial Spawners 515fe49e1 Increase outdated build delay 9cd5a19a0 SPIGOT-7794: Cancelling InventoryItemMoveEvent destroys items ce40c7b14 SPIGOT-7796: Kickplayer newlines not working 5167256ff SPIGOT-7795: Fix damage/stats ignore the invulnerable damage time f993563ee Improve cross-world teleportation handling ab29122cf PR-1433: HumanEntity#openInventory(InventoryView) should only support views belonging to the player 764a541c5 SPIGOT-7732: Issue with the "hurt()" method of EntityLiving and invulnerable time 820084b5f SPIGOT-7791: Skull BlockState with null profile causes NullPointerException 5e46f1c82 SPIGOT-7785: Teleporting a player at the right moment can mess up vanilla teleportation cbd95a6b3 SPIGOT-7772: Include hidden / non-sampled players in player count 3153debc5 SPIGOT-7790: Server crashes after bee nest is forced to update e77bb26bb SPIGOT-7788: The healing power of friendship advancement is never granted ee3d7258a SPIGOT-7789: Fix NPE in CraftMetaFirework applyToItem 2889b3a11 PR-1429: Add CreatureSpawnEvent.SpawnReason#TRIAL_SPAWNER cdd05bc7f SPIGOT-7777: Speed attribute stays after death; missing EntityPotionEffectEvent call d0e6af2d4 PR-1428: Expose Creeper igniter d01c70e93 PR-1425: Fix bytecode transformation taking care of class-to-interface compatibility. b2b08f68c SPIGOT-7770: Fix certain shaped recipes not registering 3f8e4161f PR-1426: Deprecate more unused methods in UnsafeValues 2c9dd879e SPIGOT-7771: Material.getDefaultAttributes always returns an empty map Spigot Changes: 491f3675 Rebuild patches 0a642bd7 Rebuild patches 8897571b Rebuild patches cb8cf80c Fix newlines in custom restart message 1aabe506 Rebuild patches
383 lines
19 KiB
Diff
383 lines
19 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
Date: Sun, 12 May 2024 10:42:42 -0700
|
|
Subject: [PATCH] Fix issues with recipe API
|
|
|
|
Improves the validation when creating recipes
|
|
and RecipeChoices to closer match what is
|
|
allowed by the Codecs and StreamCodecs internally.
|
|
|
|
Adds RecipeChoice#empty which is allowed in specific
|
|
recipes and ingredient slots.
|
|
|
|
Also fixes some issues regarding mutability of both ItemStack
|
|
and implementations of RecipeChoice.
|
|
|
|
diff --git a/src/main/java/org/bukkit/inventory/CookingRecipe.java b/src/main/java/org/bukkit/inventory/CookingRecipe.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/org/bukkit/inventory/CookingRecipe.java
|
|
+++ b/src/main/java/org/bukkit/inventory/CookingRecipe.java
|
|
@@ -0,0 +0,0 @@ public abstract class CookingRecipe<T extends CookingRecipe> implements Recipe,
|
|
* @param cookingTime The cooking time (in ticks)
|
|
*/
|
|
public CookingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice input, float experience, int cookingTime) {
|
|
- Preconditions.checkArgument(result.getType() != Material.AIR, "Recipe must have non-AIR result.");
|
|
+ Preconditions.checkArgument(!result.isEmpty(), "Recipe cannot have an empty result."); // Paper
|
|
this.key = key;
|
|
this.output = new ItemStack(result);
|
|
- this.ingredient = input;
|
|
+ this.ingredient = input.validate(false).clone(); // Paper
|
|
this.experience = experience;
|
|
this.cookingTime = cookingTime;
|
|
}
|
|
@@ -0,0 +0,0 @@ public abstract class CookingRecipe<T extends CookingRecipe> implements Recipe,
|
|
*/
|
|
@NotNull
|
|
public T setInputChoice(@NotNull RecipeChoice input) {
|
|
- this.ingredient = input;
|
|
+ this.ingredient = input.validate(false).clone(); // Paper
|
|
return (T) this;
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/inventory/CraftingRecipe.java b/src/main/java/org/bukkit/inventory/CraftingRecipe.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/org/bukkit/inventory/CraftingRecipe.java
|
|
+++ b/src/main/java/org/bukkit/inventory/CraftingRecipe.java
|
|
@@ -0,0 +0,0 @@ public abstract class CraftingRecipe implements Recipe, Keyed {
|
|
|
|
protected CraftingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result) {
|
|
Preconditions.checkArgument(key != null, "key cannot be null");
|
|
- Preconditions.checkArgument(result.getType() != Material.AIR, "Recipe must have non-AIR result.");
|
|
+ Preconditions.checkArgument(!result.isEmpty(), "Recipe cannot have an empty result."); // Paper
|
|
this.key = key;
|
|
this.output = new ItemStack(result);
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/inventory/EmptyRecipeChoice.java b/src/main/java/org/bukkit/inventory/EmptyRecipeChoice.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
|
--- /dev/null
|
|
+++ b/src/main/java/org/bukkit/inventory/EmptyRecipeChoice.java
|
|
@@ -0,0 +0,0 @@
|
|
+package org.bukkit.inventory;
|
|
+
|
|
+import org.checkerframework.checker.nullness.qual.NonNull;
|
|
+import org.checkerframework.framework.qual.DefaultQualifier;
|
|
+import org.jetbrains.annotations.ApiStatus;
|
|
+
|
|
+@ApiStatus.Internal
|
|
+@DefaultQualifier(NonNull.class)
|
|
+record EmptyRecipeChoice() implements RecipeChoice {
|
|
+
|
|
+ static final RecipeChoice INSTANCE = new EmptyRecipeChoice();
|
|
+ @Override
|
|
+ public ItemStack getItemStack() {
|
|
+ throw new UnsupportedOperationException("This is an empty RecipeChoice");
|
|
+ }
|
|
+
|
|
+ @SuppressWarnings("MethodDoesntCallSuperMethod")
|
|
+ @Override
|
|
+ public RecipeChoice clone() {
|
|
+ return this;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean test(final ItemStack itemStack) {
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public RecipeChoice validate(final boolean allowEmptyRecipes) {
|
|
+ if (allowEmptyRecipes) return this;
|
|
+ throw new IllegalArgumentException("empty RecipeChoice isn't allowed here");
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/org/bukkit/inventory/MerchantRecipe.java b/src/main/java/org/bukkit/inventory/MerchantRecipe.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/org/bukkit/inventory/MerchantRecipe.java
|
|
+++ b/src/main/java/org/bukkit/inventory/MerchantRecipe.java
|
|
@@ -0,0 +0,0 @@ public class MerchantRecipe implements Recipe {
|
|
this(result, uses, maxUses, experienceReward, villagerExperience, priceMultiplier, 0, 0, ignoreDiscounts);
|
|
}
|
|
public MerchantRecipe(@NotNull ItemStack result, int uses, int maxUses, boolean experienceReward, int villagerExperience, float priceMultiplier, int demand, int specialPrice, boolean ignoreDiscounts) {
|
|
+ Preconditions.checkArgument(!result.isEmpty(), "Recipe cannot have an empty result."); // Paper
|
|
this.ignoreDiscounts = ignoreDiscounts;
|
|
// Paper end
|
|
this.result = result;
|
|
@@ -0,0 +0,0 @@ public class MerchantRecipe implements Recipe {
|
|
@NotNull
|
|
@Override
|
|
public ItemStack getResult() {
|
|
- return result;
|
|
+ return result.clone(); // Paper
|
|
}
|
|
|
|
public void addIngredient(@NotNull ItemStack item) {
|
|
Preconditions.checkState(ingredients.size() < 2, "MerchantRecipe can only have maximum 2 ingredients");
|
|
+ Preconditions.checkArgument(!item.isEmpty(), "Recipe cannot have an empty itemstack ingredient."); // Paper
|
|
ingredients.add(item.clone());
|
|
}
|
|
|
|
@@ -0,0 +0,0 @@ public class MerchantRecipe implements Recipe {
|
|
Preconditions.checkState(ingredients.size() <= 2, "MerchantRecipe can only have maximum 2 ingredients");
|
|
this.ingredients = new ArrayList<ItemStack>();
|
|
for (ItemStack item : ingredients) {
|
|
+ Preconditions.checkArgument(!item.isEmpty(), "Recipe cannot have an empty itemstack ingredient."); // Paper
|
|
this.ingredients.add(item.clone());
|
|
}
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/inventory/RecipeChoice.java b/src/main/java/org/bukkit/inventory/RecipeChoice.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/org/bukkit/inventory/RecipeChoice.java
|
|
+++ b/src/main/java/org/bukkit/inventory/RecipeChoice.java
|
|
@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull;
|
|
*/
|
|
public interface RecipeChoice extends Predicate<ItemStack>, Cloneable {
|
|
|
|
+ // Paper start - add "empty" choice
|
|
+ /**
|
|
+ * An "empty" recipe choice. Only valid as a recipe choice in
|
|
+ * specific places. Check the javadocs of a method before using it
|
|
+ * to be sure it's valid for that recipe and ingredient type.
|
|
+ *
|
|
+ * @return the empty recipe choice
|
|
+ */
|
|
+ static @NotNull RecipeChoice empty() {
|
|
+ return EmptyRecipeChoice.INSTANCE;
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
/**
|
|
* Gets a single item stack representative of this stack choice.
|
|
*
|
|
@@ -0,0 +0,0 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable {
|
|
@Override
|
|
boolean test(@NotNull ItemStack itemStack);
|
|
|
|
+ // Paper start - check valid ingredients
|
|
+ @org.jetbrains.annotations.ApiStatus.Internal
|
|
+ default @NotNull RecipeChoice validate(final boolean allowEmptyRecipes) {
|
|
+ return this;
|
|
+ }
|
|
+ // Paper end - check valid ingredients
|
|
+
|
|
/**
|
|
* Represents a choice of multiple matching Materials.
|
|
*/
|
|
@@ -0,0 +0,0 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable {
|
|
public String toString() {
|
|
return "MaterialChoice{" + "choices=" + choices + '}';
|
|
}
|
|
+
|
|
+ // Paper start - check valid ingredients
|
|
+ @Override
|
|
+ public @NotNull RecipeChoice validate(final boolean allowEmptyRecipes) {
|
|
+ if (this.choices.stream().anyMatch(Material::isAir)) {
|
|
+ throw new IllegalArgumentException("RecipeChoice.MaterialChoice cannot contain air");
|
|
+ }
|
|
+ return this;
|
|
+ }
|
|
+ // Paper end - check valid ingredients
|
|
}
|
|
|
|
/**
|
|
@@ -0,0 +0,0 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable {
|
|
public ExactChoice clone() {
|
|
try {
|
|
ExactChoice clone = (ExactChoice) super.clone();
|
|
- clone.choices = new ArrayList<>(choices);
|
|
+ // Paper start - properly clone
|
|
+ clone.choices = new ArrayList<>(this.choices.size());
|
|
+ for (ItemStack choice : this.choices) {
|
|
+ clone.choices.add(choice.clone());
|
|
+ }
|
|
+ // Paper end - properly clone
|
|
return clone;
|
|
} catch (CloneNotSupportedException ex) {
|
|
throw new AssertionError(ex);
|
|
@@ -0,0 +0,0 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable {
|
|
public String toString() {
|
|
return "ExactChoice{" + "choices=" + choices + '}';
|
|
}
|
|
+
|
|
+ // Paper start - check valid ingredients
|
|
+ @Override
|
|
+ public @NotNull RecipeChoice validate(final boolean allowEmptyRecipes) {
|
|
+ if (this.choices.stream().anyMatch(s -> s.getType().isAir())) {
|
|
+ throw new IllegalArgumentException("RecipeChoice.ExactChoice cannot contain air");
|
|
+ }
|
|
+ return this;
|
|
+ }
|
|
+ // Paper end - check valid ingredients
|
|
}
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/inventory/ShapedRecipe.java b/src/main/java/org/bukkit/inventory/ShapedRecipe.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/org/bukkit/inventory/ShapedRecipe.java
|
|
+++ b/src/main/java/org/bukkit/inventory/ShapedRecipe.java
|
|
@@ -0,0 +0,0 @@ public class ShapedRecipe extends CraftingRecipe {
|
|
Preconditions.checkArgument(key != ' ', "Space in recipe shape must represent no ingredient");
|
|
Preconditions.checkArgument(ingredients.containsKey(key), "Symbol does not appear in the shape:", key);
|
|
|
|
- ingredients.put(key, ingredient);
|
|
+ ingredients.put(key, ingredient.validate(false).clone()); // Paper
|
|
return this;
|
|
}
|
|
|
|
// Paper start
|
|
@NotNull
|
|
public ShapedRecipe setIngredient(char key, @NotNull ItemStack item) {
|
|
- return setIngredient(key, new RecipeChoice.ExactChoice(item));
|
|
+ Preconditions.checkArgument(!item.getType().isAir(), "Item cannot be air"); // Paper
|
|
+ return setIngredient(key, new RecipeChoice.ExactChoice(item.clone())); // Paper
|
|
}
|
|
// Paper end
|
|
|
|
diff --git a/src/main/java/org/bukkit/inventory/ShapelessRecipe.java b/src/main/java/org/bukkit/inventory/ShapelessRecipe.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/org/bukkit/inventory/ShapelessRecipe.java
|
|
+++ b/src/main/java/org/bukkit/inventory/ShapelessRecipe.java
|
|
@@ -0,0 +0,0 @@ public class ShapelessRecipe extends CraftingRecipe {
|
|
public ShapelessRecipe addIngredient(@NotNull RecipeChoice ingredient) {
|
|
Preconditions.checkArgument(ingredients.size() + 1 <= 9, "Shapeless recipes cannot have more than 9 ingredients");
|
|
|
|
- ingredients.add(ingredient);
|
|
+ ingredients.add(ingredient.validate(false).clone()); // Paper
|
|
return this;
|
|
}
|
|
|
|
@@ -0,0 +0,0 @@ public class ShapelessRecipe extends CraftingRecipe {
|
|
@NotNull
|
|
public ShapelessRecipe addIngredient(int count, @NotNull ItemStack item) {
|
|
Preconditions.checkArgument(ingredients.size() + count <= 9, "Shapeless recipes cannot have more than 9 ingredients");
|
|
+ Preconditions.checkArgument(!item.getType().isAir(), "Item cannot be air"); // Paper
|
|
+ item = item.clone(); // Paper
|
|
while (count-- > 0) {
|
|
ingredients.add(new RecipeChoice.ExactChoice(item));
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/inventory/SmithingRecipe.java b/src/main/java/org/bukkit/inventory/SmithingRecipe.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/org/bukkit/inventory/SmithingRecipe.java
|
|
+++ b/src/main/java/org/bukkit/inventory/SmithingRecipe.java
|
|
@@ -0,0 +0,0 @@ public class SmithingRecipe implements Recipe, Keyed {
|
|
*/
|
|
@Deprecated
|
|
public SmithingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice base, @NotNull RecipeChoice addition, boolean copyDataComponents) {
|
|
+ com.google.common.base.Preconditions.checkArgument(!result.isEmpty() || this instanceof ComplexRecipe, "Recipe cannot have an empty result."); // Paper
|
|
this.copyDataComponents = copyDataComponents;
|
|
// Paper end
|
|
this.key = key;
|
|
this.result = result;
|
|
- this.base = base;
|
|
- this.addition = addition;
|
|
+ this.base = base.validate(true).clone(); // Paper
|
|
+ this.addition = addition.validate(true).clone(); // Paper
|
|
}
|
|
|
|
/**
|
|
diff --git a/src/main/java/org/bukkit/inventory/SmithingTransformRecipe.java b/src/main/java/org/bukkit/inventory/SmithingTransformRecipe.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/org/bukkit/inventory/SmithingTransformRecipe.java
|
|
+++ b/src/main/java/org/bukkit/inventory/SmithingTransformRecipe.java
|
|
@@ -0,0 +0,0 @@ public class SmithingTransformRecipe extends SmithingRecipe {
|
|
*
|
|
* @param key The unique recipe key
|
|
* @param result The item you want the recipe to create.
|
|
- * @param template The template item.
|
|
- * @param base The base ingredient
|
|
- * @param addition The addition ingredient
|
|
+ * @param template The template item ({@link RecipeChoice#empty()} can be used)
|
|
+ * @param base The base ingredient ({@link RecipeChoice#empty()} can be used)
|
|
+ * @param addition The addition ingredient ({@link RecipeChoice#empty()} can be used)
|
|
*/
|
|
public SmithingTransformRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice template, @NotNull RecipeChoice base, @NotNull RecipeChoice addition) {
|
|
super(key, result, base, addition);
|
|
- this.template = template;
|
|
+ this.template = template.validate(true).clone(); // Paper
|
|
}
|
|
// Paper start
|
|
/**
|
|
@@ -0,0 +0,0 @@ public class SmithingTransformRecipe extends SmithingRecipe {
|
|
*
|
|
* @param key The unique recipe key
|
|
* @param result The item you want the recipe to create.
|
|
- * @param template The template item.
|
|
- * @param base The base ingredient
|
|
- * @param addition The addition ingredient
|
|
+ * @param template The template item ({@link RecipeChoice#empty()} can be used)
|
|
+ * @param base The base ingredient ({@link RecipeChoice#empty()} can be used)
|
|
+ * @param addition The addition ingredient ({@link RecipeChoice#empty()} can be used)
|
|
* @param copyDataComponents whether to copy the data components from the input base item to the output
|
|
*/
|
|
public SmithingTransformRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice template, @NotNull RecipeChoice base, @NotNull RecipeChoice addition, boolean copyDataComponents) {
|
|
super(key, result, base, addition, copyDataComponents);
|
|
- this.template = template;
|
|
+ this.template = template.validate(true).clone();
|
|
}
|
|
// Paper end
|
|
|
|
diff --git a/src/main/java/org/bukkit/inventory/SmithingTrimRecipe.java b/src/main/java/org/bukkit/inventory/SmithingTrimRecipe.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/org/bukkit/inventory/SmithingTrimRecipe.java
|
|
+++ b/src/main/java/org/bukkit/inventory/SmithingTrimRecipe.java
|
|
@@ -0,0 +0,0 @@ public class SmithingTrimRecipe extends SmithingRecipe implements ComplexRecipe
|
|
* Create a smithing recipe to produce the specified result ItemStack.
|
|
*
|
|
* @param key The unique recipe key
|
|
- * @param template The template item.
|
|
- * @param base The base ingredient
|
|
- * @param addition The addition ingredient
|
|
+ * @param template The template item ({@link RecipeChoice#empty()} can be used)
|
|
+ * @param base The base ingredient ({@link RecipeChoice#empty()} can be used)
|
|
+ * @param addition The addition ingredient ({@link RecipeChoice#empty()} can be used)
|
|
*/
|
|
public SmithingTrimRecipe(@NotNull NamespacedKey key, @NotNull RecipeChoice template, @NotNull RecipeChoice base, @NotNull RecipeChoice addition) {
|
|
super(key, new ItemStack(Material.AIR), base, addition);
|
|
- this.template = template;
|
|
+ this.template = template.validate(true).clone(); // Paper
|
|
}
|
|
// Paper start
|
|
/**
|
|
* Create a smithing recipe to produce the specified result ItemStack.
|
|
*
|
|
* @param key The unique recipe key
|
|
- * @param template The template item.
|
|
- * @param base The base ingredient
|
|
- * @param addition The addition ingredient
|
|
+ * @param template The template item. ({@link RecipeChoice#empty()} can be used)
|
|
+ * @param base The base ingredient ({@link RecipeChoice#empty()} can be used)
|
|
+ * @param addition The addition ingredient ({@link RecipeChoice#empty()} can be used)
|
|
* @param copyDataComponents whether to copy the data components from the input base item to the output
|
|
*/
|
|
public SmithingTrimRecipe(@NotNull NamespacedKey key, @NotNull RecipeChoice template, @NotNull RecipeChoice base, @NotNull RecipeChoice addition, boolean copyDataComponents) {
|
|
super(key, new ItemStack(Material.AIR), base, addition, copyDataComponents);
|
|
- this.template = template;
|
|
+ this.template = template.validate(true).clone(); // Paper
|
|
}
|
|
// Paper end
|
|
|
|
diff --git a/src/main/java/org/bukkit/inventory/StonecuttingRecipe.java b/src/main/java/org/bukkit/inventory/StonecuttingRecipe.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/org/bukkit/inventory/StonecuttingRecipe.java
|
|
+++ b/src/main/java/org/bukkit/inventory/StonecuttingRecipe.java
|
|
@@ -0,0 +0,0 @@ public class StonecuttingRecipe implements Recipe, Keyed {
|
|
* @param input The input choices.
|
|
*/
|
|
public StonecuttingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice input) {
|
|
- Preconditions.checkArgument(result.getType() != Material.AIR, "Recipe must have non-AIR result.");
|
|
+ Preconditions.checkArgument(!result.isEmpty(), "Recipe cannot have an empty result."); // Paper
|
|
this.key = key;
|
|
this.output = new ItemStack(result);
|
|
- this.ingredient = input;
|
|
+ this.ingredient = input.validate(false).clone(); // Paper
|
|
}
|
|
|
|
/**
|
|
@@ -0,0 +0,0 @@ public class StonecuttingRecipe implements Recipe, Keyed {
|
|
*/
|
|
@NotNull
|
|
public StonecuttingRecipe setInputChoice(@NotNull RecipeChoice input) {
|
|
- this.ingredient = input;
|
|
+ this.ingredient = input.validate(false).clone(); // Paper
|
|
return (StonecuttingRecipe) this;
|
|
}
|
|
|