package com.voxelwind.server.network.mcpe.packets;

import com.flowpowered.math.vector.Vector3f;
import com.voxelwind.api.game.item.ItemStack;
import com.voxelwind.api.game.level.block.BlockTypes;
import com.voxelwind.server.game.item.VoxelwindItemStack;
import com.voxelwind.server.network.mcpe.McpeUtil;
import com.voxelwind.server.network.mcpe.util.metadata.MetadataDictionary;
import com.voxelwind.server.network.NetworkPackage;
import com.voxelwind.server.network.raknet.RakNetUtil;
import io.netty.buffer.ByteBuf;
import lombok.Data;

import java.util.UUID;

@Data
public class McpeAddPlayer implements NetworkPackage {
    private UUID uuid;
    private String username;
    private long entityId;
    private Vector3f position;
    private Vector3f velocity;
    private float yaw;
    private float pitch;
    private ItemStack held = new VoxelwindItemStack(BlockTypes.AIR, 1, null);
    private final MetadataDictionary metadata = new MetadataDictionary();

    @Override
    public void decode(ByteBuf buffer) {
        uuid = McpeUtil.readUuid(buffer);
        username = RakNetUtil.readString(buffer);
        entityId = buffer.readLong();
        position = McpeUtil.readVector3f(buffer);
        velocity = McpeUtil.readVector3f(buffer);
        yaw = buffer.readFloat();
        pitch = buffer.readFloat();
        held = McpeUtil.readItemStack(buffer);
        metadata.putAll(MetadataDictionary.deserialize(buffer));
    }

    @Override
    public void encode(ByteBuf buffer) {
        McpeUtil.writeUuid(buffer, uuid);
        RakNetUtil.writeString(buffer, username);
        buffer.writeLong(entityId);
        McpeUtil.writeVector3f(buffer, position);
        McpeUtil.writeVector3f(buffer, velocity);
        buffer.writeFloat(yaw);
        buffer.writeFloat(pitch);
        McpeUtil.writeItemStack(buffer, held);
        metadata.writeTo(buffer);
    }
}

@@ -190,16 +190,56 @@
 kTypes;%0A
+import com.voxelwind.api.util.Rotation;%0A
 import c
@@ -280,32 +280,32 @@
 lwindItemStack;%0A
-
 import com.voxel
@@ -816,42 +816,25 @@
 ate 
-float yaw;%0A    private float pitch
+Rotation rotation
 ;%0A  
@@ -1281,67 +1281,52 @@
     
-yaw = buffer.readFloat();%0A        pitch = buffer.readFloat(
+rotation = McpeUtil.readFloatRotation(buffer
 );%0A 
@@ -1726,38 +1726,40 @@
 ocity);%0A        
-buffer
+McpeUtil
 .writeFloat(yaw)
@@ -1757,46 +1757,33 @@
 loat
-(yaw);%0A        buffer.writeFloat(pitch
+Rotation(buffer, rotation
 );%0A 

Change McpeAddPlayer yaw,pitch to rotation to implement missing headYaw field