How do I make this command in Minecraft?
I've seen multiple creative servers that have items with added speed when held. Is there any way to get a command for it or is it just a cheap hack?
22 Answers
You can apply a generic.movementSpeed attribute modifier to the item so that you don't need to include any external command mechanisms. For example, the following provides the player with stone that, when held, increases the player's movement speed by 30%:
/give @p minecraft:stone 1 0 {AttributeModifiers:[{AttributeName:"generic.movementSpeed",Name:"+30%",Amount:0.3,Operation:1,Slot:"mainhand",UUIDLeast:1l,UUIDMost:1l}]} Set up a scoreboard testing when a player hold the item, then execute that player accordingly.
You'll want to set up the scoreboard like this:/scoreboard objectives add holdItemOne dummy note that it's dummy because we're adding a score when someone holds the item.
Make sure that these following commands are on a clock, but in this order:
- /scoreboard players set @a holdItemOne 0
- /scoreboard players set @a holdItemOne 1 {SelectedItem:{id:"minecraft:stick",tag:{display:{Name:"Speedy Stick"}}}}
- effect @a[score_holdItemOne_min=1] minecraft:speed 5 5
note that you can change the scoreboard objective name, what the player is holding, and the effect as you wish.
If you want to have it in one command, I would reccomend finding a one command block creator, or something along the lines of that.