Search in sources :

Example 1 with PocketPotionEffect

use of org.dragonet.common.data.PocketPotionEffect in project DragonProxy by DragonetMC.

the class PCEntityEffectPacketTranslator method translate.

public PEPacket[] translate(UpstreamSession session, ServerEntityEffectPacket 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;
        }
    }
    int effectId = MagicValues.value(Integer.class, packet.getEffect());
    PocketPotionEffect effect = PocketPotionEffect.getByID(effectId);
    if (effect == null) {
        System.out.println("Unknown effect ID: " + effectId);
        return null;
    }
    MobEffectPacket eff = new MobEffectPacket();
    eff.rtid = entity.proxyEid;
    eff.effectId = effect.getEffect();
    if (entity.effects.contains(effectId)) {
        eff.eventId = MobEffectPacket.EVENT_MODIFY;
    } else {
        eff.eventId = MobEffectPacket.EVENT_ADD;
        entity.effects.add(effectId);
    }
    eff.amplifier = packet.getAmplifier();
    eff.duration = packet.getDuration();
    eff.particles = packet.getShowParticles();
    return new PEPacket[] { eff };
}
Also used : CachedEntity(org.dragonet.proxy.network.cache.CachedEntity) PocketPotionEffect(org.dragonet.common.data.PocketPotionEffect) PEPacket(org.dragonet.protocol.PEPacket) MobEffectPacket(org.dragonet.protocol.packets.MobEffectPacket)

Aggregations

PocketPotionEffect (org.dragonet.common.data.PocketPotionEffect)1 PEPacket (org.dragonet.protocol.PEPacket)1 MobEffectPacket (org.dragonet.protocol.packets.MobEffectPacket)1 CachedEntity (org.dragonet.proxy.network.cache.CachedEntity)1