Search in sources :

Example 1 with SetEntityMotionPacket

use of org.dragonet.protocol.packets.SetEntityMotionPacket in project DragonProxy by DragonetMC.

the class PCEntityVelocityPacketTranslator method translate.

public PEPacket[] translate(UpstreamSession session, ServerEntityVelocityPacket packet) {
    CachedEntity entity = session.getEntityCache().getByRemoteEID(packet.getEntityId());
    if (entity == null) {
        if (packet.getEntityId() == (int) session.getDataCache().get(CacheKey.PLAYER_EID)) {
            entity = session.getEntityCache().getClientEntity();
        } else {
            return null;
        }
    }
    entity.motionX = packet.getMotionX();
    entity.motionY = packet.getMotionY();
    entity.motionZ = packet.getMotionZ();
    SetEntityMotionPacket pk = new SetEntityMotionPacket();
    pk.rtid = entity.proxyEid;
    pk.motion = new Vector3F((float) packet.getMotionX(), (float) packet.getMotionY(), (float) packet.getMotionZ());
    return new PEPacket[] { pk };
}
Also used : SetEntityMotionPacket(org.dragonet.protocol.packets.SetEntityMotionPacket) CachedEntity(org.dragonet.proxy.network.cache.CachedEntity) Vector3F(org.dragonet.common.maths.Vector3F) PEPacket(org.dragonet.protocol.PEPacket)

Aggregations

Vector3F (org.dragonet.common.maths.Vector3F)1 PEPacket (org.dragonet.protocol.PEPacket)1 SetEntityMotionPacket (org.dragonet.protocol.packets.SetEntityMotionPacket)1 CachedEntity (org.dragonet.proxy.network.cache.CachedEntity)1