Search in sources :

Example 1 with LanternPotionEffectType

use of org.lanternpowered.server.effect.potion.LanternPotionEffectType in project LanternServer by LanternPowered.

the class PotionEffectSerializer method serialize.

public static DataView serialize(PotionEffect potionEffect) {
    final DataView dataView = DataContainer.createNew(DataView.SafetyMode.NO_DATA_CLONED);
    dataView.set(AMPLIFIER, (byte) potionEffect.getAmplifier());
    dataView.set(DURATION, potionEffect.getDuration());
    dataView.set(AMBIENT, (byte) (potionEffect.isAmbient() ? 1 : 0));
    if (potionEffect.getShowParticles()) {
        dataView.set(SHOW_PARTICLES, (byte) 1);
    }
    final LanternPotionEffectType potionEffectType = (LanternPotionEffectType) potionEffect.getType();
    final int internalId = potionEffectType.getInternalId();
    if (internalId > 0xff) {
        dataView.set(IDENTIFIER, internalId);
    } else {
        dataView.set(IDENTIFIER, (byte) internalId);
    }
    return dataView;
}
Also used : DataView(org.spongepowered.api.data.DataView) LanternPotionEffectType(org.lanternpowered.server.effect.potion.LanternPotionEffectType)

Example 2 with LanternPotionEffectType

use of org.lanternpowered.server.effect.potion.LanternPotionEffectType in project LanternServer by LanternPowered.

the class CodecPlayOutRemovePotionEffect method encode.

@Override
public ByteBuffer encode(CodecContext context, MessagePlayOutRemovePotionEffect message) throws CodecException {
    final ByteBuffer buf = context.byteBufAlloc().buffer();
    buf.writeVarInt(message.getEntityId());
    buf.writeByte((byte) ((LanternPotionEffectType) message.getType()).getInternalId());
    return buf;
}
Also used : LanternPotionEffectType(org.lanternpowered.server.effect.potion.LanternPotionEffectType) ByteBuffer(org.lanternpowered.server.network.buffer.ByteBuffer)

Example 3 with LanternPotionEffectType

use of org.lanternpowered.server.effect.potion.LanternPotionEffectType in project LanternServer by LanternPowered.

the class CodecPlayOutAddPotionEffect method encode.

@Override
public ByteBuffer encode(CodecContext context, MessagePlayOutAddPotionEffect message) throws CodecException {
    final ByteBuffer buf = context.byteBufAlloc().buffer();
    buf.writeVarInt(message.getEntityId());
    buf.writeByte((byte) ((LanternPotionEffectType) message.getType()).getInternalId());
    buf.writeByte((byte) message.getAmplifier());
    buf.writeVarInt(message.getDuration());
    byte flags = 0;
    if (message.isAmbient()) {
        flags |= 0x1;
    }
    if (message.getShowParticles()) {
        flags |= 0x2;
    }
    buf.writeByte(flags);
    return buf;
}
Also used : LanternPotionEffectType(org.lanternpowered.server.effect.potion.LanternPotionEffectType) ByteBuffer(org.lanternpowered.server.network.buffer.ByteBuffer)

Example 4 with LanternPotionEffectType

use of org.lanternpowered.server.effect.potion.LanternPotionEffectType in project LanternServer by LanternPowered.

the class PotionEffectTypeRegistryModule method registerDefaults.

@Override
public void registerDefaults() {
    register(new LanternPotionEffectType("minecraft", "speed", 1, "moveSpeed"));
    register(new LanternPotionEffectType("minecraft", "slowness", 2, "moveSlowdown"));
    register(new LanternPotionEffectType("minecraft", "haste", 3, "digSpeed"));
    register(new LanternPotionEffectType("minecraft", "mining_fatigue", 4, "digSlowDown"));
    register(new LanternPotionEffectType("minecraft", "strength", 5, "damageBoost"));
    register(new LanternPotionEffectType("minecraft", "instant_health", 6, "heal").instant());
    register(new LanternPotionEffectType("minecraft", "instant_damage", 7, "harm").instant());
    register(new LanternPotionEffectType("minecraft", "jump_boost", 8, "jump"));
    register(new LanternPotionEffectType("minecraft", "nausea", 9, "confusion"));
    register(new LanternPotionEffectType("minecraft", "regeneration", 10, "regeneration"));
    register(new LanternPotionEffectType("minecraft", "resistance", 11, "resistance"));
    register(new LanternPotionEffectType("minecraft", "fire_resistance", 12, "fireResistance"));
    register(new LanternPotionEffectType("minecraft", "water_breathing", 13, "waterBreathing"));
    register(new LanternPotionEffectType("minecraft", "invisibility", 14, "invisibility"));
    register(new LanternPotionEffectType("minecraft", "blindness", 15, "blindness"));
    register(new LanternPotionEffectType("minecraft", "night_vision", 16, "nightVision"));
    register(new LanternPotionEffectType("minecraft", "hunger", 17, "hunger"));
    register(new LanternPotionEffectType("minecraft", "weakness", 18, "weakness"));
    register(new LanternPotionEffectType("minecraft", "poison", 19, "poison"));
    register(new LanternPotionEffectType("minecraft", "wither", 20, "wither"));
    register(new LanternPotionEffectType("minecraft", "health_boost", 21, "healthBoost"));
    register(new LanternPotionEffectType("minecraft", "absorption", 22, "absorption"));
    register(new LanternPotionEffectType("minecraft", "saturation", 23, "saturation"));
    register(new LanternPotionEffectType("minecraft", "glowing", 24, "glowing"));
    register(new LanternPotionEffectType("minecraft", "levitation", 25, "levitation"));
    register(new LanternPotionEffectType("minecraft", "luck", 26, "luck"));
    register(new LanternPotionEffectType("minecraft", "unluck", 27, "unluck"));
}
Also used : LanternPotionEffectType(org.lanternpowered.server.effect.potion.LanternPotionEffectType)

Aggregations

LanternPotionEffectType (org.lanternpowered.server.effect.potion.LanternPotionEffectType)4 ByteBuffer (org.lanternpowered.server.network.buffer.ByteBuffer)2 DataView (org.spongepowered.api.data.DataView)1