Search in sources :

Example 1 with MovePlayerPacket

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

the class DragonetSession method sendPosition.

/**
     * Send the server side position to the client, used to correct the position
     */
public void sendPosition() {
    if (this.getPlayer() == null) {
        return;
    }
    /*
         MoveEntitiesPacket.MoveEntityData d = new MoveEntitiesPacket.MoveEntityData();
         d.eid = this.getPlayer().getEntityId();
         d.x = (float) this.getPlayer().getLocation().getX();
         d.y = (float) this.getPlayer().getLocation().getY();
         d.z = (float) this.getPlayer().getLocation().getZ();
         d.yaw = this.getPlayer().getLocation().getYaw();
         d.pitch = this.getPlayer().getLocation().getPitch();
         MoveEntitiesPacket pkMovePlayer = new MoveEntitiesPacket(new MoveEntitiesPacket.MoveEntityData[]{d});
         */
    MovePlayerPacket pkMovePlayer = new MovePlayerPacket();
    pkMovePlayer.eid = this.getPlayer().getEntityId();
    pkMovePlayer.x = (float) this.getPlayer().getLocation().getX();
    pkMovePlayer.y = (float) this.getPlayer().getLocation().getY();
    pkMovePlayer.z = (float) this.getPlayer().getLocation().getZ();
    pkMovePlayer.yaw = this.getPlayer().getLocation().getYaw();
    pkMovePlayer.bodyYaw = this.getPlayer().getLocation().getYaw();
    pkMovePlayer.pitch = this.getPlayer().getLocation().getPitch();
    pkMovePlayer.teleport = true;
    this.send(pkMovePlayer);
}
Also used : MovePlayerPacket(org.dragonet.net.packet.minecraft.MovePlayerPacket)

Example 2 with MovePlayerPacket

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

the class RelativeEntityPositionMessageTranslator method handleSpecific.

@Override
public PEPacket[] handleSpecific(RelativeEntityPositionMessage packet) {
    Entity entity = this.getSession().getPlayer().getWorld().getEntityManager().getEntity(packet.id);
    if (entity == null) {
        return null;
    }
    if (entity instanceof GlowPlayer) {
        boolean isTeleport = (packet.deltaX ^ 2 + packet.deltaY ^ 2 + packet.deltaZ ^ 2) > 4;
        MovePlayerPacket pkMovePlayer = new MovePlayerPacket(packet.id, (float) entity.getLocation().getX(), (float) entity.getLocation().getY(), (float) entity.getLocation().getZ(), entity.getLocation().getYaw(), entity.getLocation().getPitch(), entity.getLocation().getYaw(), isTeleport);
        return new PEPacket[] { pkMovePlayer };
    } else {
        MoveEntitiesPacket.MoveEntityData data = new MoveEntitiesPacket.MoveEntityData();
        data.eid = packet.id;
        data.x = (float) entity.getLocation().getX();
        data.y = (float) entity.getLocation().getY();
        data.z = (float) entity.getLocation().getZ();
        data.yaw = (float) entity.getLocation().getYaw();
        data.pitch = (float) entity.getLocation().getPitch();
        MoveEntitiesPacket pk = new MoveEntitiesPacket(new MoveEntitiesPacket.MoveEntityData[] { data });
        return new PEPacket[] { pk };
    }
}
Also used : Entity(org.bukkit.entity.Entity) MoveEntitiesPacket(org.dragonet.net.packet.minecraft.MoveEntitiesPacket) GlowPlayer(net.glowstone.entity.GlowPlayer) PEPacket(org.dragonet.net.packet.minecraft.PEPacket) MovePlayerPacket(org.dragonet.net.packet.minecraft.MovePlayerPacket)

Example 3 with MovePlayerPacket

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

the class RelativeEntityPositionRotationMessageTranslator method handleSpecific.

@Override
public PEPacket[] handleSpecific(RelativeEntityPositionRotationMessage packet) {
    Entity entity = this.getSession().getPlayer().getWorld().getEntityManager().getEntity(packet.id);
    if (entity == null) {
        return null;
    }
    if (entity instanceof GlowPlayer) {
        boolean isTeleport = (packet.deltaX ^ 2 + packet.deltaY ^ 2 + packet.deltaZ ^ 2) > 4;
        MovePlayerPacket pkMovePlayer = new MovePlayerPacket(packet.id, (float) entity.getLocation().getX(), (float) entity.getLocation().getY(), (float) entity.getLocation().getZ(), (float) entity.getLocation().getYaw(), (float) entity.getLocation().getPitch(), (float) entity.getLocation().getYaw(), isTeleport);
        return new PEPacket[] { pkMovePlayer };
    } else {
        MoveEntitiesPacket.MoveEntityData data = new MoveEntitiesPacket.MoveEntityData();
        data.eid = packet.id;
        data.x = (float) entity.getLocation().getX();
        data.y = (float) entity.getLocation().getY();
        data.z = (float) entity.getLocation().getZ();
        data.yaw = (float) entity.getLocation().getYaw();
        data.pitch = (float) entity.getLocation().getPitch();
        MoveEntitiesPacket pk = new MoveEntitiesPacket(new MoveEntitiesPacket.MoveEntityData[] { data });
        return new PEPacket[] { pk };
    }
}
Also used : Entity(org.bukkit.entity.Entity) MoveEntitiesPacket(org.dragonet.net.packet.minecraft.MoveEntitiesPacket) GlowPlayer(net.glowstone.entity.GlowPlayer) PEPacket(org.dragonet.net.packet.minecraft.PEPacket) MovePlayerPacket(org.dragonet.net.packet.minecraft.MovePlayerPacket)

Example 4 with MovePlayerPacket

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

the class PlayerPositionMessageTranslator method handleSpecific.

@Override
public PEPacket[] handleSpecific(PlayerPositionMessage packet) {
    MovePlayerPacket pkMovePlayer = new MovePlayerPacket();
    pkMovePlayer.eid = this.getSession().getPlayer().getEntityId();
    pkMovePlayer.x = (float) packet.x;
    pkMovePlayer.y = (float) packet.y;
    pkMovePlayer.z = (float) packet.z;
    pkMovePlayer.yaw = this.getSession().getPlayer().getLocation().getYaw();
    pkMovePlayer.pitch = this.getSession().getPlayer().getLocation().getPitch();
    pkMovePlayer.teleport = true;
    return new PEPacket[] { pkMovePlayer };
}
Also used : PEPacket(org.dragonet.net.packet.minecraft.PEPacket) MovePlayerPacket(org.dragonet.net.packet.minecraft.MovePlayerPacket)

Example 5 with MovePlayerPacket

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

the class PlayerPositionLookMessageTranslator method handleSpecific.

@Override
public PEPacket[] handleSpecific(PlayerPositionLookMessage packet) {
    MovePlayerPacket pkMovePlayer = new MovePlayerPacket();
    pkMovePlayer.eid = this.getSession().getPlayer().getEntityId();
    pkMovePlayer.x = (float) packet.x;
    pkMovePlayer.y = (float) packet.y;
    pkMovePlayer.z = (float) packet.z;
    pkMovePlayer.yaw = packet.yaw;
    pkMovePlayer.pitch = packet.pitch;
    pkMovePlayer.teleport = true;
    return new PEPacket[] { pkMovePlayer };
}
Also used : PEPacket(org.dragonet.net.packet.minecraft.PEPacket) MovePlayerPacket(org.dragonet.net.packet.minecraft.MovePlayerPacket)

Aggregations

MovePlayerPacket (org.dragonet.net.packet.minecraft.MovePlayerPacket)5 PEPacket (org.dragonet.net.packet.minecraft.PEPacket)4 GlowPlayer (net.glowstone.entity.GlowPlayer)2 Entity (org.bukkit.entity.Entity)2 MoveEntitiesPacket (org.dragonet.net.packet.minecraft.MoveEntitiesPacket)2