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

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 whack or stab.

<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.
The time is set to the closest integer after unit conversion to gametick. For example. .5d is same as 12000 gameticks.

Result

CommandTriggerJava Edition
AnyThe command is incomplete, or any argument is not specified correctly. Unparseable
<targets> fails to resolve to one or more entities. Failed
OtherwiseSuccessful

Output

CommandEditionSituationSuccess Count/execute store success .../execute store result ...
AnyJava EditionOn fail000
On success11the number of targeted entities

History

Java Edition
26.1snap1Added /swing.
snap3Both arguments are now optional, and default to @s and mainhand respectively.
Upcoming Java Edition
26.3snap7When used on a player, the player's attack strength will no longer be reset.
Added the whack|stab and duration arguments.

Sources