Search in sources :

Example 1 with SetEntityDataPacket

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

the class PCEntityMetadataPacketTranslator method translate.

public PEPacket[] translate(UpstreamSession session, ServerEntityMetadataPacket packet) {
    CachedEntity entity = session.getEntityCache().getByRemoteEID(packet.getEntityId());
    if (entity == null) {
        if (packet.getEntityId() == session.getEntityCache().getClientEntity().eid)
            entity = session.getEntityCache().getClientEntity();
        else
            return null;
    // System.out.println("!!!!!!!!!!!!!!! TRY TO update the player meta from PCEntityMetadataPacketTranslator");
    // return null;
    }
    entity.pcMeta = packet.getMetadata();
    if (entity.spawned) {
        SetEntityDataPacket pk = new SetEntityDataPacket();
        pk.rtid = entity.proxyEid;
        pk.meta = EntityMetaTranslator.translateToPE(session, packet.getMetadata(), entity.peType);
        session.sendPacket(pk);
    } else if (entity.peType == EntityType.PLAYER || entity.peType == EntityType.PAINTING) {
    // Do nothing here !
    } else
        entity.spawn(session);
    return null;
}
Also used : CachedEntity(org.dragonet.proxy.network.cache.CachedEntity) SetEntityDataPacket(org.dragonet.protocol.packets.SetEntityDataPacket)

Example 2 with SetEntityDataPacket

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

the class PCEntitySetPassengerPacketTranslator method setRiding.

// if offset is null, it's a dismount action
private void setRiding(UpstreamSession session, CachedEntity rider, Vector3F offset) {
    EntityMetaData peMeta = EntityMetaTranslator.translateToPE(session, rider.pcMeta, rider.peType);
    peMeta.setGenericFlag(EntityMetaData.Constants.DATA_FLAG_RIDING, offset != null);
    if (offset != null) {
        peMeta.set(EntityMetaData.Constants.DATA_RIDER_SEAT_POSITION, new Vector3FMeta(offset));
    }
    SetEntityDataPacket pk = new SetEntityDataPacket();
    pk.rtid = rider.proxyEid;
    pk.meta = peMeta;
    session.putCachePacket(pk);
}
Also used : SetEntityDataPacket(org.dragonet.protocol.packets.SetEntityDataPacket) EntityMetaData(org.dragonet.common.data.entity.meta.EntityMetaData) Vector3FMeta(org.dragonet.common.data.entity.meta.type.Vector3FMeta)

Aggregations

SetEntityDataPacket (org.dragonet.protocol.packets.SetEntityDataPacket)2 EntityMetaData (org.dragonet.common.data.entity.meta.EntityMetaData)1 Vector3FMeta (org.dragonet.common.data.entity.meta.type.Vector3FMeta)1 CachedEntity (org.dragonet.proxy.network.cache.CachedEntity)1