use of org.dragonet.protocol.packets.MobEffectPacket in project DragonProxy by DragonetMC.
the class PCEntityRemoveEffectPacketTranslator method translate.
public PEPacket[] translate(UpstreamSession session, ServerEntityRemoveEffectPacket 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());
if (!entity.effects.contains(effectId)) {
return null;
}
MobEffectPacket eff = new MobEffectPacket();
eff.rtid = entity.proxyEid;
eff.eventId = MobEffectPacket.EVENT_REMOVE;
return new PEPacket[] { eff };
}
use of org.dragonet.protocol.packets.MobEffectPacket 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 };
}
Aggregations