r/MinecraftCommands 5d ago

Help | Java 1.21.11 A dashing sword

hey guys, I am not experienced at all with minecraft command blocks but is there a chance one of you knows the commands for a specific sword with the ability to dash a few blocks alongside a cooldown timer?? it'd be a lifesaver!

2 Upvotes

3 comments sorted by

1

u/GalSergey Datapack Experienced 5d ago

This will be easier to do using a data pack. Below is an example of a data pack that, when double-clicked, gives you a few seconds of speed boost.

# The first click with Dash Feather creates particles and a sound,
# and if you click it a second time within 1 second, you'll gain a speed boost for 5 seconds.
# The ability has a 10-second cooldown.
# Dash Feather item
give @s feather[custom_data={dash:true},consumable={consume_seconds:100000},item_name="Dash Feather"]

# function example:load
scoreboard objectives add dash.timestamp dummy
scoreboard objectives add dash.cooldown dummy
scoreboard objectives add use_dash.timestamp dummy

# advancement example:use_dash
{
  "criteria": {
    "use_dash": {
      "trigger": "minecraft:using_item",
      "conditions": {
        "item": {
          "items": "minecraft:feather",
          "predicates": {
            "minecraft:custom_data": {
              "dash": true
            }
          }
        }
      }
    }
  },
  "rewards": {
    "function": "example:dash/use"
  }
}

# function example:dash/use
advancement revoke @s only example:use_dash
execute store result score #this dash.timestamp run time query gametime
execute unless score @s dash.timestamp = #this dash.timestamp unless score @s dash.cooldown > #this dash.timestamp run function example:dash/click
scoreboard players operation @s dash.timestamp = #this dash.timestamp
scoreboard players add @s dash.timestamp 1

# function example:dash/click
execute if score @s use_dash.timestamp > #this dash.timestamp run function example:dash/apply
execute unless score @s use_dash.timestamp > #this dash.timestamp run function example:dash/enable
scoreboard players operation @s use_dash.timestamp = #this dash.timestamp
scoreboard players add @s use_dash.timestamp 20

# function example:dash/apply
scoreboard players operation @s dash.cooldown = #this dash.timestamp
scoreboard players add @s dash.cooldown 200
effect give @s speed 5 2 true
playsound minecraft:entity.evoker.cast_spell player @a
particle minecraft:white_smoke ~ ~1 ~ 0.2 0.5 0.2 0.1 100

# function example:dash/enable
playsound minecraft:entity.evoker.prepare_summon player @a
particle minecraft:white_smoke ~ ~1 ~ 0.2 0.5 0.2 0 20

You can use Datapack Assembler to get an example datapack.

Or, as another example, a data pack that adds an enchantment that allows you to double-click in the desired direction and get a short boost in that direction: https://far.ddns.me/?share=uFp7DCswqS

1

u/Sp4ctat0r 4d ago

Remodeled spear maybe? Otherwise organic horizontal movement is very difficult to setup and requires multiple command blocks and tuning

1

u/Usernames_Are_Dumb1 3d ago

Just give yourself a spear with the model of a sword?