Search in sources :

Example 1 with AddPlayerPacket

use of org.dragonet.net.packet.minecraft.AddPlayerPacket in project Dragonet-Legacy by DragonetMC.

the class SpawnPlayerMessageTranslator method handleSpecific.

@Override
public PEPacket[] handleSpecific(SpawnPlayerMessage packet) {
    if (!this.getTranslator().cachedEntityIDs.contains(packet.id)) {
        // Add to the spawned entity list
        this.getTranslator().cachedEntityIDs.add(packet.id);
    }
    // Register this id as a player
    this.getTranslator().cachedPlayerEntities.add(packet.id);
    AddPlayerPacket pkAddPlayer = new AddPlayerPacket();
    pkAddPlayer.uuid = packet.getUuid();
    pkAddPlayer.eid = packet.getId();
    pkAddPlayer.username = this.getSession().getServer().getPlayer(packet.getUuid()).getDisplayName();
    pkAddPlayer.x = (float) packet.getX() / 32;
    pkAddPlayer.y = (float) packet.getY() / 32;
    pkAddPlayer.z = (float) packet.getZ() / 32;
    // return (int) (((loc.getYaw() % 360) / 360) * 256);
    pkAddPlayer.speedX = 0.0f;
    pkAddPlayer.speedY = 0.0f;
    pkAddPlayer.speedZ = 0.0f;
    pkAddPlayer.yaw = ((float) packet.getRotation() / 256) * 360;
    pkAddPlayer.pitch = ((float) packet.getPitch() / 256) * 360;
    // pkAddPlayer.metadata = EntityMetaData.getMetaDataFromPlayer((GlowPlayer) this.getSession().getPlayer().getWorld().getEntityManager().getEntity(packet.getId())); TODO Fix the metadata, this one of the reasons why skins weren't working properly!
    PlayerListPacket lst = new PlayerListPacket(new PlayerListPacket.PlayerInfo(packet.getUuid(), packet.getId(), pkAddPlayer.username, true, false, DefaultSkin.getDefaultSkin()));
    return new PEPacket[] { pkAddPlayer, lst };
}
Also used : AddPlayerPacket(org.dragonet.net.packet.minecraft.AddPlayerPacket) PEPacket(org.dragonet.net.packet.minecraft.PEPacket) PlayerListPacket(org.dragonet.net.packet.minecraft.PlayerListPacket)

Aggregations

AddPlayerPacket (org.dragonet.net.packet.minecraft.AddPlayerPacket)1 PEPacket (org.dragonet.net.packet.minecraft.PEPacket)1 PlayerListPacket (org.dragonet.net.packet.minecraft.PlayerListPacket)1