diff --git a/Allay-API/src/main/java/org/allaymc/api/block/component/common/BlockBaseComponent.java b/Allay-API/src/main/java/org/allaymc/api/block/component/common/BlockBaseComponent.java index 32b037862..fe5e75e6d 100644 --- a/Allay-API/src/main/java/org/allaymc/api/block/component/common/BlockBaseComponent.java +++ b/Allay-API/src/main/java/org/allaymc/api/block/component/common/BlockBaseComponent.java @@ -47,8 +47,8 @@ default void updateBlockProperty(BlockPropertyType property default double calculateBreakTime(BlockState blockState, ItemStack usedItem, Entity entity) { checkBlockType(blockState); - double blockHardness = blockState.getBlockAttributes().hardness(); - if (blockHardness == 0) return 0; + if (usedItem.canInstantBreak(blockState)) return 0; + float blockHardness = blockState.getBlockAttributes().hardness(); boolean isCorrectTool = usedItem.isCorrectToolFor(blockState); boolean isAlwaysDestroyable = getBlockType().getMaterial().isAlwaysDestroyable(); boolean hasAquaAffinity = false; diff --git a/Allay-API/src/main/java/org/allaymc/api/item/component/common/ItemBaseComponent.java b/Allay-API/src/main/java/org/allaymc/api/item/component/common/ItemBaseComponent.java index c8c8a655a..b71d33279 100644 --- a/Allay-API/src/main/java/org/allaymc/api/item/component/common/ItemBaseComponent.java +++ b/Allay-API/src/main/java/org/allaymc/api/item/component/common/ItemBaseComponent.java @@ -2,6 +2,7 @@ import org.allaymc.api.block.data.BlockFace; import org.allaymc.api.block.type.BlockState; +import org.allaymc.api.block.type.BlockTypes; import org.allaymc.api.data.VanillaBlockId; import org.allaymc.api.data.VanillaItemId; import org.allaymc.api.entity.interfaces.EntityPlayer; @@ -139,7 +140,6 @@ default double getBreakTimeBonus(BlockState blockState) { // 剑破坏蜘蛛网加速 if (itemType.hasItemTag(IS_SWORD)) { if (materialType == WEB) return 15.0; - if (blockState.getBlockType() == BAMBOO_BLOCK_TYPE) return Integer.MAX_VALUE; } if (itemType == SHEARS_TYPE) { // 剪刀破坏羊毛和树叶加速 @@ -167,4 +167,15 @@ default double getBreakTimeBonus(BlockState blockState) { * @return 是否是正确工具 */ boolean isCorrectToolFor(BlockState blockState); + + default boolean canInstantBreak(BlockState blockState) { + double blockHardness = blockState.getBlockAttributes().hardness(); + // 硬度为0的方块可以被瞬间破坏 + if (blockHardness == 0) return true; + if (getItemType().hasItemTag(IS_SWORD)) { + // 剑可以瞬间破坏竹子 + return blockState.getBlockType() == BlockTypes.BAMBOO_TYPE; + } + return false; + } } diff --git a/Allay-Server/src/main/java/org/allaymc/server/network/processor/PlayerAuthInputPacketProcessor.java b/Allay-Server/src/main/java/org/allaymc/server/network/processor/PlayerAuthInputPacketProcessor.java index 8b32afa11..14d5919e3 100644 --- a/Allay-Server/src/main/java/org/allaymc/server/network/processor/PlayerAuthInputPacketProcessor.java +++ b/Allay-Server/src/main/java/org/allaymc/server/network/processor/PlayerAuthInputPacketProcessor.java @@ -57,7 +57,7 @@ protected void handleBlockAction(EntityPlayer player, List inputData) {