Search in sources :

Example 1 with MoveEntitiesPacket

use of org.dragonet.net.packet.minecraft.MoveEntitiesPacket 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 2 with MoveEntitiesPacket

use of org.dragonet.net.packet.minecraft.MoveEntitiesPacket 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)

Aggregations

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