Search in sources :

Example 1 with SpawnPlayerMessage

use of net.glowstone.net.message.play.entity.SpawnPlayerMessage in project Glowstone by GlowstoneMC.

the class GlowHumanEntity method createSpawnMessage.

////////////////////////////////////////////////////////////////////////////
// Internals
@Override
public List<Message> createSpawnMessage() {
    List<Message> result = new LinkedList<>();
    // spawn player
    double x = location.getX();
    double y = location.getY();
    double z = location.getZ();
    int yaw = Position.getIntYaw(location);
    int pitch = Position.getIntPitch(location);
    result.add(new SpawnPlayerMessage(id, profile.getUniqueId(), x, y, z, yaw, pitch, metadata.getEntryList()));
    // head facing
    result.add(new EntityHeadRotationMessage(id, yaw));
    // equipment
    EntityEquipment equipment = getEquipment();
    result.add(new EntityEquipmentMessage(id, 0, equipment.getItemInHand()));
    for (int i = 0; i < 4; i++) {
        result.add(new EntityEquipmentMessage(id, i + 1, equipment.getArmorContents()[i]));
    }
    return result;
}
Also used : EntityHeadRotationMessage(net.glowstone.net.message.play.entity.EntityHeadRotationMessage) SpawnPlayerMessage(net.glowstone.net.message.play.entity.SpawnPlayerMessage) EntityEquipmentMessage(net.glowstone.net.message.play.entity.EntityEquipmentMessage) Message(com.flowpowered.network.Message) EntityHeadRotationMessage(net.glowstone.net.message.play.entity.EntityHeadRotationMessage) SpawnPlayerMessage(net.glowstone.net.message.play.entity.SpawnPlayerMessage) EntityEquipment(org.bukkit.inventory.EntityEquipment) EntityEquipmentMessage(net.glowstone.net.message.play.entity.EntityEquipmentMessage)

Example 2 with SpawnPlayerMessage

use of net.glowstone.net.message.play.entity.SpawnPlayerMessage in project Glowstone by GlowstoneMC.

the class SpawnPlayerCodec method decode.

@Override
public SpawnPlayerMessage decode(ByteBuf buf) throws IOException {
    int id = ByteBufUtils.readVarInt(buf);
    UUID uuid = GlowBufUtils.readUuid(buf);
    double x = buf.readDouble();
    double y = buf.readDouble();
    double z = buf.readDouble();
    int rotation = buf.readByte();
    int pitch = buf.readByte();
    List<Entry> list = GlowBufUtils.readMetadata(buf);
    return new SpawnPlayerMessage(id, uuid, x, y, z, rotation, pitch, list);
}
Also used : Entry(net.glowstone.entity.meta.MetadataMap.Entry) SpawnPlayerMessage(net.glowstone.net.message.play.entity.SpawnPlayerMessage) UUID(java.util.UUID)

Aggregations

SpawnPlayerMessage (net.glowstone.net.message.play.entity.SpawnPlayerMessage)2 Message (com.flowpowered.network.Message)1 UUID (java.util.UUID)1 Entry (net.glowstone.entity.meta.MetadataMap.Entry)1 EntityEquipmentMessage (net.glowstone.net.message.play.entity.EntityEquipmentMessage)1 EntityHeadRotationMessage (net.glowstone.net.message.play.entity.EntityHeadRotationMessage)1 EntityEquipment (org.bukkit.inventory.EntityEquipment)1