Skip to content

Commit

Permalink
Migrate Equipable
Browse files Browse the repository at this point in the history
  • Loading branch information
MrHell228 committed Sep 15, 2024
1 parent ffd4e09 commit 7c349a5
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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);
}
36 changes: 34 additions & 2 deletions src/main/java/org/spongepowered/api/item/inventory/Equipable.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}

Expand All @@ -84,6 +100,14 @@ default Optional<ItemStack> 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.
Expand All @@ -95,9 +119,17 @@ default Optional<ItemStack> 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);
}
}

0 comments on commit 7c349a5

Please sign in to comment.