Commands/swing
Minecraft Wiki article. Categories: Java_Edition, Upcoming, Java_Edition_upcoming_tag, Java_Edition_upcoming, Commands
📌 Mirrored from Minecraft Wiki
This article is reproduced from Commands/swing on the Minecraft Wiki. Mirrored from revision 3712325. It is licensed CC BY-NC-SA 3.0 by the Minecraft Wiki contributors — not under the Codex’s CC BY-SA 4.0, and it may not be used commercially. Edits belong upstream, not here.
This feature is exclusive to Java Edition.
/swing{
"title": "<code>/swing</code>",
"rows": [
{
"field": "2",
"label": "(link to Permission level article, displayed as Permission level<br>required)"
},
{
"field": "None",
"label": "(link to Commands#Restrictions article, displayed as Restrictions)"
}
],
"invimages": [],
"images": []
}
Controls the swinging animation of entities' hands.
Syntax
/swing [<targets>] [mainhand|offhand][until: JE 26.3]/swing [<targets>] [mainhand|offhand] [<animation>] [<duration>][upcoming: JE 26.3]
Arguments
<targets>: entity
- Specifies entities to swing. Defaults to
@s(the command executor). - Not all entities will animate a swing on the client side.
- Must be a player name, a target selector or a UUID.
mainhand|offhand
- Specifies the arm to swing. Defaults to
mainhand.
<animation>: swing_animation[upcoming: JE 26.3]
- Specifies the swing animation to play. Defaults to
whack. - Must be either
whackorstab.
<duration>: time[upcoming: JE 26.3]
- Specifies the duration of the swing animation. Defaults to
6t. - It must be a single-precision floating-point number suffixed with a unit. It must be not less than 1 gameticks. Units include:
d: an in-game day, 24000 gameticks;s: a second, 20 gameticks;t(default and omitable): a single gametick; the default unit.
.5dis same as 12000 gameticks.
Result
| Command | Trigger | Java Edition |
|---|---|---|
| Any | The command is incomplete, or any argument is not specified correctly. | Unparseable |
<targets> fails to resolve to one or more entities. | Failed | |
| Otherwise | Successful |
Output
| Command | Edition | Situation | Success Count | /execute store success ... | /execute store result ... |
|---|---|---|---|---|---|
| Any | Java Edition | On fail | 0 | 0 | 0 |
| On success | 1 | 1 | the number of targeted entities |
History
| Java Edition | |||||||
|---|---|---|---|---|---|---|---|
| 26.1 | snap1 | Added /swing. | |||||
| snap3 | Both arguments are now optional, and default to @s and mainhand respectively. | ||||||
| Upcoming Java Edition | |||||||
| 26.3 | snap7 | When used on a player, the player's attack strength will no longer be reset. | |||||
Added the whack|stab and duration arguments. | |||||||
Navigation
Sources
- Commands/swing — Minecraft Wiki, CC BY-NC-SA 3.0, revision 3712325.