Archived
0

Обработка анимации

This commit is contained in:
2018-05-22 20:50:01 +03:00
parent 8c1a1d3f99
commit 2e2d0dc4d9
3 changed files with 51 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
/*
* d.mihailov <d.mihailov@samson-rus.com>
* 2018-05-22
*/
package mc.core.network.proto_125.packets;
import lombok.*;
import mc.core.network.CSPacket;
import mc.core.network.NetStream;
import mc.core.network.SCPacket;
import mc.core.network.proto_125.ByteArrayOutputNetStream;
@AllArgsConstructor
@NoArgsConstructor
@Setter
@Getter
@ToString
public class AnimationPacket implements SCPacket, CSPacket {
public static final int NO_ANIMATION = 0,
SWING_ARM = 1,
DAMAGE = 2,
LEAVE_BED = 3,
EAT_FOOD = 5,
CROUCH = 104,
UNCROUCH = 105;
private int id;
private int animation;
@Override
public void readSelf(NetStream netStream) {
id = netStream.readInt();
animation = netStream.readByte();
}
@Override
public byte[] toByteArray() {
ByteArrayOutputNetStream netStream = new ByteArrayOutputNetStream();
netStream.writeInt(id);
netStream.writeByte(animation);
return netStream.toByteArray();
}
}

View File

@@ -20,6 +20,7 @@ public class PacketManager {
.put(0x0B, PlayerPositionPacket.class) .put(0x0B, PlayerPositionPacket.class)
.put(0x0C, PlayerLookPacket.class) .put(0x0C, PlayerLookPacket.class)
.put(0x0D, PositionAndLookPacket.class) .put(0x0D, PositionAndLookPacket.class)
.put(0x12, AnimationPacket.class)
.put(0x14, SpawnNamedEntityPacket.class) .put(0x14, SpawnNamedEntityPacket.class)
.put(0x1D, DestroyEntityPacket.class) .put(0x1D, DestroyEntityPacket.class)
.put(0x1F, EntityRelativeMovePacket.class) .put(0x1F, EntityRelativeMovePacket.class)

View File

@@ -285,4 +285,11 @@ public class PacketHandler extends SimpleChannelInboundHandler<CSPacket> {
packet.getMessage() packet.getMessage()
); );
} }
private void onAnimationPacket(Channel channel, AnimationPacket packet) {
Player player = channel.attr(ATTR_PLAYER).get();
playerManager.getPlayers().stream().filter(pl -> !pl.equals(player)).forEach(pl -> {
pl.getChannel().writeAndFlush(packet);
});
}
} }