mirror of
https://github.com/PaperMC/Paper.git
synced 2025-07-31 20:22:05 -07:00
Use ? super in Consumer/Predicate API (#9939)
This commit is contained in:
@@ -42,13 +42,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ * @param input the input placed into the bottom 3 slots
|
||||
+ * @param ingredient the ingredient placed into the top slot
|
||||
+ */
|
||||
+ public PotionMix(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice input, @NotNull RecipeChoice ingredient) {
|
||||
+ public PotionMix(final @NotNull NamespacedKey key, final @NotNull ItemStack result, final @NotNull RecipeChoice input, final @NotNull RecipeChoice ingredient) {
|
||||
+ this.key = key;
|
||||
+ this.result = result;
|
||||
+ this.input = input;
|
||||
+ this.ingredient = ingredient;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Create a {@link RecipeChoice} based on a Predicate. These RecipeChoices are only
|
||||
+ * valid for {@link PotionMix}, not anywhere else RecipeChoices may be used.
|
||||
+ *
|
||||
+ * @param stackPredicate a predicate for an itemstack.
|
||||
+ * @return a new RecipeChoice
|
||||
+ */
|
||||
+ @Contract(value = "_ -> new", pure = true)
|
||||
+ public static @NotNull RecipeChoice createPredicateChoice(final @NotNull Predicate<? super ItemStack> stackPredicate) {
|
||||
+ return new PredicateRecipeChoice(stackPredicate);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull NamespacedKey getKey() {
|
||||
+ return this.key;
|
||||
@@ -81,18 +93,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ return this.ingredient;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Create a {@link RecipeChoice} based on a Predicate. These RecipeChoices are only
|
||||
+ * valid for {@link PotionMix}, not anywhere else RecipeChoices may be used.
|
||||
+ *
|
||||
+ * @param stackPredicate a predicate for an itemstack.
|
||||
+ * @return a new RecipeChoice
|
||||
+ */
|
||||
+ @Contract(value = "_ -> new", pure = true)
|
||||
+ public static @NotNull RecipeChoice createPredicateChoice(@NotNull Predicate<ItemStack> stackPredicate) {
|
||||
+ return new PredicateRecipeChoice(stackPredicate);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String toString() {
|
||||
+ return "PotionMix{" +
|
||||
@@ -103,10 +103,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean equals(Object o) {
|
||||
+ public boolean equals(final Object o) {
|
||||
+ if (this == o) return true;
|
||||
+ if (o == null || getClass() != o.getClass()) return false;
|
||||
+ PotionMix potionMix = (PotionMix) o;
|
||||
+ if (o == null || this.getClass() != o.getClass()) return false;
|
||||
+ final PotionMix potionMix = (PotionMix) o;
|
||||
+ return this.key.equals(potionMix.key) && this.result.equals(potionMix.result) && this.input.equals(potionMix.input) && this.ingredient.equals(potionMix.ingredient);
|
||||
+ }
|
||||
+
|
||||
@@ -132,7 +132,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+
|
||||
+@ApiStatus.Internal
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+record PredicateRecipeChoice(Predicate<ItemStack> itemStackPredicate) implements RecipeChoice, Cloneable {
|
||||
+record PredicateRecipeChoice(Predicate<? super ItemStack> itemStackPredicate) implements RecipeChoice, Cloneable {
|
||||
+
|
||||
+ @Override
|
||||
+ @Deprecated
|
||||
@@ -144,7 +144,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ public RecipeChoice clone() {
|
||||
+ try {
|
||||
+ return (PredicateRecipeChoice) super.clone();
|
||||
+ } catch (CloneNotSupportedException ex) {
|
||||
+ } catch (final CloneNotSupportedException ex) {
|
||||
+ throw new AssertionError(ex);
|
||||
+ }
|
||||
+ }
|
||||
|
Reference in New Issue
Block a user