diff options
author | Jake Potrebic <[email protected]> | 2023-08-25 10:57:11 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2023-08-25 10:57:11 -0700 |
commit | 6813244fb06e416bf30542905b7bedfb94facecf (patch) | |
tree | b9fd2885eea5af0c2cd9a66ecd1a50123740556d /patches/api | |
parent | 6f30f08b201df05676880b480b0fa5a5876a7ac3 (diff) | |
download | Paper-6813244fb06e416bf30542905b7bedfb94facecf.tar.gz Paper-6813244fb06e416bf30542905b7bedfb94facecf.zip |
Fix/improve destroy speed API (#9645)
further improvements could be a method that takes in an entity
to account for effects
Diffstat (limited to 'patches/api')
-rw-r--r-- | patches/api/0223-Add-Destroy-Speed-API.patch | 60 | ||||
-rw-r--r-- | patches/api/0373-Block-Ticking-API.patch | 14 |
2 files changed, 55 insertions, 19 deletions
diff --git a/patches/api/0223-Add-Destroy-Speed-API.patch b/patches/api/0223-Add-Destroy-Speed-API.patch index 6e2512b8b7..9b4e942bd1 100644 --- a/patches/api/0223-Add-Destroy-Speed-API.patch +++ b/patches/api/0223-Add-Destroy-Speed-API.patch @@ -6,36 +6,72 @@ Subject: [PATCH] Add Destroy Speed API Co-authored-by: Jake Potrebic <[email protected]> diff --git a/src/main/java/org/bukkit/block/Block.java b/src/main/java/org/bukkit/block/Block.java -index 5ae85ddc2cff3145dcba877a7bf55abd818f6881..546c6709383edb0007b9a8a560af0b64f498dadd 100644 +index 5ae85ddc2cff3145dcba877a7bf55abd818f6881..89bd97153d874c2710304d163f7c46062d8c8bab 100644 --- a/src/main/java/org/bukkit/block/Block.java +++ b/src/main/java/org/bukkit/block/Block.java -@@ -680,5 +680,29 @@ public interface Block extends Metadatable, Translatable, net.kyori.adventure.tr - @NotNull +@@ -681,4 +681,31 @@ public interface Block extends Metadatable, Translatable, net.kyori.adventure.tr @Deprecated(forRemoval = true) String getTranslationKey(); + // Paper end + ++ // Paper start - destroy speed API + /** + * Gets the speed at which this block will be destroyed by a given {@link ItemStack} ++ * <p> ++ * Default value is 1.0 + * -+ * <p>Default value is 1.0</p> ++ * @param itemStack {@link ItemStack} used to mine this Block ++ * @return the speed that this Block will be mined by the given {@link ItemStack} ++ */ ++ default float getDestroySpeed(final @NotNull ItemStack itemStack) { ++ return this.getBlockData().getDestroySpeed(itemStack); ++ } ++ ++ /** ++ * Gets the speed at which this block will be destroyed by a given {@link ItemStack} ++ * <p> ++ * Default value is 1.0 + * + * @param itemStack {@link ItemStack} used to mine this Block ++ * @param considerEnchants true to look at enchants on the itemstack + * @return the speed that this Block will be mined by the given {@link ItemStack} + */ -+ @NotNull -+ public default float getDestroySpeed(@NotNull ItemStack itemStack) { -+ return getDestroySpeed(itemStack, false); ++ default float getDestroySpeed(@NotNull ItemStack itemStack, boolean considerEnchants) { ++ return this.getBlockData().getDestroySpeed(itemStack, considerEnchants); + } ++ // Paper end - destroy speed API + } +diff --git a/src/main/java/org/bukkit/block/data/BlockData.java b/src/main/java/org/bukkit/block/data/BlockData.java +index 869fa47a13fbcb128228963bf53cc72da4499a01..1f475424cc04d90f437cf0e38e07f5ae4020fb54 100644 +--- a/src/main/java/org/bukkit/block/data/BlockData.java ++++ b/src/main/java/org/bukkit/block/data/BlockData.java +@@ -247,4 +247,29 @@ public interface BlockData extends Cloneable { + @NotNull + @ApiStatus.Experimental + BlockState createBlockState(); + ++ // Paper start - destroy speed API + /** -+ * Gets the speed at which this blook will be destroyed by a given {@link org.bukkit.inventory.ItemStack} ++ * Gets the speed at which this block will be destroyed by a given {@link ItemStack} + * <p> + * Default value is 1.0 -+ * @param itemStack {@link org.bukkit.inventory.ItemStack} used to mine this Block ++ * ++ * @param itemStack {@link ItemStack} used to mine this Block ++ * @return the speed that this Block will be mined by the given {@link ItemStack} ++ */ ++ default float getDestroySpeed(final @NotNull ItemStack itemStack) { ++ return this.getDestroySpeed(itemStack, false); ++ } ++ ++ /** ++ * Gets the speed at which this block will be destroyed by a given {@link ItemStack} ++ * <p> ++ * Default value is 1.0 ++ * ++ * @param itemStack {@link ItemStack} used to mine this Block + * @param considerEnchants true to look at enchants on the itemstack -+ * @return the speed that this Block will be mined by the given {@link org.bukkit.inventory.ItemStack} ++ * @return the speed that this Block will be mined by the given {@link ItemStack} + */ -+ @NotNull + float getDestroySpeed(@NotNull ItemStack itemStack, boolean considerEnchants); - // Paper end ++ // Paper end - destroy speed API } diff --git a/patches/api/0373-Block-Ticking-API.patch b/patches/api/0373-Block-Ticking-API.patch index 9b2fc54ea1..b64dd3fde1 100644 --- a/patches/api/0373-Block-Ticking-API.patch +++ b/patches/api/0373-Block-Ticking-API.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Block Ticking API diff --git a/src/main/java/org/bukkit/block/Block.java b/src/main/java/org/bukkit/block/Block.java -index 921864e748407291b7fa153381e7d9701e1c4608..1c3f54382d66549dc881d4577c7104be6673a274 100644 +index 49fd2f54d2051553bd2df1c53f6b229ffa64892e..0b2a927b3500be5e6583a6d1ae90fe68473ff786 100644 --- a/src/main/java/org/bukkit/block/Block.java +++ b/src/main/java/org/bukkit/block/Block.java @@ -589,6 +589,21 @@ public interface Block extends Metadatable, Translatable, net.kyori.adventure.tr @@ -31,13 +31,13 @@ index 921864e748407291b7fa153381e7d9701e1c4608..1c3f54382d66549dc881d4577c7104be /** diff --git a/src/main/java/org/bukkit/block/data/BlockData.java b/src/main/java/org/bukkit/block/data/BlockData.java -index 869fa47a13fbcb128228963bf53cc72da4499a01..c6b17605090f2f284e6536567ddf0e0977eeaaf8 100644 +index 1f475424cc04d90f437cf0e38e07f5ae4020fb54..31111cea5ffd018c3c011c1f3b8befbbd33db5e5 100644 --- a/src/main/java/org/bukkit/block/data/BlockData.java +++ b/src/main/java/org/bukkit/block/data/BlockData.java -@@ -247,4 +247,14 @@ public interface BlockData extends Cloneable { - @NotNull - @ApiStatus.Experimental - BlockState createBlockState(); +@@ -272,4 +272,14 @@ public interface BlockData extends Cloneable { + */ + float getDestroySpeed(@NotNull ItemStack itemStack, boolean considerEnchants); + // Paper end - destroy speed API + + // Paper start - Tick API + /** @@ -47,5 +47,5 @@ index 869fa47a13fbcb128228963bf53cc72da4499a01..c6b17605090f2f284e6536567ddf0e09 + * @return is ticked randomly + */ + boolean isRandomlyTicked(); -+ // Paper end ++ // Paper end - Tick API } |