ClientboundSwingAnimationPacket .java

net.minecraft.network.protocol.game.ClientboundSwingAnimationPacket (record, 36 lines): members: entityId, hand, animation, handle, STREAM_CODEC, type.

net.minecraft.network.protocol.gamerecord36 linescommon1.3 KB

Implements

API Surface (2)

PacketType<ClientboundSwingAnimationPacket> type()
void handle(final ClientGamePacketListener listener)

Fields & Constants (1)

STREAM_CODEC

Same Package (197)

Full Source

ClientboundSwingAnimationPacket.java36 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.network.protocol.game;
2
3
import io.netty.buffer.ByteBuf;
4
import net.minecraft.network.codec.ByteBufCodecs;
5
import net.minecraft.network.codec.StreamCodec;
6
import net.minecraft.network.protocol.Packet;
7
import net.minecraft.network.protocol.PacketType;
8
import net.minecraft.world.InteractionHand;
9
import net.minecraft.world.entity.Entity;
10
import net.minecraft.world.item.component.SwingAnimation;
11
12
public record ClientboundSwingAnimationPacket(int entityId, InteractionHand hand, SwingAnimation animation) implements Packet<ClientGamePacketListener> {
13
	public static final StreamCodec<ByteBuf, ClientboundSwingAnimationPacket> STREAM_CODEC = StreamCodec.composite(
14
		ByteBufCodecs.VAR_INT,
15
		ClientboundSwingAnimationPacket::entityId,
16
		InteractionHand.STREAM_CODEC,
17
		ClientboundSwingAnimationPacket::hand,
18
		SwingAnimation.STREAM_CODEC,
19
		ClientboundSwingAnimationPacket::animation,
20
		ClientboundSwingAnimationPacket::new
21
	);
22
23
	public ClientboundSwingAnimationPacket(final Entity entity, final InteractionHand hand, final SwingAnimation animation) {
24
		this(entity.getId(), hand, animation);
25
	}
26
27
	@Override
28
	public PacketType<ClientboundSwingAnimationPacket> type() {
29
		return GamePacketTypes.CLIENTBOUND_SWING_ANIMATION;
30
	}
31
32
	public void handle(final ClientGamePacketListener listener) {
33
		listener.handleSwingAnimation(this);
34
	}
35
}
36

Decompiled Minecraft 26.3 source of ClientboundSwingAnimationPacket (net/minecraft/network/protocol/game/ClientboundSwingAnimationPacket.java) with Mojang official mappings, stored verbatim on the site.