diff --git a/src/main/java/de/bixilon/minosoft/protocol/packets/serverbound/play/PacketAnimation.java b/src/main/java/de/bixilon/minosoft/protocol/packets/serverbound/play/PacketAnimation.java new file mode 100644 index 000000000..a1a38d0aa --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/protocol/packets/serverbound/play/PacketAnimation.java @@ -0,0 +1,49 @@ +/* + * Codename Minosoft + * Copyright (C) 2020 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.protocol.packets.serverbound.play; + +import de.bixilon.minosoft.game.datatypes.player.Hand; +import de.bixilon.minosoft.logging.Log; +import de.bixilon.minosoft.protocol.packets.ServerboundPacket; +import de.bixilon.minosoft.protocol.protocol.OutPacketBuffer; +import de.bixilon.minosoft.protocol.protocol.Packets; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +public class PacketAnimation implements ServerboundPacket { + final Hand hand; + + public PacketAnimation(Hand hand) { + this.hand = hand; + log(); + } + + + @Override + public OutPacketBuffer write(ProtocolVersion version) { + OutPacketBuffer buffer = new OutPacketBuffer(version, version.getPacketCommand(Packets.Serverbound.PLAY_ANIMATION)); + switch (version) { + case VERSION_1_8: + break; + case VERSION_1_9_4: + buffer.writeVarInt(hand.getId()); + break; + } + return buffer; + } + + @Override + public void log() { + Log.protocol(String.format("Sending hand animation (hand=%s)", hand.name())); + } +} diff --git a/src/main/java/de/bixilon/minosoft/protocol/packets/serverbound/play/PacketEntityAction.java b/src/main/java/de/bixilon/minosoft/protocol/packets/serverbound/play/PacketEntityAction.java index 91a387624..1196019e3 100644 --- a/src/main/java/de/bixilon/minosoft/protocol/packets/serverbound/play/PacketEntityAction.java +++ b/src/main/java/de/bixilon/minosoft/protocol/packets/serverbound/play/PacketEntityAction.java @@ -44,7 +44,7 @@ public class PacketEntityAction implements ServerboundPacket { @Override public OutPacketBuffer write(ProtocolVersion version) { - OutPacketBuffer buffer = new OutPacketBuffer(version, version.getPacketCommand(Packets.Serverbound.PLAY_PLAYER_DIGGING)); + OutPacketBuffer buffer = new OutPacketBuffer(version, version.getPacketCommand(Packets.Serverbound.PLAY_ENTITY_ACTION)); switch (version) { case VERSION_1_7_10: buffer.writeInt(entityId); @@ -67,7 +67,6 @@ public class PacketEntityAction implements ServerboundPacket { } public enum EntityActions { - SNEAK(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 0)}), UN_SNEAK(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 1)}), LEAVE_BED(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 2)}),