From 54ec5946b7a3e57188b7dfe68292a05731a34e58 Mon Sep 17 00:00:00 2001
From: MrHell228
Date: Wed, 5 Jun 2024 01:18:55 +0300
Subject: [PATCH 01/14] Add BlockEntity tick methods
---
.../api/block/entity/BlockEntity.java | 21 +++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/src/main/java/org/spongepowered/api/block/entity/BlockEntity.java b/src/main/java/org/spongepowered/api/block/entity/BlockEntity.java
index bc74a110b3..90ddcca7bf 100644
--- a/src/main/java/org/spongepowered/api/block/entity/BlockEntity.java
+++ b/src/main/java/org/spongepowered/api/block/entity/BlockEntity.java
@@ -67,6 +67,27 @@ public interface BlockEntity extends SerializableDataHolder.Mutable, Locatable {
*/
void remove();
+ /**
+ * Returns whether this block entity can tick.
+ *
+ * @return True if this block entity can tick
+ */
+ boolean canTick();
+
+ /**
+ * Returns whether this block entity is ticking.
+ *
+ * @return True if this block entity is ticking
+ */
+ boolean isTicking();
+
+ /**
+ * Sets if this block entity will naturally tick.
+ *
+ * @param ticking The ticking state
+ */
+ void setTicking(boolean ticking);
+
/**
* Gets the type of {@link BlockEntity} this is.
*
From cf82a241c93386e81433bd6a6247425e0d9ac807 Mon Sep 17 00:00:00 2001
From: MrHell228
Date: Tue, 13 Aug 2024 03:39:19 +0700
Subject: [PATCH 02/14] Add ItemStackLike
---
.../api/item/inventory/ItemStack.java | 113 +-----------
.../api/item/inventory/ItemStackLike.java | 172 ++++++++++++++++++
.../api/item/inventory/ItemStackSnapshot.java | 37 +---
3 files changed, 177 insertions(+), 145 deletions(-)
create mode 100644 src/main/java/org/spongepowered/api/item/inventory/ItemStackLike.java
diff --git a/src/main/java/org/spongepowered/api/item/inventory/ItemStack.java b/src/main/java/org/spongepowered/api/item/inventory/ItemStack.java
index bc66070fd4..991261f164 100644
--- a/src/main/java/org/spongepowered/api/item/inventory/ItemStack.java
+++ b/src/main/java/org/spongepowered/api/item/inventory/ItemStack.java
@@ -24,26 +24,19 @@
*/
package org.spongepowered.api.item.inventory;
-import net.kyori.adventure.text.ComponentLike;
-import net.kyori.adventure.text.event.HoverEvent;
-import net.kyori.adventure.text.event.HoverEventSource;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.block.BlockSnapshot;
import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.block.entity.BlockEntity;
import org.spongepowered.api.data.DataHolderBuilder;
-import org.spongepowered.api.data.Key;
import org.spongepowered.api.data.SerializableDataHolder;
import org.spongepowered.api.data.persistence.DataView;
-import org.spongepowered.api.data.value.Value;
-import org.spongepowered.api.data.value.ValueContainer;
import org.spongepowered.api.entity.attribute.AttributeModifier;
import org.spongepowered.api.entity.attribute.type.AttributeType;
import org.spongepowered.api.item.ItemType;
import org.spongepowered.api.item.inventory.equipment.EquipmentType;
import org.spongepowered.api.registry.DefaultedRegistryReference;
-import java.util.Collection;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
@@ -52,14 +45,10 @@
import java.util.function.Supplier;
/**
- * Represents a stack of a specific {@link ItemType}. Supports serialization and
- * can be compared using the comparators listed in {@link ItemStackComparators}.
- *
- * {@link ItemStack}s have a variety of properties and data. It is advised to
- * use {@link ValueContainer#get(Key)} in order to retrieve information regarding
- * this item stack.
+ * Represents mutable {@link ItemStackLike}. Can be compared
+ * using the comparators listed in {@link ItemStackComparators}.
*/
-public interface ItemStack extends SerializableDataHolder.Mutable, ComponentLike, HoverEventSource {
+public interface ItemStack extends ItemStackLike, SerializableDataHolder.Mutable {
/**
* Returns an empty {@link ItemStack}.
@@ -123,22 +112,6 @@ static ItemStack of(ItemType itemType) {
return ItemStack.of(itemType, 1);
}
- /**
- * Gets the {@link ItemType} of this {@link ItemStack}.
- *
- * @return The item type
- */
- ItemType type();
-
- /**
- * Gets the quantity of items in this stack. This may exceed the max stack
- * size of the item, and if added to an inventory will then be divided by
- * the max stack.
- *
- * @return Quantity of items
- */
- int quantity();
-
/**
* Sets the quantity in this stack.
*
@@ -148,24 +121,6 @@ static ItemStack of(ItemType itemType) {
*/
void setQuantity(int quantity) throws IllegalArgumentException;
- /**
- * Gets the maximum quantity per stack. By default, returns
- * {@link ItemType#maxStackQuantity()}, unless a
- * different value has been set for this specific stack.
- *
- * @return Max stack quantity
- */
- int maxStackQuantity();
-
- /**
- * Gets the {@link ItemStackSnapshot} of this {@link ItemStack}. All
- * known {@link Value}s existing on this {@link ItemStack} are added
- * as copies to the {@link ItemStackSnapshot}.
- *
- * @return The newly created item stack snapshot
- */
- ItemStackSnapshot createSnapshot();
-
/**
* Returns true if the specified {@link ItemStack} has the same stack
* size, {@link ItemType}, and data. Note that this method is not an
@@ -179,66 +134,6 @@ static ItemStack of(ItemType itemType) {
*/
boolean equalTo(ItemStack that);
- /**
- * Returns true if {@link #quantity()} is zero and therefore this
- * ItemStack is empty.
- *
- * In Vanilla empty ItemStacks are not rendered by the client.
- *
- * @return True if this ItemStack is empty
- */
- boolean isEmpty();
-
- /**
- * Gets all {@link AttributeModifier}s on this item stack.
- *
- * @param attributeType The {@link AttributeType} of the modifier.
- * @param equipmentType The {@link EquipmentType} this modifier is applied
- * to.
- *
- * @return A collection of {@link AttributeModifier}s.
- */
- default Collection attributeModifiers(Supplier extends AttributeType> attributeType, DefaultedRegistryReference extends EquipmentType> equipmentType) {
- return this.attributeModifiers(attributeType.get(), equipmentType.get());
- }
-
- /**
- * Gets all {@link AttributeModifier}s on this item stack.
- *
- * @param attributeType The {@link AttributeType} of the modifier.
- * @param equipmentType The {@link EquipmentType} this modifier is applied
- * to.
- *
- * @return A collection of {@link AttributeModifier}s.
- */
- default Collection attributeModifiers(AttributeType attributeType, DefaultedRegistryReference extends EquipmentType> equipmentType) {
- return this.attributeModifiers(attributeType, equipmentType.get());
- }
-
- /**
- * Gets all {@link AttributeModifier}s on this item stack.
- *
- * @param attributeType The {@link AttributeType} of the modifier.
- * @param equipmentType The {@link EquipmentType} this modifier is applied
- * to.
- *
- * @return A collection of {@link AttributeModifier}s.
- */
- default Collection attributeModifiers(Supplier extends AttributeType> attributeType, EquipmentType equipmentType) {
- return this.attributeModifiers(attributeType.get(), equipmentType);
- }
-
- /**
- * Gets all {@link AttributeModifier}s on this item stack.
- *
- * @param attributeType The {@link AttributeType} of the modifier.
- * @param equipmentType The {@link EquipmentType} this modifier is applied
- * to.
- *
- * @return A collection of {@link AttributeModifier}s.
- */
- Collection attributeModifiers(AttributeType attributeType, EquipmentType equipmentType);
-
/**
* Adds an {@link AttributeModifier} to this item stack.
*
@@ -386,7 +281,7 @@ default Builder fromBlockState(final Supplier extends BlockState> blockState)
* @return This builder, for chaining
*/
default Builder fromSnapshot(final ItemStackSnapshot snapshot) {
- return this.fromItemStack(snapshot.createStack());
+ return this.fromItemStack(snapshot.asMutable());
}
/**
diff --git a/src/main/java/org/spongepowered/api/item/inventory/ItemStackLike.java b/src/main/java/org/spongepowered/api/item/inventory/ItemStackLike.java
new file mode 100644
index 0000000000..e425fe1f10
--- /dev/null
+++ b/src/main/java/org/spongepowered/api/item/inventory/ItemStackLike.java
@@ -0,0 +1,172 @@
+/*
+ * This file is part of SpongeAPI, licensed under the MIT License (MIT).
+ *
+ * Copyright (c) SpongePowered
+ * Copyright (c) contributors
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package org.spongepowered.api.item.inventory;
+
+import net.kyori.adventure.text.ComponentLike;
+import net.kyori.adventure.text.event.HoverEvent;
+import net.kyori.adventure.text.event.HoverEventSource;
+import org.spongepowered.api.data.Key;
+import org.spongepowered.api.data.Keys;
+import org.spongepowered.api.data.SerializableDataHolder;
+import org.spongepowered.api.data.value.Value;
+import org.spongepowered.api.data.value.ValueContainer;
+import org.spongepowered.api.entity.attribute.AttributeModifier;
+import org.spongepowered.api.entity.attribute.type.AttributeType;
+import org.spongepowered.api.item.ItemType;
+import org.spongepowered.api.item.inventory.equipment.EquipmentType;
+import org.spongepowered.api.registry.DefaultedRegistryReference;
+
+import java.util.Collection;
+import java.util.function.Supplier;
+
+/**
+ * Represents a stack of a specific {@link ItemType}. Supports serialization.
+ *
+ * {@link ItemStackLike} have a variety of properties and data. It is advised to
+ * use {@link ValueContainer#get(Key)} in order to retrieve information regarding
+ * this item stack.
+ */
+public interface ItemStackLike extends SerializableDataHolder, ComponentLike, HoverEventSource {
+
+ /**
+ * Gets the {@link ItemType} of this {@link ItemStackLike}.
+ *
+ * @return The item type
+ */
+ ItemType type();
+
+ /**
+ * Gets the quantity of items in this stack. This may exceed the max stack
+ * size of the item, and if added to an inventory will then be divided by
+ * the max stack.
+ *
+ * @return Quantity of items
+ */
+ int quantity();
+
+ /**
+ * Gets the maximum quantity per stack. By default, returns
+ * {@link ItemType#maxStackQuantity()}, unless a
+ * different value has been set for this specific stack.
+ *
+ * @return Max stack quantity
+ */
+ default int maxStackQuantity() {
+ return this.require(Keys.MAX_STACK_SIZE);
+ }
+
+ /**
+ * Returns true if {@link #quantity()} is zero and therefore this
+ * {@link ItemStackLike} is empty.
+ *
+ * In Vanilla empty ItemStacks are not rendered by the client.
+ *
+ * @return True if this ItemStackLike is empty
+ */
+ boolean isEmpty();
+
+ /**
+ * Gets all {@link AttributeModifier}s on this {@link ItemStackLike}.
+ *
+ * @param attributeType The {@link AttributeType} of the modifier.
+ * @param equipmentType The {@link EquipmentType} this modifier is applied.
+ * to.
+ *
+ * @return A collection of {@link AttributeModifier}s.
+ */
+ default Collection attributeModifiers(Supplier extends AttributeType> attributeType, DefaultedRegistryReference extends EquipmentType> equipmentType) {
+ return this.attributeModifiers(attributeType.get(), equipmentType.get());
+ }
+
+ /**
+ * Gets all {@link AttributeModifier}s on this {@link ItemStackLike}.
+ *
+ * @param attributeType The {@link AttributeType} of the modifier.
+ * @param equipmentType The {@link EquipmentType} this modifier is applied.
+ * to.
+ *
+ * @return A collection of {@link AttributeModifier}s.
+ */
+ default Collection attributeModifiers(AttributeType attributeType, DefaultedRegistryReference extends EquipmentType> equipmentType) {
+ return this.attributeModifiers(attributeType, equipmentType.get());
+ }
+
+ /**
+ * Gets all {@link AttributeModifier}s on this {@link ItemStackLike}.
+ *
+ * @param attributeType The {@link AttributeType} of the modifier.
+ * @param equipmentType The {@link EquipmentType} this modifier is applied.
+ * to.
+ *
+ * @return A collection of {@link AttributeModifier}s.
+ */
+ default Collection attributeModifiers(Supplier extends AttributeType> attributeType, EquipmentType equipmentType) {
+ return this.attributeModifiers(attributeType.get(), equipmentType);
+ }
+
+ /**
+ * Gets all {@link AttributeModifier}s on this {@link ItemStackLike}.
+ *
+ * @param attributeType The {@link AttributeType} of the modifier.
+ * @param equipmentType The {@link EquipmentType} this modifier is applied.
+ * to.
+ *
+ * @return A collection of {@link AttributeModifier}s.
+ */
+ Collection attributeModifiers(AttributeType attributeType, EquipmentType equipmentType);
+
+ /**
+ * Retrieves a mutable form of this {@link ItemStackLike}. If this
+ * ItemStackLike is already mutable, this would simply return itself.
+ * In other cases, a new {@link ItemStack} is created with all the
+ * data currently available on this {@link ItemStackLike}.
+ *
+ * @return An ItemStack
+ */
+ ItemStack asMutable();
+
+ /**
+ * Retrieves a copy in the mutable form of this {@link ItemStackLike}.
+ * The new {@link ItemStack} is created with all the data currently
+ * available on this {@link ItemStackLike}.
+ *
+ * @return A new ItemStack
+ */
+ ItemStack asMutableCopy();
+
+ /**
+ * Retrieves an immutable form of this {@link ItemStackLike}. If this
+ * ItemStackLike is already immutable, this would simply return itself.
+ * In other cases, a new {@link ItemStackSnapshot} is created with all
+ * known {@link Value}s existing on this {@link ItemStackLike} added
+ * as copies to the {@link ItemStackSnapshot}.
+ *
+ * @return An ItemStackSnapshot
+ */
+ ItemStackSnapshot asImmutable();
+
+ @Override
+ ItemStackLike copy();
+}
diff --git a/src/main/java/org/spongepowered/api/item/inventory/ItemStackSnapshot.java b/src/main/java/org/spongepowered/api/item/inventory/ItemStackSnapshot.java
index 4ee66be6bc..35314f96e9 100644
--- a/src/main/java/org/spongepowered/api/item/inventory/ItemStackSnapshot.java
+++ b/src/main/java/org/spongepowered/api/item/inventory/ItemStackSnapshot.java
@@ -24,11 +24,8 @@
*/
package org.spongepowered.api.item.inventory;
-import net.kyori.adventure.text.event.HoverEvent;
-import net.kyori.adventure.text.event.HoverEventSource;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.data.SerializableDataHolder;
-import org.spongepowered.api.item.ItemType;
/**
* Represents a snapshot of an {@link ItemStack} as an
@@ -37,7 +34,7 @@
* it is a snapshot, a snapshot cannot be modified, but modifications will
* result in a new instance of the {@link ItemStackSnapshot}.
*/
-public interface ItemStackSnapshot extends HoverEventSource, SerializableDataHolder.Immutable {
+public interface ItemStackSnapshot extends ItemStackLike, SerializableDataHolder.Immutable {
/**
* Gets a empty {@link ItemStackSnapshot}.
@@ -48,38 +45,6 @@ static ItemStackSnapshot empty() {
return Sponge.game().factoryProvider().provide(Factory.class).empty();
}
- /**
- * Gets the {@link ItemType} of this {@link ItemStackSnapshot}. The
- * {@link ItemType} is always available.
- *
- * @return The item type
- */
- ItemType type();
-
- /**
- * Gets the quantity of items in this the {@link ItemStack} this
- * {@link ItemStackSnapshot} is representing.
- *
- * @return The current stack size
- */
- int quantity();
-
- /**
- * Returns true if {@link #quantity()} is zero and therefore this
- * ItemStackSnapshot is empty.
- *
- * @return True if this ItemStackSnapshot is empty
- */
- boolean isEmpty();
-
- /**
- * Creates a new {@link ItemStack} with all the data currently available
- * on this {@link ItemStackSnapshot}.
- *
- * @return The newly generated item stack
- */
- ItemStack createStack();
-
interface Factory {
ItemStackSnapshot empty();
From 2bc0eec7f1c4a7312a8c5dd7382331c208997112 Mon Sep 17 00:00:00 2001
From: MrHell228
Date: Tue, 13 Aug 2024 03:40:08 +0700
Subject: [PATCH 03/14] replace: createStack() -> asMutable() &
createSnapshot() -> asImmutable()
---
.../java/org/spongepowered/api/advancement/DisplayInfo.java | 2 +-
.../api/event/cause/entity/damage/DamageModifier.java | 2 +-
.../api/event/item/inventory/AffectItemStackEvent.java | 2 +-
.../spongepowered/api/event/item/inventory/AffectSlotEvent.java | 2 +-
.../api/item/inventory/transaction/SlotTransaction.java | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/main/java/org/spongepowered/api/advancement/DisplayInfo.java b/src/main/java/org/spongepowered/api/advancement/DisplayInfo.java
index f8ad82609c..85f2c8fff4 100644
--- a/src/main/java/org/spongepowered/api/advancement/DisplayInfo.java
+++ b/src/main/java/org/spongepowered/api/advancement/DisplayInfo.java
@@ -171,7 +171,7 @@ default Builder icon(ItemType itemType) {
* @return This builder, for chaining
*/
default Builder icon(ItemStack itemStack) {
- return this.icon(itemStack.createSnapshot());
+ return this.icon(itemStack.asImmutable());
}
/**
diff --git a/src/main/java/org/spongepowered/api/event/cause/entity/damage/DamageModifier.java b/src/main/java/org/spongepowered/api/event/cause/entity/damage/DamageModifier.java
index 65286dc6fb..c0b0eb263e 100644
--- a/src/main/java/org/spongepowered/api/event/cause/entity/damage/DamageModifier.java
+++ b/src/main/java/org/spongepowered/api/event/cause/entity/damage/DamageModifier.java
@@ -163,7 +163,7 @@ public Builder group(final String group) {
}
public Builder item(final ItemStack itemStack) {
- this.item(java.util.Objects.requireNonNull(itemStack, "ItemStack").createSnapshot());
+ this.item(java.util.Objects.requireNonNull(itemStack, "ItemStack").asImmutable());
return this;
}
diff --git a/src/main/java/org/spongepowered/api/event/item/inventory/AffectItemStackEvent.java b/src/main/java/org/spongepowered/api/event/item/inventory/AffectItemStackEvent.java
index 8346af1480..6e46aafe46 100644
--- a/src/main/java/org/spongepowered/api/event/item/inventory/AffectItemStackEvent.java
+++ b/src/main/java/org/spongepowered/api/event/item/inventory/AffectItemStackEvent.java
@@ -67,7 +67,7 @@ public interface AffectItemStackEvent extends Event, Cancellable {
*/
default List extends Transaction> filter(Predicate predicate) {
final List> invalidatedTransactions = new ArrayList<>();
- this.transactions().stream().filter(transaction -> !predicate.test(transaction.finalReplacement().createStack())).forEach(transaction -> {
+ this.transactions().stream().filter(transaction -> !predicate.test(transaction.finalReplacement().asMutable())).forEach(transaction -> {
transaction.setValid(false);
invalidatedTransactions.add(transaction);
});
diff --git a/src/main/java/org/spongepowered/api/event/item/inventory/AffectSlotEvent.java b/src/main/java/org/spongepowered/api/event/item/inventory/AffectSlotEvent.java
index 3662f9d534..ab7d667fd5 100644
--- a/src/main/java/org/spongepowered/api/event/item/inventory/AffectSlotEvent.java
+++ b/src/main/java/org/spongepowered/api/event/item/inventory/AffectSlotEvent.java
@@ -40,7 +40,7 @@ public interface AffectSlotEvent extends AffectItemStackEvent {
@Override
default List filter(Predicate predicate) {
final List invalidatedTransactions = new ArrayList<>();
- this.transactions().stream().filter(transaction -> !predicate.test(transaction.finalReplacement().createStack())).forEach(transaction -> {
+ this.transactions().stream().filter(transaction -> !predicate.test(transaction.finalReplacement().asMutable())).forEach(transaction -> {
transaction.setValid(false);
invalidatedTransactions.add(transaction);
});
diff --git a/src/main/java/org/spongepowered/api/item/inventory/transaction/SlotTransaction.java b/src/main/java/org/spongepowered/api/item/inventory/transaction/SlotTransaction.java
index a7369f53f9..cf25725a58 100644
--- a/src/main/java/org/spongepowered/api/item/inventory/transaction/SlotTransaction.java
+++ b/src/main/java/org/spongepowered/api/item/inventory/transaction/SlotTransaction.java
@@ -57,7 +57,7 @@ public SlotTransaction(Slot slot, ItemStackSnapshot original, ItemStackSnapshot
* @param stack The stack
*/
public void setCustom(ItemStack stack) {
- this.setCustom(Objects.requireNonNull(stack, "ItemStack was null").createSnapshot());
+ this.setCustom(Objects.requireNonNull(stack, "ItemStack was null").asImmutable());
}
/**
From c55e532c5e19dc6b0dcd2f62cc8989a949611dcb Mon Sep 17 00:00:00 2001
From: MrHell228
Date: Fri, 13 Sep 2024 16:39:39 +0300
Subject: [PATCH 04/14] return #createStack() & #createSnapshot() with
deprecation
---
.../org/spongepowered/api/item/inventory/ItemStack.java | 8 ++++++++
.../api/item/inventory/ItemStackSnapshot.java | 8 ++++++++
2 files changed, 16 insertions(+)
diff --git a/src/main/java/org/spongepowered/api/item/inventory/ItemStack.java b/src/main/java/org/spongepowered/api/item/inventory/ItemStack.java
index 991261f164..5732149556 100644
--- a/src/main/java/org/spongepowered/api/item/inventory/ItemStack.java
+++ b/src/main/java/org/spongepowered/api/item/inventory/ItemStack.java
@@ -121,6 +121,14 @@ static ItemStack of(ItemType itemType) {
*/
void setQuantity(int quantity) throws IllegalArgumentException;
+ /**
+ * @deprecated Use {@link #asImmutable()} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default ItemStackSnapshot createSnapshot() {
+ return this.asImmutable();
+ }
+
/**
* Returns true if the specified {@link ItemStack} has the same stack
* size, {@link ItemType}, and data. Note that this method is not an
diff --git a/src/main/java/org/spongepowered/api/item/inventory/ItemStackSnapshot.java b/src/main/java/org/spongepowered/api/item/inventory/ItemStackSnapshot.java
index 35314f96e9..e6fa6e98f9 100644
--- a/src/main/java/org/spongepowered/api/item/inventory/ItemStackSnapshot.java
+++ b/src/main/java/org/spongepowered/api/item/inventory/ItemStackSnapshot.java
@@ -45,6 +45,14 @@ static ItemStackSnapshot empty() {
return Sponge.game().factoryProvider().provide(Factory.class).empty();
}
+ /**
+ * @deprecated Use {@link #asMutable()} or {@link #asMutableCopy()} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default ItemStack createStack() {
+ return this.asMutable();
+ }
+
interface Factory {
ItemStackSnapshot empty();
From 6ddddd40ee390b9441bf8b225684ff6d8a338e97 Mon Sep 17 00:00:00 2001
From: MrHell228
Date: Sat, 14 Sep 2024 04:00:15 +0300
Subject: [PATCH 05/14] Migrate recipes to ItemStackLike
---
.../api/item/recipe/RecipeManager.java | 41 +++++++++-
.../item/recipe/cooking/CookingRecipe.java | 63 +++++++++++----
.../item/recipe/cooking/CookingResult.java | 15 +++-
.../api/item/recipe/crafting/Ingredient.java | 80 ++++++++++++++-----
.../api/item/recipe/crafting/RecipeInput.java | 21 ++++-
.../item/recipe/crafting/RecipeResult.java | 16 +++-
.../recipe/crafting/ShapedCraftingRecipe.java | 39 ++++++---
.../crafting/ShapelessCraftingRecipe.java | 37 ++++++---
.../crafting/SpecialCraftingRecipe.java | 15 +++-
.../item/recipe/single/StoneCutterRecipe.java | 37 ++++++---
.../item/recipe/smithing/SmithingRecipe.java | 37 ++++++---
11 files changed, 304 insertions(+), 97 deletions(-)
diff --git a/src/main/java/org/spongepowered/api/item/recipe/RecipeManager.java b/src/main/java/org/spongepowered/api/item/recipe/RecipeManager.java
index bb1e05ca83..5ddae2894c 100644
--- a/src/main/java/org/spongepowered/api/item/recipe/RecipeManager.java
+++ b/src/main/java/org/spongepowered/api/item/recipe/RecipeManager.java
@@ -25,6 +25,7 @@
package org.spongepowered.api.item.recipe;
import org.spongepowered.api.ResourceKey;
+import org.spongepowered.api.item.inventory.ItemStackLike;
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
import org.spongepowered.api.item.recipe.cooking.CookingRecipe;
import org.spongepowered.api.item.recipe.crafting.RecipeInput;
@@ -76,6 +77,14 @@ default > Collection allOfType(Supplier extends RecipeT
return this.allOfType(supplier.get());
}
+ /**
+ * @deprecated Use {@link #findByResult(RecipeType, ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default > Collection findByResult(RecipeType type, ItemStackSnapshot result) {
+ return this.findByResult(type, (ItemStackLike) result);
+ }
+
/**
* Returns all registered recipes of given type and with given item as a result.
*
@@ -84,7 +93,15 @@ default > Collection allOfType(Supplier extends RecipeT
*
* @return The recipes resulting in given item.
*/
- > Collection findByResult(RecipeType type, ItemStackSnapshot result);
+ > Collection findByResult(RecipeType type, ItemStackLike result);
+
+ /**
+ * @deprecated Use {@link #findByResult(Supplier, ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default > Collection findByResult(Supplier extends RecipeType> supplier, ItemStackSnapshot result) {
+ return this.findByResult(supplier, (ItemStackLike) result);
+ }
/**
* Gets all recipes with given item as a result.
@@ -93,7 +110,7 @@ default > Collection allOfType(Supplier extends RecipeT
*
* @return All recipes resulting in given item.
*/
- default > Collection findByResult(Supplier extends RecipeType> supplier, ItemStackSnapshot result) {
+ default > Collection findByResult(Supplier extends RecipeType> supplier, ItemStackLike result) {
return this.findByResult(supplier.get(), result);
}
@@ -121,6 +138,14 @@ default > Optional findMatchingRec
return this.findMatchingRecipe(supplier.get(), input, world);
}
+ /**
+ * @deprecated Use {@link #findCookingRecipe(RecipeType, ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default Optional findCookingRecipe(RecipeType type, ItemStackSnapshot ingredient) {
+ return this.findCookingRecipe(type, (ItemStackLike) ingredient);
+ }
+
/**
* Finds a matching cooking recipe for given type and ingredient
*
@@ -129,7 +154,15 @@ default > Optional findMatchingRec
*
* @return The matching recipe.
*/
- Optional findCookingRecipe(RecipeType type, ItemStackSnapshot ingredient);
+ Optional findCookingRecipe(RecipeType type, ItemStackLike ingredient);
+
+ /**
+ * @deprecated Use {@link #findCookingRecipe(Supplier, ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default Optional findCookingRecipe(Supplier extends RecipeType> supplier, ItemStackSnapshot ingredient) {
+ return this.findCookingRecipe(supplier, (ItemStackLike) ingredient);
+ }
/**
* Finds a matching cooking recipe for given type and ingredient
@@ -139,7 +172,7 @@ default > Optional findMatchingRec
*
* @return The matching recipe.
*/
- default Optional findCookingRecipe(Supplier extends RecipeType> supplier, ItemStackSnapshot ingredient) {
+ default Optional findCookingRecipe(Supplier extends RecipeType> supplier, ItemStackLike ingredient) {
return this.findCookingRecipe(supplier.get(), ingredient);
}
diff --git a/src/main/java/org/spongepowered/api/item/recipe/cooking/CookingRecipe.java b/src/main/java/org/spongepowered/api/item/recipe/cooking/CookingRecipe.java
index 6038676b55..776725f7e0 100644
--- a/src/main/java/org/spongepowered/api/item/recipe/cooking/CookingRecipe.java
+++ b/src/main/java/org/spongepowered/api/item/recipe/cooking/CookingRecipe.java
@@ -29,6 +29,7 @@
import org.spongepowered.api.datapack.DataPack;
import org.spongepowered.api.item.ItemType;
import org.spongepowered.api.item.inventory.ItemStack;
+import org.spongepowered.api.item.inventory.ItemStackLike;
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
import org.spongepowered.api.item.recipe.Recipe;
import org.spongepowered.api.item.recipe.RecipeRegistration;
@@ -64,25 +65,41 @@ static Builder builder() {
Ingredient ingredient();
/**
- * Checks if the given {@link ItemStackSnapshot} fits the required
+ * @deprecated Use {@link #isValid(ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default boolean isValid(ItemStackSnapshot ingredient) {
+ return this.isValid((ItemStackLike) ingredient);
+ }
+
+ /**
+ * Checks if the given {@link ItemStackLike} fits the required
* constraints to craft this {@link CookingRecipe}.
*
* @param ingredient The ingredient to check against
*
* @return Whether this ingredient can be used to craft the result
*/
- boolean isValid(ItemStackSnapshot ingredient);
+ boolean isValid(ItemStackLike ingredient);
+
+ /**
+ * @deprecated Use {@link #result(ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default Optional result(ItemStackSnapshot ingredient) {
+ return this.result((ItemStackLike) ingredient);
+ }
/**
* Returns the {@link CookingResult} containing the resulting
- * {@link ItemStackSnapshot} and the amount of experience released.
+ * {@link ItemStackLike} and the amount of experience released.
*
- * @param ingredient The {@link ItemStackSnapshot} currently being cooked
+ * @param ingredient The {@link ItemStackLike} currently being cooked
* @return The {@link CookingResult}, or {@link Optional#empty()}
* if the recipe is not valid according to
- * {@link #isValid(ItemStackSnapshot)}.
+ * {@link #isValid(ItemStackLike)}.
*/
- Optional result(ItemStackSnapshot ingredient);
+ Optional result(ItemStackLike ingredient);
/**
* Returns the cooking time in ticks.
@@ -183,24 +200,38 @@ default EndStep result(Supplier extends ItemType> result) {
}
/**
- * Changes the result and returns this builder. The result is the
- * {@link ItemStack} created when the recipe is fulfilled.
- *
- * @param result The output of this recipe
- *
- * @return This builder, for chaining
+ * @deprecated Use {@link #result(ItemStackLike)} instead.
*/
- EndStep result(ItemStack result);
+ @Deprecated(forRemoval = true)
+ default EndStep result(ItemStack result) {
+ return this.result((ItemStackLike) result);
+ }
+
+ /**
+ * @deprecated Use {@link #result(ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default EndStep result(ItemStackSnapshot result) {
+ return this.result((ItemStackLike) result);
+ }
/**
* Changes the result and returns this builder. The result is the
- * {@link ItemStack} created when the recipe is fulfilled.
+ * {@link ItemStackLike} created when the recipe is fulfilled.
*
* @param result The output of this recipe
*
* @return This builder, for chaining
*/
- EndStep result(ItemStackSnapshot result);
+ EndStep result(ItemStackLike result);
+
+ /**
+ * @deprecated Use {@link #result(Function, ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default EndStep result(final Function resultFunction, final ItemStack exemplaryResult) {
+ return this.result(resultFunction, (ItemStackLike) exemplaryResult);
+ }
/**
* Sets the result function and an exemplary result.
@@ -210,7 +241,7 @@ default EndStep result(Supplier extends ItemType> result) {
*
* @return The builder
*/
- EndStep result(final Function resultFunction, final ItemStack exemplaryResult);
+ EndStep result(final Function resultFunction, final ItemStackLike exemplaryResult);
}
interface EndStep extends Builder,
diff --git a/src/main/java/org/spongepowered/api/item/recipe/cooking/CookingResult.java b/src/main/java/org/spongepowered/api/item/recipe/cooking/CookingResult.java
index c978d3951c..8cb100ba48 100644
--- a/src/main/java/org/spongepowered/api/item/recipe/cooking/CookingResult.java
+++ b/src/main/java/org/spongepowered/api/item/recipe/cooking/CookingResult.java
@@ -24,6 +24,7 @@
*/
package org.spongepowered.api.item.recipe.cooking;
+import org.spongepowered.api.item.inventory.ItemStackLike;
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
import java.util.Objects;
@@ -37,6 +38,14 @@ public final class CookingResult {
private final ItemStackSnapshot result;
private final double experience;
+ /**
+ * @deprecated Use {@link #CookingResult(ItemStackLike, double)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ public CookingResult(final ItemStackSnapshot result, final double experience) {
+ this((ItemStackLike) result, experience);
+ }
+
/**
* Creates a new {@link CookingResult}.
*
@@ -45,16 +54,16 @@ public final class CookingResult {
* @param result The result of the cooking recipe
* @param experience The experience that should be created from this result
*/
- public CookingResult(final ItemStackSnapshot result, final double experience) {
+ public CookingResult(final ItemStackLike result, final double experience) {
Objects.requireNonNull(result, "result");
if (result.isEmpty()) {
- throw new IllegalArgumentException("The resulting snapshot must not be empty");
+ throw new IllegalArgumentException("The result must not be empty");
}
if (experience < 0) {
throw new IllegalArgumentException("The experience must be non-negative.");
}
- this.result = result;
+ this.result = result.asImmutable();
this.experience = experience;
}
diff --git a/src/main/java/org/spongepowered/api/item/recipe/crafting/Ingredient.java b/src/main/java/org/spongepowered/api/item/recipe/crafting/Ingredient.java
index c2e6062d19..abefa1b908 100644
--- a/src/main/java/org/spongepowered/api/item/recipe/crafting/Ingredient.java
+++ b/src/main/java/org/spongepowered/api/item/recipe/crafting/Ingredient.java
@@ -29,6 +29,7 @@
import org.spongepowered.api.Sponge;
import org.spongepowered.api.item.ItemType;
import org.spongepowered.api.item.inventory.ItemStack;
+import org.spongepowered.api.item.inventory.ItemStackLike;
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
import org.spongepowered.api.registry.DefaultedRegistryReference;
@@ -53,11 +54,19 @@ static Ingredient empty() {
return Sponge.game().factoryProvider().provide(Factory.class).empty();
}
+ /**
+ * @deprecated Use {@link #test(ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
@Override
- boolean test(ItemStack itemStack);
+ default boolean test(ItemStack itemStack) {
+ return this.test((ItemStackLike) itemStack);
+ }
+
+ boolean test(ItemStackLike item);
/**
- * Returns the list of {@link ItemStack}s used to display the ingredient in a recipe.
+ * Returns the list of {@link ItemStackSnapshot}s used to display the ingredient in a recipe.
* These are not necessarily all the items that this Ingredient can match.
*
* @return The list of items to display the Ingredient in a recipe.
@@ -87,25 +96,28 @@ static Ingredient of(ItemType @Nullable ... itemTypes) {
}
/**
- * Creates a new {@link Ingredient} for the provided {@link ItemStack}s.
- *
- * @param items The items
- * @return The new ingredient
+ * @deprecated Use {@link #of(ItemStackLike...)} instead.
*/
+ @Deprecated(forRemoval = true)
static Ingredient of(ItemStack @Nullable ... items) {
- if (items == null || items.length == 0) {
- return Ingredient.empty();
- }
- return Ingredient.builder().with(items).build();
+ return Ingredient.of((ItemStackLike[]) items);
}
/**
- * Creates a new {@link Ingredient} for the provided {@link ItemStackSnapshot}s.
+ * @deprecated Use {@link #of(ItemStackLike...)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ static Ingredient of(ItemStackSnapshot @Nullable ... items) {
+ return Ingredient.of((ItemStackLike[]) items);
+ }
+
+ /**
+ * Creates a new {@link Ingredient} for the provided {@link ItemStackLike}s.
*
* @param items The item
* @return The new ingredient
*/
- static Ingredient of(ItemStackSnapshot @Nullable ... items) {
+ static Ingredient of(ItemStackLike @Nullable ... items) {
if (items == null) {
return Ingredient.empty();
}
@@ -127,7 +139,15 @@ static Ingredient of(DefaultedRegistryReference extends ItemType> @Nullable ..
}
/**
- * Creates a new {@link Ingredient} for the provided {@link Predicate} and exemplary {@link ItemStack}s.
+ * @deprecated Use {@link #of(ResourceKey, Predicate, ItemStackLike...)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ static Ingredient of(ResourceKey key, Predicate predicate, ItemStack... exemplaryStacks) {
+ return Ingredient.of(key, itemStack -> predicate.test(itemStack.asMutable()), (ItemStackLike[]) exemplaryStacks);
+ }
+
+ /**
+ * Creates a new {@link Ingredient} for the provided {@link Predicate} and exemplary {@link ItemStackLike}s.
* Note: Predicate ingredients may not be fully supported for all recipe types
*
* @param key A unique resource key
@@ -136,7 +156,7 @@ static Ingredient of(DefaultedRegistryReference extends ItemType> @Nullable ..
*
* @return The new ingredient
*/
- static Ingredient of(ResourceKey key, Predicate predicate, ItemStack... exemplaryStacks) {
+ static Ingredient of(ResourceKey key, Predicate super ItemStackLike> predicate, ItemStackLike... exemplaryStacks) {
if (exemplaryStacks.length == 0) {
throw new IllegalArgumentException("At least exemplary stack is required");
}
@@ -178,12 +198,28 @@ interface Builder extends org.spongepowered.api.util.Builder... types);
/**
- * Sets one ore more ItemStack for matching the ingredient.
+ * @deprecated Use {@link #with(ItemStackLike...)} instead
+ */
+ @Deprecated(forRemoval = true)
+ default Builder with(ItemStack... types) {
+ return this.with((ItemStackLike[]) types);
+ }
+
+ /**
+ * Sets one or more ItemStackLike for matching the ingredient.
*
* @param types The items
* @return This Builder, for chaining
*/
- Builder with(ItemStack... types);
+ Builder with(ItemStackLike... types);
+
+ /**
+ * @deprecated Use {@link #with(ResourceKey, Predicate, ItemStackLike...)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default Builder with(ResourceKey resourceKey, Predicate predicate, ItemStack... exemplaryTypes) {
+ return this.with(resourceKey, itemStack -> predicate.test(itemStack.asMutable()), (ItemStackLike[]) exemplaryTypes);
+ }
/**
* Sets a Predicate for matching the ingredient.
@@ -194,15 +230,15 @@ interface Builder extends org.spongepowered.api.util.Builder predicate, ItemStack... exemplaryTypes);
+ Builder with(ResourceKey resourceKey, Predicate super ItemStackLike> predicate, ItemStackLike... exemplaryTypes);
/**
- * Sets one ItemStack for matching the ingredient.
- *
- * @param types The items
- * @return This Builder, for chaining
+ * @deprecated Use {@link #with(ItemStackLike...)} instead
*/
- Builder with(ItemStackSnapshot... types);
+ @Deprecated(forRemoval = true)
+ default Builder with(ItemStackSnapshot... types) {
+ return this.with((ItemStackLike[]) types);
+ }
/**
* Sets the item tag for matching the ingredient.
diff --git a/src/main/java/org/spongepowered/api/item/recipe/crafting/RecipeInput.java b/src/main/java/org/spongepowered/api/item/recipe/crafting/RecipeInput.java
index 11981dd274..d31e8dcd1b 100644
--- a/src/main/java/org/spongepowered/api/item/recipe/crafting/RecipeInput.java
+++ b/src/main/java/org/spongepowered/api/item/recipe/crafting/RecipeInput.java
@@ -26,6 +26,7 @@
import org.spongepowered.api.item.inventory.Inventory;
import org.spongepowered.api.item.inventory.ItemStack;
+import org.spongepowered.api.item.inventory.ItemStackLike;
import org.spongepowered.api.item.inventory.type.GridInventory;
import org.spongepowered.api.item.recipe.cooking.CookingRecipe;
import org.spongepowered.api.item.recipe.single.StoneCutterRecipe;
@@ -65,6 +66,14 @@ interface Crafting extends RecipeInput {
interface Factory {
+ /**
+ * @deprecated Use {@link #single(ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default RecipeInput.Single single(ItemStack stack) {
+ return this.single((ItemStackLike) stack);
+ }
+
/**
* Creates a recipe input for
* {@link CookingRecipe} and
@@ -74,7 +83,15 @@ interface Factory {
*
* @return the recipe input
*/
- RecipeInput.Single single(ItemStack stack);
+ RecipeInput.Single single(ItemStackLike stack);
+
+ /**
+ * @deprecated Use {@link #smithing(ItemStackLike, ItemStackLike, ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default RecipeInput.Smithing smithing(ItemStack templateStack, ItemStack baseStack, ItemStack additionStack) {
+ return this.smithing((ItemStackLike) templateStack, (ItemStackLike) baseStack, (ItemStackLike) additionStack);
+ }
/**
* Creates a recipe input for {@link SmithingRecipe}
@@ -85,7 +102,7 @@ interface Factory {
*
* @return the recipe input
*/
- RecipeInput.Smithing smithing(ItemStack templateStack, ItemStack baseStack, ItemStack additionStack);
+ RecipeInput.Smithing smithing(ItemStackLike templateStack, ItemStackLike baseStack, ItemStackLike additionStack);
/**
* Creates a recipe input for {@link CraftingRecipe}
diff --git a/src/main/java/org/spongepowered/api/item/recipe/crafting/RecipeResult.java b/src/main/java/org/spongepowered/api/item/recipe/crafting/RecipeResult.java
index 3fff2cec29..d8128aa8db 100644
--- a/src/main/java/org/spongepowered/api/item/recipe/crafting/RecipeResult.java
+++ b/src/main/java/org/spongepowered/api/item/recipe/crafting/RecipeResult.java
@@ -24,12 +24,14 @@
*/
package org.spongepowered.api.item.recipe.crafting;
+import org.spongepowered.api.item.inventory.ItemStackLike;
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
import org.spongepowered.api.item.inventory.crafting.CraftingGridInventory;
import java.util.List;
import java.util.Objects;
import java.util.StringJoiner;
+import java.util.stream.Collectors;
/**
* The result of fulfilling a {@link CraftingRecipe}.
@@ -39,6 +41,14 @@ public final class RecipeResult {
private final ItemStackSnapshot result;
private final List remainingItems;
+ /**
+ * @deprecated Use {@link #RecipeResult(ItemStackLike, List)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ public RecipeResult(ItemStackSnapshot result, List remainingItems) {
+ this((ItemStackLike) result, (List extends ItemStackLike>) remainingItems);
+ }
+
/**
* Creates a new {@link RecipeResult}.
*
@@ -49,7 +59,7 @@ public final class RecipeResult {
* @param remainingItems The remaining items to leave in the
* crafting window
*/
- public RecipeResult(ItemStackSnapshot result, List remainingItems) {
+ public RecipeResult(ItemStackLike result, List extends ItemStackLike> remainingItems) {
Objects.requireNonNull(result, "result");
if (result.isEmpty()) {
throw new IllegalArgumentException("The result must not be empty!");
@@ -60,8 +70,8 @@ public RecipeResult(ItemStackSnapshot result, List remainingI
+ " It should contain empty ItemStackSnapshot values for slots which should be cleared.");
}
- this.result = result;
- this.remainingItems = List.copyOf(remainingItems);
+ this.result = result.asImmutable();
+ this.remainingItems = remainingItems.stream().map(ItemStackLike::asImmutable).toList();
}
/**
diff --git a/src/main/java/org/spongepowered/api/item/recipe/crafting/ShapedCraftingRecipe.java b/src/main/java/org/spongepowered/api/item/recipe/crafting/ShapedCraftingRecipe.java
index 570df7e2a8..388f2dbd46 100644
--- a/src/main/java/org/spongepowered/api/item/recipe/crafting/ShapedCraftingRecipe.java
+++ b/src/main/java/org/spongepowered/api/item/recipe/crafting/ShapedCraftingRecipe.java
@@ -29,6 +29,7 @@
import org.spongepowered.api.Sponge;
import org.spongepowered.api.datapack.DataPack;
import org.spongepowered.api.item.inventory.ItemStack;
+import org.spongepowered.api.item.inventory.ItemStackLike;
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
import org.spongepowered.api.item.recipe.RecipeRegistration;
import org.spongepowered.api.util.ResourceKeyedBuilder;
@@ -214,28 +215,44 @@ interface ResultStep extends Builder {
* @param remainingItemsFunction the remaining items function
*
* @return This builder, for chaining
+ * @deprecated Will be replaced with ItemStackLike variant
*/
- ResultStep remainingItems(Function> remainingItemsFunction);
+ @Deprecated
+ ResultStep remainingItems(Function> remainingItemsFunction);
/**
- * Sets the resultant {@link ItemStackSnapshot} for when this shaped
+ * @deprecated Use {@link #result(ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default EndStep result(ItemStackSnapshot result) {
+ return this.result((ItemStackLike) result);
+ }
+
+ /**
+ * @deprecated Use {@link #result(ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default EndStep result(ItemStack result) {
+ return this.result((ItemStackLike) result);
+ }
+
+ /**
+ * Sets the resultant {@link ItemStackLike} for when this shaped
* recipe is correctly crafted.
*
* @param result The resultant snapshot
*
* @return The builder
*/
- EndStep result(ItemStackSnapshot result);
+ EndStep result(ItemStackLike result);
/**
- * Sets the resultant {@link ItemStack} for when this shaped recipe
- * is correctly crafted.
- *
- * @param result The resultant stack
- *
- * @return The builder
+ * @deprecated Use {@link #result(Function, ItemStackLike)} instead.
*/
- EndStep result(ItemStack result);
+ @Deprecated(forRemoval = true)
+ default EndStep result(Function resultFunction, ItemStack exemplaryResult) {
+ return this.result(resultFunction, (ItemStackLike) exemplaryResult);
+ }
/**
* Sets the result function and an exemplary result.
@@ -246,7 +263,7 @@ interface ResultStep extends Builder {
*
* @return The builder
*/
- EndStep result(Function resultFunction, ItemStack exemplaryResult);
+ EndStep result(Function resultFunction, ItemStackLike exemplaryResult);
}
/**
diff --git a/src/main/java/org/spongepowered/api/item/recipe/crafting/ShapelessCraftingRecipe.java b/src/main/java/org/spongepowered/api/item/recipe/crafting/ShapelessCraftingRecipe.java
index b8c9dbe5a2..f32e54eab2 100644
--- a/src/main/java/org/spongepowered/api/item/recipe/crafting/ShapelessCraftingRecipe.java
+++ b/src/main/java/org/spongepowered/api/item/recipe/crafting/ShapelessCraftingRecipe.java
@@ -30,6 +30,7 @@
import org.spongepowered.api.datapack.DataPack;
import org.spongepowered.api.item.ItemType;
import org.spongepowered.api.item.inventory.ItemStack;
+import org.spongepowered.api.item.inventory.ItemStackLike;
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
import org.spongepowered.api.item.recipe.RecipeRegistration;
import org.spongepowered.api.util.ResourceKeyedBuilder;
@@ -98,27 +99,41 @@ interface ResultStep extends Builder {
*
* @return This builder, for chaining
*/
- ResultStep remainingItems(Function> remainingItemsFunction);
+ ResultStep remainingItems(Function> remainingItemsFunction);
/**
- * Sets the result and returns this builder. The result is the
- * {@link ItemStack} created when the recipe is fulfilled.
- *
- * @param result The result
- *
- * @return This builder, for chaining
+ * @deprecated Use {@link #result(ItemStackLike)} instead.
*/
- EndStep result(ItemStackSnapshot result);
+ @Deprecated(forRemoval = true)
+ default EndStep result(ItemStackSnapshot result) {
+ return this.result((ItemStackLike) result);
+ }
+
+ /**
+ * @deprecated Use {@link #result(ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default EndStep result(ItemStack result) {
+ return this.result((ItemStackLike) result);
+ }
/**
* Sets the result and returns this builder. The result is the
- * {@link ItemStack} created when the recipe is fulfilled.
+ * {@link ItemStackLike} created when the recipe is fulfilled.
*
* @param result The result
*
* @return This builder, for chaining
*/
- EndStep result(ItemStack result);
+ EndStep result(ItemStackLike result);
+
+ /**
+ * @deprecated Use {@link #result(Function, ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default EndStep result(Function resultFunction, ItemStack exemplaryResult) {
+ return this.result(resultFunction, (ItemStackLike) exemplaryResult);
+ }
/**
* Sets the result function and an exemplary result.
@@ -129,7 +144,7 @@ interface ResultStep extends Builder {
*
* @return This builder, for chaining
*/
- EndStep result(Function resultFunction, ItemStack exemplaryResult);
+ EndStep result(Function resultFunction, ItemStackLike exemplaryResult);
}
diff --git a/src/main/java/org/spongepowered/api/item/recipe/crafting/SpecialCraftingRecipe.java b/src/main/java/org/spongepowered/api/item/recipe/crafting/SpecialCraftingRecipe.java
index b46e9ecc0d..8f5e35d5bc 100644
--- a/src/main/java/org/spongepowered/api/item/recipe/crafting/SpecialCraftingRecipe.java
+++ b/src/main/java/org/spongepowered/api/item/recipe/crafting/SpecialCraftingRecipe.java
@@ -27,6 +27,7 @@
import org.spongepowered.api.Sponge;
import org.spongepowered.api.datapack.DataPack;
import org.spongepowered.api.item.inventory.ItemStack;
+import org.spongepowered.api.item.inventory.ItemStackLike;
import org.spongepowered.api.item.recipe.RecipeRegistration;
import org.spongepowered.api.util.ResourceKeyedBuilder;
import org.spongepowered.api.world.server.ServerWorld;
@@ -74,7 +75,7 @@ interface ResultStep extends Builder {
*
* @return This builder, for chaining
*/
- ResultStep remainingItems(Function> remainingItemsFunction);
+ ResultStep remainingItems(Function> remainingItemsFunction);
/**
* Sets the result function.
@@ -83,7 +84,15 @@ interface ResultStep extends Builder {
*
* @return This builder, for chaining
*/
- EndStep result(Function resultFunction);
+ EndStep result(Function resultFunction);
+
+ /**
+ * @deprecated Use {@link #result(ItemStackLike)} instead;
+ */
+ @Deprecated(forRemoval = true)
+ default EndStep result(ItemStack result) {
+ return this.result((ItemStackLike) result);
+ }
/**
* Sets the result
@@ -92,7 +101,7 @@ interface ResultStep extends Builder {
*
* @return This builder, for chaining
*/
- EndStep result(ItemStack result);
+ EndStep result(ItemStackLike result);
}
interface EndStep extends Builder, org.spongepowered.api.util.Builder {
diff --git a/src/main/java/org/spongepowered/api/item/recipe/single/StoneCutterRecipe.java b/src/main/java/org/spongepowered/api/item/recipe/single/StoneCutterRecipe.java
index 407e74c2f3..4f4ec3fce7 100644
--- a/src/main/java/org/spongepowered/api/item/recipe/single/StoneCutterRecipe.java
+++ b/src/main/java/org/spongepowered/api/item/recipe/single/StoneCutterRecipe.java
@@ -30,6 +30,7 @@
import org.spongepowered.api.datapack.DataPack;
import org.spongepowered.api.item.ItemType;
import org.spongepowered.api.item.inventory.ItemStack;
+import org.spongepowered.api.item.inventory.ItemStackLike;
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
import org.spongepowered.api.item.recipe.Recipe;
import org.spongepowered.api.item.recipe.RecipeRegistration;
@@ -90,35 +91,49 @@ default ResultStep ingredient(Supplier extends ItemType> ingredient) {
interface ResultStep extends StoneCutterRecipe.Builder {
/**
- * Changes the result and returns this builder. The result is the
- * {@link ItemStack} created when the recipe is fulfilled.
- *
- * @param result The output of this recipe
- *
- * @return This builder, for chaining
+ * @deprecated Use {@link #result(ItemStackLike)} instead.
*/
- EndStep result(ItemStackSnapshot result);
+ @Deprecated(forRemoval = true)
+ default EndStep result(ItemStackSnapshot result) {
+ return this.result((ItemStackLike) result);
+ }
+
+ /**
+ * @deprecated Use {@link #result(ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default EndStep result(ItemStack result) {
+ return this.result((ItemStackLike) result);
+ }
/**
* Changes the result and returns this builder. The result is the
- * {@link ItemStack} created when the recipe is fulfilled.
+ * {@link ItemStackLike} created when the recipe is fulfilled.
*
* @param result The output of this recipe
*
* @return This builder, for chaining
*/
- EndStep result(ItemStack result);
+ EndStep result(ItemStackLike result);
+
+ /**
+ * @deprecated Use {@link #result(Function, ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default EndStep result(Function resultFunction, ItemStack exemplaryResult) {
+ return this.result(resultFunction, (ItemStackLike) exemplaryResult);
+ }
/**
* Changes the result and returns this builder. The result is the
- * {@link ItemStack} created when the recipe is fulfilled.
+ * {@link ItemStackLike} created when the recipe is fulfilled.
*
* @param resultFunction The result function
* @param exemplaryResult The exemplary output of this recipe
*
* @return This builder, for chaining
*/
- EndStep result(Function resultFunction, ItemStack exemplaryResult);
+ EndStep result(Function resultFunction, ItemStackLike exemplaryResult);
}
diff --git a/src/main/java/org/spongepowered/api/item/recipe/smithing/SmithingRecipe.java b/src/main/java/org/spongepowered/api/item/recipe/smithing/SmithingRecipe.java
index 9c57d1c057..9520273623 100644
--- a/src/main/java/org/spongepowered/api/item/recipe/smithing/SmithingRecipe.java
+++ b/src/main/java/org/spongepowered/api/item/recipe/smithing/SmithingRecipe.java
@@ -30,6 +30,7 @@
import org.spongepowered.api.datapack.DataPack;
import org.spongepowered.api.item.ItemType;
import org.spongepowered.api.item.inventory.ItemStack;
+import org.spongepowered.api.item.inventory.ItemStackLike;
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
import org.spongepowered.api.item.recipe.Recipe;
import org.spongepowered.api.item.recipe.RecipeRegistration;
@@ -155,35 +156,49 @@ default ResultStep addition(Supplier extends ItemType> ingredient) {
interface ResultStep extends SmithingRecipe.Builder {
/**
- * Changes the result and returns this builder. The result is the
- * {@link ItemStack} created when the recipe is fulfilled.
- *
- * @param result The output of this recipe
- *
- * @return This builder, for chaining
+ * @deprecated Use {@link #result(ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default EndStep result(ItemStackSnapshot result) {
+ return this.result((ItemStackLike) result);
+ }
+
+ /**
+ * @deprecated Use {@link #result(ItemStackLike)} instead.
*/
- EndStep result(ItemStackSnapshot result);
+ @Deprecated(forRemoval = true)
+ default EndStep result(ItemStack result) {
+ return this.result((ItemStackLike) result);
+ }
/**
* Changes the result and returns this builder. The result is the
- * {@link ItemStack} created when the recipe is fulfilled.
+ * {@link ItemStackLike} created when the recipe is fulfilled.
*
* @param result The output of this recipe
*
* @return This builder, for chaining
*/
- EndStep result(ItemStack result);
+ EndStep result(ItemStackLike result);
+
+ /**
+ * @deprecated Use {@link #result(Function, ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default EndStep result(Function resultFunction, ItemStack exemplaryResult) {
+ return this.result(resultFunction, (ItemStackLike) exemplaryResult);
+ }
/**
* Changes the result and returns this builder. The result is the
- * {@link ItemStack} created when the recipe is fulfilled.
+ * {@link ItemStackLike} created when the recipe is fulfilled.
*
* @param resultFunction The result function
* @param exemplaryResult The exemplary output of this recipe
*
* @return This builder, for chaining
*/
- EndStep result(Function resultFunction, ItemStack exemplaryResult);
+ EndStep result(Function resultFunction, ItemStackLike exemplaryResult);
}
From ffd4e09c7da3ee7bd23297e47fbdf9250cf97659 Mon Sep 17 00:00:00 2001
From: MrHell228
Date: Sat, 14 Sep 2024 15:10:05 +0300
Subject: [PATCH 06/14] Migrate enchantments and trade offers
---
.../api/item/enchantment/EnchantmentType.java | 25 ++++++++++++---
.../api/item/merchant/TradeOffer.java | 31 +++++++++++++++++--
2 files changed, 49 insertions(+), 7 deletions(-)
diff --git a/src/main/java/org/spongepowered/api/item/enchantment/EnchantmentType.java b/src/main/java/org/spongepowered/api/item/enchantment/EnchantmentType.java
index b3dececc7a..2d324dabc2 100644
--- a/src/main/java/org/spongepowered/api/item/enchantment/EnchantmentType.java
+++ b/src/main/java/org/spongepowered/api/item/enchantment/EnchantmentType.java
@@ -27,6 +27,7 @@
import net.kyori.adventure.text.ComponentLike;
import org.spongepowered.api.block.entity.EnchantmentTable;
import org.spongepowered.api.item.inventory.ItemStack;
+import org.spongepowered.api.item.inventory.ItemStackLike;
import org.spongepowered.api.registry.DefaultedRegistryValue;
import org.spongepowered.api.tag.EnchantmenTypeTags;
import org.spongepowered.api.tag.Taggable;
@@ -82,22 +83,38 @@ public interface EnchantmentType extends DefaultedRegistryValue, ComponentLike,
int maximumEnchantabilityForLevel(int level);
/**
- * Test if this enchantment type can be applied to an {@link ItemStack}.
+ * @deprecated Use {@link #canBeAppliedToStack(ItemStackLike)} instead,
+ */
+ @Deprecated(forRemoval = true)
+ default boolean canBeAppliedToStack(ItemStack stack) {
+ return this.canBeAppliedToStack((ItemStackLike) stack);
+ }
+
+ /**
+ * Test if this enchantment type can be applied to an {@link ItemStackLike}.
*
* @param stack The item stack to check
* @return Whether this enchantment type can be applied
*/
- boolean canBeAppliedToStack(ItemStack stack);
+ boolean canBeAppliedToStack(ItemStackLike stack);
+
+ /**
+ * @deprecated Use {@link #canBeAppliedToStack(ItemStackLike)} instead,
+ */
+ @Deprecated(forRemoval = true)
+ default boolean canBeAppliedByTable(ItemStack stack) {
+ return this.canBeAppliedByTable((ItemStackLike) stack);
+ }
/**
- * Test if this enchantment type can be applied to an {@link ItemStack} by
+ * Test if this enchantment type can be applied to an {@link ItemStackLike} by
* the {@link EnchantmentTable}.
*
* @param stack Te item stack to check
* @return Whether this enchantment type can be applied by the
* enchantment table
*/
- boolean canBeAppliedByTable(ItemStack stack);
+ boolean canBeAppliedByTable(ItemStackLike stack);
/**
* Test if this enchantment type can be applied along with
diff --git a/src/main/java/org/spongepowered/api/item/merchant/TradeOffer.java b/src/main/java/org/spongepowered/api/item/merchant/TradeOffer.java
index a6d7370595..b57641df73 100644
--- a/src/main/java/org/spongepowered/api/item/merchant/TradeOffer.java
+++ b/src/main/java/org/spongepowered/api/item/merchant/TradeOffer.java
@@ -29,6 +29,7 @@
import org.spongepowered.api.data.persistence.DataSerializable;
import org.spongepowered.api.entity.living.Humanoid;
import org.spongepowered.api.item.inventory.ItemStack;
+import org.spongepowered.api.item.inventory.ItemStackLike;
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
import org.spongepowered.api.util.CopyableBuilder;
@@ -164,6 +165,14 @@ static Builder builder() {
*/
interface Builder extends org.spongepowered.api.util.Builder, CopyableBuilder, DataBuilder {
+ /**
+ * @deprecated Use {@link #firstBuyingItem(ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default Builder firstBuyingItem(ItemStack item) {
+ return this.firstBuyingItem((ItemStackLike) item);
+ }
+
/**
* Sets the first selling item of the trade offer to be
* generated.
@@ -173,7 +182,15 @@ interface Builder extends org.spongepowered.api.util.Builder
Date: Mon, 16 Sep 2024 00:45:09 +0300
Subject: [PATCH 07/14] Migrate Equipable
---
.../api/item/inventory/ArmorEquipable.java | 60 +++++++++++++++++--
.../api/item/inventory/Equipable.java | 36 ++++++++++-
.../equipment/EquipmentInventory.java | 21 ++++++-
3 files changed, 107 insertions(+), 10 deletions(-)
diff --git a/src/main/java/org/spongepowered/api/item/inventory/ArmorEquipable.java b/src/main/java/org/spongepowered/api/item/inventory/ArmorEquipable.java
index aa82af5725..964fd3e6d8 100644
--- a/src/main/java/org/spongepowered/api/item/inventory/ArmorEquipable.java
+++ b/src/main/java/org/spongepowered/api/item/inventory/ArmorEquipable.java
@@ -46,12 +46,20 @@ public interface ArmorEquipable extends Equipable {
*/
ItemStack head();
+ /**
+ * @deprecated Use {@link #setHead(ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default void setHead(ItemStack head) {
+ this.setHead((ItemStackLike) head);
+ }
+
/**
* Sets the head.
*
* @param head The head
*/
- void setHead(ItemStack head);
+ void setHead(ItemStackLike head);
/**
* Gets the chest.
@@ -60,12 +68,20 @@ public interface ArmorEquipable extends Equipable {
*/
ItemStack chest();
+ /**
+ * @deprecated Use {@link #setChest(ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default void setChest(ItemStack chest) {
+ this.setChest((ItemStackLike) chest);
+ }
+
/**
* Sets the chest.
*
* @param chest The chest
*/
- void setChest(ItemStack chest);
+ void setChest(ItemStackLike chest);
/**
* Gets the legs.
@@ -74,12 +90,20 @@ public interface ArmorEquipable extends Equipable {
*/
ItemStack legs();
+ /**
+ * @deprecated Use {@link #setLegs(ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default void setLegs(ItemStack legs) {
+ this.setLegs((ItemStackLike) legs);
+ }
+
/**
* Sets the legs.
*
* @param legs The legs
*/
- void setLegs(ItemStack legs);
+ void setLegs(ItemStackLike legs);
/**
* Gets the feet.
@@ -88,12 +112,20 @@ public interface ArmorEquipable extends Equipable {
*/
ItemStack feet();
+ /**
+ * @deprecated Use {@link #setFeet(ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default void setFeet(ItemStack feet) {
+ this.setFeet((ItemStackLike) feet);
+ }
+
/**
* Sets the feet.
*
* @param feet The feet
*/
- void setFeet(ItemStack feet);
+ void setFeet(ItemStackLike feet);
/**
* Gets the equipped item in hand.
@@ -113,21 +145,37 @@ default ItemStack itemInHand(Supplier extends HandType> handType) {
*/
ItemStack itemInHand(HandType handType);
+ /**
+ * @deprecated Use {@link #setItemInHand(Supplier, ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default void setItemInHand(Supplier extends HandType> handType, ItemStack itemInHand) {
+ this.setItemInHand(handType, (ItemStackLike) itemInHand);
+ }
+
/**
* Sets the equipped item in hand.
*
* @param handType The hand type to set to
* @param itemInHand The item in hand
*/
- default void setItemInHand(Supplier extends HandType> handType, ItemStack itemInHand) {
+ default void setItemInHand(Supplier extends HandType> handType, ItemStackLike itemInHand) {
this.setItemInHand(handType.get(), itemInHand);
}
+ /**
+ * @deprecated Use {@link #setItemInHand(HandType, ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default void setItemInHand(HandType handType, ItemStack itemInHand) {
+ this.setItemInHand(handType, (ItemStackLike) itemInHand);
+ }
+
/**
* Sets the equipped item in hand.
*
* @param handType The hand type to set to
* @param itemInHand The item in hand
*/
- void setItemInHand(HandType handType, ItemStack itemInHand);
+ void setItemInHand(HandType handType, ItemStackLike itemInHand);
}
diff --git a/src/main/java/org/spongepowered/api/item/inventory/Equipable.java b/src/main/java/org/spongepowered/api/item/inventory/Equipable.java
index 686f50a633..974c5c16d2 100644
--- a/src/main/java/org/spongepowered/api/item/inventory/Equipable.java
+++ b/src/main/java/org/spongepowered/api/item/inventory/Equipable.java
@@ -56,6 +56,14 @@ default boolean canEquip(final Supplier extends EquipmentType> type) {
return this.canEquip(type.get());
}
+ /**
+ * @deprecated Use {@link #canEquip(EquipmentType, ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default boolean canEquip(EquipmentType type, ItemStack equipment) {
+ return this.canEquip(type, (ItemStackLike) equipment);
+ }
+
/**
* Gets whether this {@link Equipable} can equip the supplied equipment in its slot of
* the specified type (eg. whether calling {@link #equip} with the specified
@@ -65,9 +73,17 @@ default boolean canEquip(final Supplier extends EquipmentType> type) {
* @param equipment The equipment to check for
* @return true if can equip the supplied equipment
*/
- boolean canEquip(EquipmentType type, ItemStack equipment);
+ boolean canEquip(EquipmentType type, ItemStackLike equipment);
+ /**
+ * @deprecated Use {@link #canEquip(Supplier, ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
default boolean canEquip(final Supplier extends EquipmentType> type, final ItemStack equipment) {
+ return this.canEquip(type, (ItemStackLike) equipment);
+ }
+
+ default boolean canEquip(final Supplier extends EquipmentType> type, final ItemStackLike equipment) {
return this.canEquip(type.get(), equipment);
}
@@ -84,6 +100,14 @@ default Optional equipped(final Supplier extends EquipmentType> typ
return this.equipped(type.get());
}
+ /**
+ * @deprecated Use {@link #equip(EquipmentType, ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default boolean equip(EquipmentType type, ItemStack equipment) {
+ return this.equip(type, (ItemStackLike) equipment);
+ }
+
/**
* Sets the item currently equipped by the {@link Equipable} in the specified slot, if
* the equipable has such a slot.
@@ -95,9 +119,17 @@ default Optional equipped(final Supplier extends EquipmentType> typ
* specified equipment type or because the item was incompatible with
* the specified slot.
*/
- boolean equip(EquipmentType type, ItemStack equipment);
+ boolean equip(EquipmentType type, ItemStackLike equipment);
+ /**
+ * @deprecated Use {@link #equip(Supplier, ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
default boolean equip(final Supplier extends EquipmentType> type, final ItemStack equipment) {
+ return this.equip(type, (ItemStackLike) equipment);
+ }
+
+ default boolean equip(final Supplier extends EquipmentType> type, final ItemStackLike equipment) {
return this.equip(type.get(), equipment);
}
}
diff --git a/src/main/java/org/spongepowered/api/item/inventory/equipment/EquipmentInventory.java b/src/main/java/org/spongepowered/api/item/inventory/equipment/EquipmentInventory.java
index 685f49f18d..321069ebb1 100644
--- a/src/main/java/org/spongepowered/api/item/inventory/equipment/EquipmentInventory.java
+++ b/src/main/java/org/spongepowered/api/item/inventory/equipment/EquipmentInventory.java
@@ -27,6 +27,7 @@
import org.spongepowered.api.item.inventory.Equipable;
import org.spongepowered.api.item.inventory.Inventory;
import org.spongepowered.api.item.inventory.ItemStack;
+import org.spongepowered.api.item.inventory.ItemStackLike;
import org.spongepowered.api.item.inventory.Slot;
import org.spongepowered.api.item.inventory.transaction.InventoryTransactionResult;
@@ -88,17 +89,33 @@ default Optional peek(final Supplier extends EquipmentType> equipme
return this.peek(equipmentType.get());
}
+ /**
+ * @deprecated Use {@link #set(EquipmentType, ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default InventoryTransactionResult set(EquipmentType equipmentType, ItemStack stack) {
+ return this.set(equipmentType, (ItemStackLike) stack);
+ }
+
/**
* Sets the item for the specified equipment type.
*
- * @see Slot#set(ItemStack)
+ * @see Slot#set(ItemStackLike)
* @param equipmentType Type of equipment slot to set
* @param stack stack to insert
* @return operation result, for details see {@link Inventory#set}
*/
- InventoryTransactionResult set(EquipmentType equipmentType, ItemStack stack);
+ InventoryTransactionResult set(EquipmentType equipmentType, ItemStackLike stack);
+ /**
+ * @deprecated Use {@link #set(Supplier, ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
default InventoryTransactionResult set(final Supplier extends EquipmentType> equipmentType, final ItemStack stack) {
+ return this.set(equipmentType, (ItemStackLike) stack);
+ }
+
+ default InventoryTransactionResult set(final Supplier extends EquipmentType> equipmentType, final ItemStackLike stack) {
return this.set(equipmentType.get(), stack);
}
From 06778f44555677c081f75cc2e791428b4434a81f Mon Sep 17 00:00:00 2001
From: MrHell228
Date: Mon, 16 Sep 2024 01:41:50 +0300
Subject: [PATCH 08/14] Migrate item transactions
---
.../InventoryTransactionResult.java | 29 +++++++++++++++----
.../transaction/SlotTransaction.java | 13 +++++++--
2 files changed, 34 insertions(+), 8 deletions(-)
diff --git a/src/main/java/org/spongepowered/api/item/inventory/transaction/InventoryTransactionResult.java b/src/main/java/org/spongepowered/api/item/inventory/transaction/InventoryTransactionResult.java
index d7d636fb4a..a516faaa56 100644
--- a/src/main/java/org/spongepowered/api/item/inventory/transaction/InventoryTransactionResult.java
+++ b/src/main/java/org/spongepowered/api/item/inventory/transaction/InventoryTransactionResult.java
@@ -27,6 +27,7 @@
import org.spongepowered.api.Sponge;
import org.spongepowered.api.item.inventory.Inventory;
import org.spongepowered.api.item.inventory.ItemStack;
+import org.spongepowered.api.item.inventory.ItemStackLike;
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
import org.spongepowered.api.util.CopyableBuilder;
@@ -179,31 +180,47 @@ interface Builder extends org.spongepowered.api.util.Builder itemStacks);
+ Builder reject(Iterable extends ItemStackLike> itemStacks);
+
+ /**
+ * @deprecated Use {@link #poll(ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default Builder.PollBuilder poll(ItemStackSnapshot itemStack) {
+ return this.poll((ItemStackLike) itemStack);
+ }
/**
- * Sets the provided {@link ItemStackSnapshot} as the stack that has been polled from the inventory.
+ * Sets the provided {@link ItemStackLike} as the stack that has been polled from the inventory.
*
* @param itemStack The polled itemstack
*
* @return This builder, for chaining
*/
- Builder.PollBuilder poll(ItemStackSnapshot itemStack);
+ Builder.PollBuilder poll(ItemStackLike itemStack);
/**
* Adds the provided {@link ItemStack itemstacks} as stacks that are
diff --git a/src/main/java/org/spongepowered/api/item/inventory/transaction/SlotTransaction.java b/src/main/java/org/spongepowered/api/item/inventory/transaction/SlotTransaction.java
index cf25725a58..da31f15953 100644
--- a/src/main/java/org/spongepowered/api/item/inventory/transaction/SlotTransaction.java
+++ b/src/main/java/org/spongepowered/api/item/inventory/transaction/SlotTransaction.java
@@ -26,6 +26,7 @@
import org.spongepowered.api.data.Transaction;
import org.spongepowered.api.item.inventory.ItemStack;
+import org.spongepowered.api.item.inventory.ItemStackLike;
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
import org.spongepowered.api.item.inventory.Slot;
@@ -51,12 +52,20 @@ public SlotTransaction(Slot slot, ItemStackSnapshot original, ItemStackSnapshot
}
/**
- * Sets the custom {@link ItemStack} output of this
+ * @deprecated Use {@link #setCustom(ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ public void setCustom(ItemStack stack) {
+ this.setCustom((ItemStackLike) stack);
+ }
+
+ /**
+ * Sets the custom {@link ItemStackLike} output of this
* {@link SlotTransaction}.
*
* @param stack The stack
*/
- public void setCustom(ItemStack stack) {
+ public void setCustom(ItemStackLike stack) {
this.setCustom(Objects.requireNonNull(stack, "ItemStack was null").asImmutable());
}
From 68d2ef7fc47f158abeac97ba736b5c8c20f7bd9a Mon Sep 17 00:00:00 2001
From: MrHell228
Date: Mon, 16 Sep 2024 01:59:12 +0300
Subject: [PATCH 09/14] Migrade slots
---
.../api/item/inventory/Container.java | 10 ++-
.../api/item/inventory/Inventory.java | 68 ++++++++++++++++---
.../api/item/inventory/Slot.java | 10 ++-
.../item/inventory/slot/FilteringSlot.java | 13 +++-
.../api/item/inventory/slot/SidedSlot.java | 33 +++++++--
5 files changed, 116 insertions(+), 18 deletions(-)
diff --git a/src/main/java/org/spongepowered/api/item/inventory/Container.java b/src/main/java/org/spongepowered/api/item/inventory/Container.java
index 8eb784482b..35e360e428 100644
--- a/src/main/java/org/spongepowered/api/item/inventory/Container.java
+++ b/src/main/java/org/spongepowered/api/item/inventory/Container.java
@@ -59,6 +59,14 @@ public interface Container extends Inventory {
*/
List viewed();
+ /**
+ * @deprecated Use {@link #setCursor(ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default boolean setCursor(ItemStack item) {
+ return this.setCursor((ItemStackLike) item);
+ }
+
/**
* Sets the viewing players cursor item.
* Returns false when the container is no longer open.
@@ -67,7 +75,7 @@ public interface Container extends Inventory {
*
* @return true if the cursor was set.
*/
- boolean setCursor(ItemStack item);
+ boolean setCursor(ItemStackLike item);
/**
* Gets the viewing players cursor item.
diff --git a/src/main/java/org/spongepowered/api/item/inventory/Inventory.java b/src/main/java/org/spongepowered/api/item/inventory/Inventory.java
index e6ea6da924..a28eb59808 100644
--- a/src/main/java/org/spongepowered/api/item/inventory/Inventory.java
+++ b/src/main/java/org/spongepowered/api/item/inventory/Inventory.java
@@ -142,6 +142,14 @@ static Builder builder() {
*/
ItemStack peek();
+ /**
+ * @deprecated Use {@link #offer(ItemStackLike...)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default InventoryTransactionResult offer(ItemStack... stacks) {
+ return this.offer((ItemStackLike[]) stacks);
+ }
+
/**
* Adds one or more ItemStacks to this inventory.
*
@@ -150,18 +158,26 @@ static Builder builder() {
* @return A SUCCESS transaction-result if all stacks were added and
* FAILURE when at least one stack was not or only partially added to the inventory.
*/
- InventoryTransactionResult offer(ItemStack... stacks);
+ InventoryTransactionResult offer(ItemStackLike... stacks);
+
+ /**
+ * @deprecated Use {@link #canFit(ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default boolean canFit(ItemStack stack) {
+ return this.canFit((ItemStackLike) stack);
+ }
/**
* Returns true if the entire stack can fit in this inventory.
*
- * If this returns {@code true} {@link #offer(ItemStack...)} should always succeed.
+ * If this returns {@code true} {@link #offer(ItemStackLike...)} should always succeed.
*
* @param stack The stack of items to check if it can fit in this inventory.
*
* @return true if the entire stack can fit in this inventory.
*/
- boolean canFit(ItemStack stack);
+ boolean canFit(ItemStackLike stack);
/**
* Gets and removes the stack at the supplied index in this Inventory.
@@ -198,9 +214,17 @@ static Builder builder() {
*/
Optional peekAt(int index);
+ /**
+ * @deprecated Use {@link #offer(int, ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default InventoryTransactionResult offer(int index, ItemStack stack) {
+ return this.offer(index, (ItemStackLike) stack);
+ }
+
/**
* Adds an ItemStack to the slot at given index.
- * Returns a {@link InventoryTransactionResult.Type#SUCCESS} only if the entire {@link ItemStack} fits the slot.
+ * Returns a {@link InventoryTransactionResult.Type#SUCCESS} only if the entire {@link ItemStackLike} fits the slot.
*
* @param index The slot index
* @param stack The stack to add to this inventory.
@@ -208,7 +232,15 @@ static Builder builder() {
* @return A SUCCESS transaction-result if the entire stack was added and
* FAILURE when the stack was not or only partially added to the inventory.
*/
- InventoryTransactionResult offer(int index, ItemStack stack);
+ InventoryTransactionResult offer(int index, ItemStackLike stack);
+
+ /**
+ * @deprecated Use {@link #set(int, ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default InventoryTransactionResult set(int index, ItemStack stack) {
+ return this.set(index, (ItemStackLike) stack);
+ }
/**
* Adds the ItemStack to the slot at given index overwriting the existing item.
@@ -223,7 +255,7 @@ static Builder builder() {
* @return A SUCCESS transaction-result if the entire stack was added and
* FAILURE when the stack was not or only partially added to the inventory.
*/
- InventoryTransactionResult set(int index, ItemStack stack);
+ InventoryTransactionResult set(int index, ItemStackLike stack);
/**
* Gets the {@link Slot} at the given index.
@@ -260,15 +292,23 @@ static Builder builder() {
*/
int capacity();
+ /**
+ * @deprecated Use {@link #contains(ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default boolean contains(ItemStack stack) {
+ return this.contains((ItemStackLike) stack);
+ }
+
/**
* Checks whether the stacks quantity or more of given stack is contained in this Inventory.
- * To check if an inventory contains any amount use {@link #containsAny(ItemStack)}.
+ * To check if an inventory contains any amount use {@link #containsAny(ItemStackLike)}.
*
* @param stack The stack to check for
*
* @return True if there are at least the given stack's amount of items present in this inventory.
*/
- boolean contains(ItemStack stack);
+ boolean contains(ItemStackLike stack);
/**
* Checks whether the given ItemType is contained in this Inventory
@@ -279,18 +319,26 @@ static Builder builder() {
*/
boolean contains(ItemType type);
+ /**
+ * @deprecated Use {@link #containsAny(ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default boolean containsAny(ItemStack stack) {
+ return this.containsAny((ItemStackLike) stack);
+ }
+
/**
* Checks whether the given stack is contained in this Inventory.
* The stack size is ignored.
*
* Note this will return true if any amount of the supplied stack is found.
- * To check if an inventory contains at least a given quantity use {@link #contains(ItemStack)}.
+ * To check if an inventory contains at least a given quantity use {@link #contains(ItemStackLike)}.
*
* @param stack The stack to check for
*
* @return True if the stack is present in this inventory
*/
- boolean containsAny(ItemStack stack);
+ boolean containsAny(ItemStackLike stack);
// TODO remove from API? do we need to get a property relative to another parent in API?
/**
diff --git a/src/main/java/org/spongepowered/api/item/inventory/Slot.java b/src/main/java/org/spongepowered/api/item/inventory/Slot.java
index 228f76b028..446f005b3a 100644
--- a/src/main/java/org/spongepowered/api/item/inventory/Slot.java
+++ b/src/main/java/org/spongepowered/api/item/inventory/Slot.java
@@ -38,6 +38,14 @@ public interface Slot extends Inventory {
*/
Slot viewedSlot();
+ /**
+ * @deprecated Use {@link #set(ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default InventoryTransactionResult set(ItemStack stack) {
+ return this.set((ItemStackLike) stack);
+ }
+
/**
* Adds the ItemStack to this slot overwriting the existing item.
*
@@ -48,5 +56,5 @@ public interface Slot extends Inventory {
* @return A SUCCESS transaction-result if the entire stack was added and
* FAILURE when the stack was not or only partially added to the inventory.
*/
- InventoryTransactionResult set(ItemStack stack);
+ InventoryTransactionResult set(ItemStackLike stack);
}
diff --git a/src/main/java/org/spongepowered/api/item/inventory/slot/FilteringSlot.java b/src/main/java/org/spongepowered/api/item/inventory/slot/FilteringSlot.java
index a3e51cba0c..97e94d11e0 100644
--- a/src/main/java/org/spongepowered/api/item/inventory/slot/FilteringSlot.java
+++ b/src/main/java/org/spongepowered/api/item/inventory/slot/FilteringSlot.java
@@ -26,6 +26,7 @@
import org.spongepowered.api.item.ItemType;
import org.spongepowered.api.item.inventory.ItemStack;
+import org.spongepowered.api.item.inventory.ItemStackLike;
import org.spongepowered.api.item.inventory.Slot;
/**
@@ -33,15 +34,23 @@
*/
public interface FilteringSlot extends Slot {
+ /**
+ * @deprecated Use {@link #isValidItem(ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default boolean isValidItem(ItemStack stack) {
+ return this.isValidItem((ItemStackLike) stack);
+ }
+
/**
* Check whether the supplied item can be inserted into this slot. Returning
* false from this method implies that {@link #offer} would always return
* false for this item.
*
- * @param stack ItemStack to check
+ * @param stack ItemStackLike to check
* @return true if the stack is valid for this slot
*/
- boolean isValidItem(ItemStack stack);
+ boolean isValidItem(ItemStackLike stack);
/**
* Check whether the supplied item can be inserted into this slot. Returning
diff --git a/src/main/java/org/spongepowered/api/item/inventory/slot/SidedSlot.java b/src/main/java/org/spongepowered/api/item/inventory/slot/SidedSlot.java
index dff05a269c..754977e8a5 100644
--- a/src/main/java/org/spongepowered/api/item/inventory/slot/SidedSlot.java
+++ b/src/main/java/org/spongepowered/api/item/inventory/slot/SidedSlot.java
@@ -26,6 +26,7 @@
import org.spongepowered.api.item.inventory.Inventory;
import org.spongepowered.api.item.inventory.ItemStack;
+import org.spongepowered.api.item.inventory.ItemStackLike;
import org.spongepowered.api.item.inventory.Slot;
import org.spongepowered.api.util.Direction;
@@ -34,6 +35,14 @@
*/
public interface SidedSlot extends Slot {
+ /**
+ * @deprecated Use {@link #canAccept(ItemStackLike, Direction)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default boolean canAccept(ItemStack stack, Direction from) {
+ return this.canAccept((ItemStackLike) stack, from);
+ }
+
/**
* Gets whether this slot can accept the specified item from the specified
* direction.
@@ -43,19 +52,35 @@ public interface SidedSlot extends Slot {
* @return true if this inventory can accept the supplied stack from the
* specified direction
*/
- boolean canAccept(ItemStack stack, Direction from);
+ boolean canAccept(ItemStackLike stack, Direction from);
+
+ /**
+ * @deprecated Use {@link #offer(ItemStackLike, Direction)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default boolean offer(ItemStack stack, Direction from) {
+ return this.offer((ItemStackLike) stack, from);
+ }
/**
* Attempts to insert the supplied stack into this inventory from the
* specified direction.
*
- * @see Inventory#offer(ItemStack...)
+ * @see Inventory#offer(ItemStackLike...)
* @param stack Stack to insert
* @param from Direction to check for insertion from
* @return true if this inventory can accept the supplied stack from the
* specified direction
*/
- boolean offer(ItemStack stack, Direction from);
+ boolean offer(ItemStackLike stack, Direction from);
+
+ /**
+ * @deprecated Use {@link #canGet(ItemStackLike, Direction)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default boolean canGet(ItemStack stack, Direction from) {
+ return this.canGet((ItemStackLike) stack, from);
+ }
/**
* Gets whether automation can extract the specified item from the specified
@@ -66,6 +91,6 @@ public interface SidedSlot extends Slot {
* @return true if automation can retrieve the supplied stack from the
* specified direction
*/
- boolean canGet(ItemStack stack, Direction from);
+ boolean canGet(ItemStackLike stack, Direction from);
}
From 26492d4356d264efa4d8c95ca84854f95606fbf2 Mon Sep 17 00:00:00 2001
From: MrHell228
Date: Mon, 16 Sep 2024 02:18:10 +0300
Subject: [PATCH 10/14] Migrate inventory.type package
---
.../api/item/inventory/type/GridInventory.java | 13 +++++++++++--
.../api/item/inventory/type/Inventory2D.java | 13 +++++++++++--
.../api/item/inventory/type/ViewableInventory.java | 11 ++++++++++-
3 files changed, 32 insertions(+), 5 deletions(-)
diff --git a/src/main/java/org/spongepowered/api/item/inventory/type/GridInventory.java b/src/main/java/org/spongepowered/api/item/inventory/type/GridInventory.java
index 4ca9dc95ef..48b6fd8470 100644
--- a/src/main/java/org/spongepowered/api/item/inventory/type/GridInventory.java
+++ b/src/main/java/org/spongepowered/api/item/inventory/type/GridInventory.java
@@ -26,6 +26,7 @@
import org.spongepowered.api.item.inventory.Inventory;
import org.spongepowered.api.item.inventory.ItemStack;
+import org.spongepowered.api.item.inventory.ItemStackLike;
import org.spongepowered.api.item.inventory.Slot;
import org.spongepowered.api.item.inventory.transaction.InventoryTransactionResult;
import org.spongepowered.math.vector.Vector2i;
@@ -95,16 +96,24 @@ public interface GridInventory extends Inventory2D {
*/
Optional peek(int x, int y);
+ /**
+ * @deprecated Use {@link #set(int, int, ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default InventoryTransactionResult set(int x, int y, ItemStack stack) {
+ return this.set(x, y, (ItemStackLike) stack);
+ }
+
/**
* Sets the item in the specified slot.
*
- * @see Slot#set(ItemStack)
+ * @see Slot#set(ItemStackLike)
* @param x x coordinate
* @param y y coordinate
* @param stack Item stack to insert
* @return operation result
*/
- InventoryTransactionResult set(int x, int y, ItemStack stack);
+ InventoryTransactionResult set(int x, int y, ItemStackLike stack);
/**
* Gets the {@link Slot} at the specified position.
diff --git a/src/main/java/org/spongepowered/api/item/inventory/type/Inventory2D.java b/src/main/java/org/spongepowered/api/item/inventory/type/Inventory2D.java
index 4b61b744c7..990fa0dbcf 100644
--- a/src/main/java/org/spongepowered/api/item/inventory/type/Inventory2D.java
+++ b/src/main/java/org/spongepowered/api/item/inventory/type/Inventory2D.java
@@ -26,6 +26,7 @@
import org.spongepowered.api.item.inventory.Inventory;
import org.spongepowered.api.item.inventory.ItemStack;
+import org.spongepowered.api.item.inventory.ItemStackLike;
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
import org.spongepowered.api.item.inventory.Slot;
import org.spongepowered.api.item.inventory.transaction.InventoryTransactionResult;
@@ -73,15 +74,23 @@ default Optional peek(Vector2i pos) {
return this.slot(pos).map(Inventory::peek);
}
+ /**
+ * @deprecated Use {@link #set(Vector2i, ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default InventoryTransactionResult set(Vector2i pos, ItemStack stack) {
+ return this.set(pos, (ItemStackLike) stack);
+ }
+
/**
* Sets the item in the specified slot.
*
- * @see Slot#set(ItemStack)
+ * @see Slot#set(ItemStackLike)
* @param pos Slot position to set
* @param stack Stack to insert
* @return matching stacks, as per the semantics of {@link Inventory#set}
*/
- default InventoryTransactionResult set(Vector2i pos, ItemStack stack) {
+ default InventoryTransactionResult set(Vector2i pos, ItemStackLike stack) {
return this.slot(pos).map(slot -> slot.set(stack)).orElse(InventoryTransactionResult.failNoTransactions());
}
diff --git a/src/main/java/org/spongepowered/api/item/inventory/type/ViewableInventory.java b/src/main/java/org/spongepowered/api/item/inventory/type/ViewableInventory.java
index 0c76f96d04..af76ba85db 100644
--- a/src/main/java/org/spongepowered/api/item/inventory/type/ViewableInventory.java
+++ b/src/main/java/org/spongepowered/api/item/inventory/type/ViewableInventory.java
@@ -32,6 +32,7 @@
import org.spongepowered.api.item.inventory.Carrier;
import org.spongepowered.api.item.inventory.ContainerType;
import org.spongepowered.api.item.inventory.Inventory;
+import org.spongepowered.api.item.inventory.ItemStackLike;
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
import org.spongepowered.api.item.inventory.Slot;
import org.spongepowered.api.item.inventory.menu.InventoryMenu;
@@ -247,6 +248,14 @@ interface BuildingStep {
interface DummyStep extends BuildingStep {
+ /**
+ * @deprecated Use {@link #item(ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default BuildingStep item(ItemStackSnapshot item) {
+ return this.item((ItemStackLike) item);
+ }
+
/**
* Sets the default item for the dummy-slots.
*
@@ -254,7 +263,7 @@ interface DummyStep extends BuildingStep {
*
* @return the building step
*/
- BuildingStep item(ItemStackSnapshot item);
+ BuildingStep item(ItemStackLike item);
}
interface EndStep extends Builder {
From e2d8085fa823b19c8de7e58d46e1a1efae2799c7 Mon Sep 17 00:00:00 2001
From: MrHell228
Date: Mon, 16 Sep 2024 02:31:39 +0300
Subject: [PATCH 11/14] finalize migrating item package
---
.../org/spongepowered/api/item/recipe/crafting/RecipeResult.java | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/main/java/org/spongepowered/api/item/recipe/crafting/RecipeResult.java b/src/main/java/org/spongepowered/api/item/recipe/crafting/RecipeResult.java
index d8128aa8db..489eadcbf0 100644
--- a/src/main/java/org/spongepowered/api/item/recipe/crafting/RecipeResult.java
+++ b/src/main/java/org/spongepowered/api/item/recipe/crafting/RecipeResult.java
@@ -31,7 +31,6 @@
import java.util.List;
import java.util.Objects;
import java.util.StringJoiner;
-import java.util.stream.Collectors;
/**
* The result of fulfilling a {@link CraftingRecipe}.
From 47299e1628fb02b1a980435aaf6043845337c7d7 Mon Sep 17 00:00:00 2001
From: MrHell228
Date: Mon, 16 Sep 2024 03:11:15 +0300
Subject: [PATCH 12/14] Migrate different stuff
---
.../api/advancement/DisplayInfo.java | 24 ++++++++++++-------
.../api/block/entity/Jukebox.java | 11 ++++++++-
.../cause/entity/damage/DamageModifier.java | 18 +++++++++++---
3 files changed, 40 insertions(+), 13 deletions(-)
diff --git a/src/main/java/org/spongepowered/api/advancement/DisplayInfo.java b/src/main/java/org/spongepowered/api/advancement/DisplayInfo.java
index 85f2c8fff4..14cee4b0ab 100644
--- a/src/main/java/org/spongepowered/api/advancement/DisplayInfo.java
+++ b/src/main/java/org/spongepowered/api/advancement/DisplayInfo.java
@@ -28,6 +28,7 @@
import org.spongepowered.api.Sponge;
import org.spongepowered.api.item.ItemType;
import org.spongepowered.api.item.inventory.ItemStack;
+import org.spongepowered.api.item.inventory.ItemStackLike;
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
import org.spongepowered.api.util.CopyableBuilder;
@@ -164,24 +165,29 @@ default Builder icon(ItemType itemType) {
}
/**
- * Sets the icon of the advancement with the
- * specified {@link ItemStack}.
- *
- * @param itemStack The item stack
- * @return This builder, for chaining
+ * @deprecated Use {@link #icon(ItemStackLike)} instead.
*/
+ @Deprecated(forRemoval = true)
default Builder icon(ItemStack itemStack) {
- return this.icon(itemStack.asImmutable());
+ return this.icon((ItemStackLike) itemStack);
+ }
+
+ /**
+ * @deprecated Use {@link #icon(ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default Builder icon(ItemStackSnapshot itemStackSnapshot) {
+ return this.icon((ItemStackLike) itemStackSnapshot);
}
/**
* Sets the icon of the advancement with the
- * specified {@link ItemStackSnapshot}.
+ * specified {@link ItemStackLike}.
*
- * @param itemStackSnapshot The item stack snapshot
+ * @param itemStack The item stack snapshot
* @return This builder, for chaining
*/
- Builder icon(ItemStackSnapshot itemStackSnapshot);
+ Builder icon(ItemStackLike itemStack);
/**
* Sets whether a toast should be shown. This is the notification
diff --git a/src/main/java/org/spongepowered/api/block/entity/Jukebox.java b/src/main/java/org/spongepowered/api/block/entity/Jukebox.java
index 9ac9fdc2aa..c85906436e 100644
--- a/src/main/java/org/spongepowered/api/block/entity/Jukebox.java
+++ b/src/main/java/org/spongepowered/api/block/entity/Jukebox.java
@@ -27,6 +27,7 @@
import org.spongepowered.api.data.Keys;
import org.spongepowered.api.data.value.Value;
import org.spongepowered.api.item.inventory.ItemStack;
+import org.spongepowered.api.item.inventory.ItemStackLike;
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
/**
@@ -59,10 +60,18 @@ default Value.Mutable item() {
*/
void eject();
+ /**
+ * @deprecated Use {@link #insert(ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
+ default void insert(ItemStack disc) {
+ this.insert((ItemStackLike) disc);
+ }
+
/**
* Ejects the current music disc item in this Jukebox and inserts the given one.
*
* @param disc The music disc item to insert
*/
- void insert(ItemStack disc);
+ void insert(ItemStackLike disc);
}
diff --git a/src/main/java/org/spongepowered/api/event/cause/entity/damage/DamageModifier.java b/src/main/java/org/spongepowered/api/event/cause/entity/damage/DamageModifier.java
index c0b0eb263e..19079591c3 100644
--- a/src/main/java/org/spongepowered/api/event/cause/entity/damage/DamageModifier.java
+++ b/src/main/java/org/spongepowered/api/event/cause/entity/damage/DamageModifier.java
@@ -30,6 +30,7 @@
import org.spongepowered.api.item.ItemTypes;
import org.spongepowered.api.item.enchantment.Enchantment;
import org.spongepowered.api.item.inventory.ItemStack;
+import org.spongepowered.api.item.inventory.ItemStackLike;
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
import org.spongepowered.api.util.CopyableBuilder;
@@ -162,13 +163,24 @@ public Builder group(final String group) {
return this;
}
+ /**
+ * @deprecated Use {@link #item(ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
public Builder item(final ItemStack itemStack) {
- this.item(java.util.Objects.requireNonNull(itemStack, "ItemStack").asImmutable());
- return this;
+ return this.item((ItemStackLike) itemStack);
}
+ /**
+ * @deprecated Use {@link #item(ItemStackLike)} instead.
+ */
+ @Deprecated(forRemoval = true)
public Builder item(final ItemStackSnapshot snapshot) {
- this.snapshot = java.util.Objects.requireNonNull(snapshot, "ItemStackSnapshot");
+ return this.item((ItemStackLike) snapshot);
+ }
+
+ public Builder item(final ItemStackLike item) {
+ this.snapshot = java.util.Objects.requireNonNull(item, "item").asImmutable();
return this;
}
From 369d88811f91775f4019d85a56ef47664f9afb19 Mon Sep 17 00:00:00 2001
From: MrHell228
Date: Mon, 23 Sep 2024 19:49:37 +0300
Subject: [PATCH 13/14] Change BlockEntity#setTicking()
---
.../org/spongepowered/api/block/entity/BlockEntity.java | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/spongepowered/api/block/entity/BlockEntity.java b/src/main/java/org/spongepowered/api/block/entity/BlockEntity.java
index 90ddcca7bf..8d2ec2f13d 100644
--- a/src/main/java/org/spongepowered/api/block/entity/BlockEntity.java
+++ b/src/main/java/org/spongepowered/api/block/entity/BlockEntity.java
@@ -82,11 +82,16 @@ public interface BlockEntity extends SerializableDataHolder.Mutable, Locatable {
boolean isTicking();
/**
- * Sets if this block entity will naturally tick.
+ * Attempts to set if this block entity will naturally tick.
+ *
+ * This will return false
+ * if {@link #isRemoved()} returns true
+ * or {@link #canTick()} returns false
*
* @param ticking The ticking state
+ * @return True if ticking state was successfully set
*/
- void setTicking(boolean ticking);
+ boolean setTicking(boolean ticking);
/**
* Gets the type of {@link BlockEntity} this is.
From b016dd98de4da1bce9a7e09864967d1a44a133f8 Mon Sep 17 00:00:00 2001
From: Yeregorix
Date: Thu, 19 Sep 2024 17:42:01 +0200
Subject: [PATCH 14/14] Update log4j javadoc url
---
build.gradle.kts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/build.gradle.kts b/build.gradle.kts
index 95dda334e2..75be8bd5d2 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -178,7 +178,7 @@ tasks {
options {
(this as? StandardJavadocDocletOptions)?.apply {
links(
- "https://logging.apache.org/log4j/log4j-${libs.versions.log4j.get()}/log4j-api/apidocs/",
+ "https://logging.apache.org/log4j/2.x/javadoc/log4j-api/",
"https://google.github.io/guice/api-docs/${libs.versions.guice.get()}/javadoc/",
"https://configurate.aoeu.xyz/${libs.versions.configurate.get()}/apidocs/",
"https://www.javadoc.io/doc/com.google.code.gson/gson/${libs.versions.gson.get()}/",