Further clarify functionality of damageItemStack methods (#8878)

This commit is contained in:
Jake Potrebic 2023-02-21 09:35:25 -08:00 committed by GitHub
parent 8b37e9e2aa
commit ddc0a99f52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 10 deletions

View file

@ -8,10 +8,10 @@ to simulate damage done to an itemstack and all
the logic associated with damaging them
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
index f5a4160afb75549dd56a237cf99ec733efef9b4c..285b4028eb45439c052d6a2e9001a8c0bfacd49a 100644
index f5a4160afb75549dd56a237cf99ec733efef9b4c..efcf093bc908a3a5711a06e579503100514f57aa 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
@@ -1082,5 +1082,48 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
@@ -1082,5 +1082,52 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
* @param directionZ The relative z position of the knockback source direction
*/
void knockback(double strength, double directionX, double directionZ);
@ -38,21 +38,25 @@ index f5a4160afb75549dd56a237cf99ec733efef9b4c..285b4028eb45439c052d6a2e9001a8c0
+ void broadcastSlotBreak(org.bukkit.inventory.@NotNull EquipmentSlot slot, @NotNull Collection<Player> players);
+
+ /**
+ * Damages this itemstack by the specified amount. This
+ * runs all logic associated with damaging an itemstack like
+ * events and stat changes.
+ * Damages the itemstack in this slot by the specified amount.
+ * <p>
+ * This runs all logic associated with damaging an itemstack like
+ * gamemode and enchantment checks, events, stat changes, and advancement
+ * triggers.
+ *
+ * @param stack the itemstack to damage
+ * @param amount the amount of damage to do
+ * @return the damaged itemstack, or an empty stack if it broke. It may be the same instance as the stack passed it, but it may not.
+ * @return the damaged itemstack, or an empty stack if it broke. There are no
+ * guarantees the returned itemstack is the same instance
+ */
+ @NotNull ItemStack damageItemStack(@NotNull ItemStack stack, int amount);
+
+ /**
+ * Damages the itemstack in this slot by the specified amount.
+ * <p>
+ * This runs all logic associated with damaging an itemstack like
+ * events, stat changes, and notifying clients to play
+ * break animations.
+ * gamemode and enchantment checks, events, stat changes, advancement
+ * triggers, and notifying clients to play break animations.
+ *
+ * @param slot the slot of the stack to damage
+ * @param amount the amount of damage to do

View file

@ -5,10 +5,10 @@ Subject: [PATCH] Add Entity Body Yaw API
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
index 6555397148b84dba7a87cae505544b65452f1742..1da1c293ac8a13d22743c26d35624155bfa73a16 100644
index df91f612978dcea83a99f8403820cea1ab462c06..d045f41d929c6101060caf3a9fb48c8ffc036f16 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
@@ -1125,5 +1125,21 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
@@ -1129,5 +1129,21 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
* @param amount the amount of damage to do
*/
void damageItemStack(org.bukkit.inventory.@NotNull EquipmentSlot slot, int amount);