Search in sources :

Example 11 with MobEffect

use of net.minecraft.server.v1_15_R1.MobEffect in project PaperDev by Kamillaova.

the class CraftPotionBrewer method getEffects.

public Collection<PotionEffect> getEffects(PotionType damage, boolean upgraded, boolean extended) {
    if (cache.containsKey(damage))
        return cache.get(damage);
    List<MobEffect> mcEffects = PotionRegistry.a(CraftPotionUtil.fromBukkit(new PotionData(damage, extended, upgraded))).a();
    ImmutableList.Builder<PotionEffect> builder = new ImmutableList.Builder<PotionEffect>();
    for (MobEffect effect : mcEffects) {
        builder.add(CraftPotionUtil.toBukkit(effect));
    }
    cache.put(damage, builder.build());
    return cache.get(damage);
}
Also used : PotionData(org.bukkit.potion.PotionData) PotionEffect(org.bukkit.potion.PotionEffect) ImmutableList(com.google.common.collect.ImmutableList) MobEffect(net.minecraft.server.v1_12_R1.MobEffect)

Example 12 with MobEffect

use of net.minecraft.server.v1_15_R1.MobEffect in project PaperDev by Kamillaova.

the class CraftTippedArrow method removeCustomEffect.

@Override
public boolean removeCustomEffect(PotionEffectType effect) {
    int effectId = effect.getId();
    MobEffect existing = null;
    for (MobEffect mobEffect : getHandle().effects) {
        if (MobEffectList.getId(mobEffect.getMobEffect()) == effectId) {
            existing = mobEffect;
        }
    }
    if (existing == null) {
        return false;
    }
    Validate.isTrue(getBasePotionData().getType() != PotionType.UNCRAFTABLE || !getHandle().effects.isEmpty(), "Tipped Arrows must have at least 1 effect");
    getHandle().effects.remove(existing);
    getHandle().refreshEffects();
    return true;
}
Also used : MobEffect(net.minecraft.server.v1_12_R1.MobEffect)

Example 13 with MobEffect

use of net.minecraft.server.v1_15_R1.MobEffect in project PaperDev by Kamillaova.

the class CraftAreaEffectCloud method removeCustomEffect.

@Override
public boolean removeCustomEffect(PotionEffectType effect) {
    int effectId = effect.getId();
    MobEffect existing = null;
    for (MobEffect mobEffect : getHandle().effects) {
        if (MobEffectList.getId(mobEffect.getMobEffect()) == effectId) {
            existing = mobEffect;
        }
    }
    if (existing == null) {
        return false;
    }
    getHandle().effects.remove(existing);
    getHandle().refreshEffects();
    return true;
}
Also used : MobEffect(net.minecraft.server.v1_12_R1.MobEffect)

Example 14 with MobEffect

use of net.minecraft.server.v1_15_R1.MobEffect in project MechanicsMain by WeaponMechanics.

the class Scope_1_9_R2 method removeNightVision.

@Override
public void removeNightVision(Player player) {
    if (player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) {
        EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
        // Simply remove the entity effect
        PacketPlayOutRemoveEntityEffect removeEntityEffect = new PacketPlayOutRemoveEntityEffect(player.getEntityId(), MobEffectList.fromId(PotionEffectType.NIGHT_VISION.getId()));
        entityPlayer.playerConnection.sendPacket(removeEntityEffect);
        // resend the existing one
        MobEffect mobEffect = entityPlayer.getEffect(MobEffectList.fromId(PotionEffectType.NIGHT_VISION.getId()));
        PacketPlayOutEntityEffect entityEffect = new PacketPlayOutEntityEffect(player.getEntityId(), mobEffect);
        ((CraftPlayer) player).getHandle().playerConnection.sendPacket(entityEffect);
        return;
    }
    // Simply remove the entity effect
    PacketPlayOutRemoveEntityEffect removeEntityEffect = new PacketPlayOutRemoveEntityEffect(player.getEntityId(), MobEffectList.fromId(PotionEffectType.NIGHT_VISION.getId()));
    ((CraftPlayer) player).getHandle().playerConnection.sendPacket(removeEntityEffect);
}
Also used : PacketPlayOutEntityEffect(net.minecraft.server.v1_9_R2.PacketPlayOutEntityEffect) MobEffect(net.minecraft.server.v1_9_R2.MobEffect) EntityPlayer(net.minecraft.server.v1_9_R2.EntityPlayer) PacketPlayOutRemoveEntityEffect(net.minecraft.server.v1_9_R2.PacketPlayOutRemoveEntityEffect) CraftPlayer(org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer)

Example 15 with MobEffect

use of net.minecraft.server.v1_15_R1.MobEffect in project MechanicsMain by WeaponMechanics.

the class Scope_1_9_R2 method addNightVision.

@Override
public void addNightVision(Player player) {
    // 6000 = 5min
    PacketPlayOutEntityEffect entityEffect = new PacketPlayOutEntityEffect(-player.getEntityId(), new MobEffect(MobEffectList.fromId(PotionEffectType.NIGHT_VISION.getId()), 6000, 2));
    ((CraftPlayer) player).getHandle().playerConnection.sendPacket(entityEffect);
}
Also used : PacketPlayOutEntityEffect(net.minecraft.server.v1_9_R2.PacketPlayOutEntityEffect) MobEffect(net.minecraft.server.v1_9_R2.MobEffect) CraftPlayer(org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer)

Aggregations

MobEffect (net.minecraft.server.v1_12_R1.MobEffect)7 MobEffect (net.minecraft.server.v1_10_R1.MobEffect)2 PacketPlayOutEntityEffect (net.minecraft.server.v1_10_R1.PacketPlayOutEntityEffect)2 MobEffect (net.minecraft.server.v1_11_R1.MobEffect)2 PacketPlayOutEntityEffect (net.minecraft.server.v1_11_R1.PacketPlayOutEntityEffect)2 PacketPlayOutEntityEffect (net.minecraft.server.v1_12_R1.PacketPlayOutEntityEffect)2 MobEffect (net.minecraft.server.v1_13_R2.MobEffect)2 PacketPlayOutEntityEffect (net.minecraft.server.v1_13_R2.PacketPlayOutEntityEffect)2 MobEffect (net.minecraft.server.v1_14_R1.MobEffect)2 PacketPlayOutEntityEffect (net.minecraft.server.v1_14_R1.PacketPlayOutEntityEffect)2 MobEffect (net.minecraft.server.v1_15_R1.MobEffect)2 PacketPlayOutEntityEffect (net.minecraft.server.v1_15_R1.PacketPlayOutEntityEffect)2 MobEffect (net.minecraft.server.v1_16_R3.MobEffect)2 PacketPlayOutEntityEffect (net.minecraft.server.v1_16_R3.PacketPlayOutEntityEffect)2 MobEffect (net.minecraft.server.v1_9_R2.MobEffect)2 PacketPlayOutEntityEffect (net.minecraft.server.v1_9_R2.PacketPlayOutEntityEffect)2 CraftPlayer (org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer)2 CraftPlayer (org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer)2 CraftPlayer (org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer)2 CraftPlayer (org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer)2