Java 类net.minecraft.server.MobEffect 实例源码

项目:CraftBukkit    文件:CraftPotionBrewer.java   
public Collection<PotionEffect> getEffectsFromDamage(int damage) {
    if (cache.containsKey(damage))
        return cache.get(damage);

    List<?> mcEffects = net.minecraft.server.PotionBrewer.getEffects(damage, false);
    List<PotionEffect> effects = new ArrayList<PotionEffect>();
    if (mcEffects == null)
        return effects;

    for (Object raw : mcEffects) {
        if (raw == null || !(raw instanceof MobEffect))
            continue;
        MobEffect mcEffect = (MobEffect) raw;
        PotionEffect effect = new PotionEffect(PotionEffectType.getById(mcEffect.getEffectId()),
                mcEffect.getDuration(), mcEffect.getAmplifier());
        // Minecraft PotionBrewer applies duration modifiers automatically.
        effects.add(effect);
    }

    cache.put(damage, effects);

    return effects;
}
项目:Craftbukkit    文件:CraftPotionBrewer.java   
public Collection<PotionEffect> getEffectsFromDamage(int damage) {
    if (cache.containsKey(damage))
        return cache.get(damage);

    List<?> mcEffects = net.minecraft.server.PotionBrewer.getEffects(damage, false);
    List<PotionEffect> effects = new ArrayList<PotionEffect>();
    if (mcEffects == null)
        return effects;

    for (Object raw : mcEffects) {
        if (raw == null || !(raw instanceof MobEffect))
            continue;
        MobEffect mcEffect = (MobEffect) raw;
        PotionEffect effect = new PotionEffect(PotionEffectType.getById(mcEffect.getEffectId()),
                mcEffect.getDuration(), mcEffect.getAmplifier());
        // Minecraft PotionBrewer applies duration modifiers automatically.
        effects.add(effect);
    }

    cache.put(damage, effects);

    return effects;
}
项目:Almura-Server    文件:CraftPotionBrewer.java   
public Collection<PotionEffect> getEffectsFromDamage(int damage) {
    if (cache.containsKey(damage))
        return cache.get(damage);

    List<?> mcEffects = net.minecraft.server.PotionBrewer.getEffects(damage, false);
    List<PotionEffect> effects = new ArrayList<PotionEffect>();
    if (mcEffects == null)
        return effects;

    for (Object raw : mcEffects) {
        if (raw == null || !(raw instanceof MobEffect))
            continue;
        MobEffect mcEffect = (MobEffect) raw;
        PotionEffect effect = new PotionEffect(PotionEffectType.getById(mcEffect.getEffectId()),
                mcEffect.getDuration(), mcEffect.getAmplifier());
        // Minecraft PotionBrewer applies duration modifiers automatically.
        effects.add(effect);
    }

    cache.put(damage, effects);

    return effects;
}
项目:Tweakkit-Server    文件:CraftPotionBrewer.java   
public Collection<PotionEffect> getEffectsFromDamage(int damage) {
    if (cache.containsKey(damage))
        return cache.get(damage);

    List<?> mcEffects = net.minecraft.server.PotionBrewer.getEffects(damage, false);
    List<PotionEffect> effects = new ArrayList<PotionEffect>();
    if (mcEffects == null)
        return effects;

    for (Object raw : mcEffects) {
        if (raw == null || !(raw instanceof MobEffect))
            continue;
        MobEffect mcEffect = (MobEffect) raw;
        PotionEffect effect = new PotionEffect(PotionEffectType.getById(mcEffect.getEffectId()),
                mcEffect.getDuration(), mcEffect.getAmplifier());
        // Minecraft PotionBrewer applies duration modifiers automatically.
        effects.add(effect);
    }

    cache.put(damage, effects);

    return effects;
}
项目:SpigotSource    文件:CraftTippedArrow.java   
@Override
public boolean addCustomEffect(PotionEffect effect, boolean override) {
    int effectId = effect.getType().getId();
    MobEffect existing = null;
    for (MobEffect mobEffect : getHandle().h) {
        if (MobEffectList.getId(mobEffect.getMobEffect()) == effectId) {
            existing = mobEffect;
        }
    }
    if (existing != null) {
        if (!override) {
            return false;
        }
        getHandle().h.remove(existing);
    }
    getHandle().a(CraftPotionUtil.fromBukkit(effect));
    getHandle().refreshEffects();
    return true;
}
项目:SpigotSource    文件:CraftTippedArrow.java   
@Override
public boolean removeCustomEffect(PotionEffectType effect) {
    int effectId = effect.getId();
    MobEffect existing = null;
    for (MobEffect mobEffect : getHandle().h) {
        if (MobEffectList.getId(mobEffect.getMobEffect()) == effectId) {
            existing = mobEffect;
        }
    }
    if (existing == null) {
        return false;
    }
    Validate.isTrue(getBasePotionData().getType() != PotionType.UNCRAFTABLE || getHandle().h.size() != 1, "Tipped Arrows must have at least 1 effect");
    getHandle().h.remove(existing);
    getHandle().refreshEffects();
    return true;
}
项目:SpigotSource    文件:CraftAreaEffectCloud.java   
@Override
public boolean addCustomEffect(PotionEffect effect, boolean override) {
    int effectId = effect.getType().getId();
    MobEffect existing = null;
    for (MobEffect mobEffect : getHandle().effects) {
        if (MobEffectList.getId(mobEffect.getMobEffect()) == effectId) {
            existing = mobEffect;
        }
    }
    if (existing != null) {
        if (!override) {
            return false;
        }
        getHandle().effects.remove(existing);
    }
    getHandle().a(CraftPotionUtil.fromBukkit(effect));
    getHandle().refreshEffects();
    return true;
}
项目:SpigotSource    文件:CraftAreaEffectCloud.java   
@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;
}
项目:SpigotSource    文件:PotionTest.java   
@Test
public void testEffectCompleteness() throws Throwable {
    Map<PotionType, String> effects = new EnumMap(PotionType.class);
    for (PotionRegistry reg : PotionRegistry.a) {
        List<MobEffect> eff = reg.a();
        if (eff.size() != 1) continue;
        int id = MobEffectList.getId(eff.get(0).getMobEffect());
        PotionEffectType type = PotionEffectType.getById(id);
        assertNotNull(String.valueOf(id), PotionEffectType.getById(id));

        PotionType enumType = PotionType.getByEffect(type);
        assertNotNull(type.getName(), enumType);

        effects.put(enumType, enumType.name());
    }

    assertEquals(effects.entrySet().size(), PotionType.values().length - /* PotionTypes with no Effects */ 5);
}
项目:Craft-city    文件:CraftPotionBrewer.java   
public Collection<PotionEffect> getEffectsFromDamage(int damage) {
    if (cache.containsKey(damage))
        return cache.get(damage);

    List<?> mcEffects = net.minecraft.server.PotionBrewer.getEffects(damage, false);
    List<PotionEffect> effects = new ArrayList<PotionEffect>();
    if (mcEffects == null)
        return effects;

    for (Object raw : mcEffects) {
        if (raw == null || !(raw instanceof MobEffect))
            continue;
        MobEffect mcEffect = (MobEffect) raw;
        PotionEffect effect = new PotionEffect(PotionEffectType.getById(mcEffect.getEffectId()),
                mcEffect.getDuration(), mcEffect.getAmplifier());
        // Minecraft PotionBrewer applies duration modifiers automatically.
        effects.add(effect);
    }

    cache.put(damage, effects);

    return effects;
}
项目:CraftBukkit    文件:CraftLivingEntity.java   
public boolean addPotionEffect(PotionEffect effect, boolean force) {
    if (hasPotionEffect(effect.getType())) {
        if (!force) {
            return false;
        }
        removePotionEffect(effect.getType());
    }
    getHandle().addEffect(new MobEffect(effect.getType().getId(), effect.getDuration(), effect.getAmplifier(), effect.isAmbient()));
    return true;
}
项目:CraftBukkit    文件:CraftLivingEntity.java   
public Collection<PotionEffect> getActivePotionEffects() {
    List<PotionEffect> effects = new ArrayList<PotionEffect>();
    for (Object raw : getHandle().effects.values()) {
        if (!(raw instanceof MobEffect))
            continue;
        MobEffect handle = (MobEffect) raw;
        effects.add(new PotionEffect(PotionEffectType.getById(handle.getEffectId()), handle.getDuration(), handle.getAmplifier(), handle.isAmbient()));
    }
    return effects;
}
项目:Craftbukkit    文件:CraftLivingEntity.java   
public boolean addPotionEffect(PotionEffect effect, boolean force) {
    if (hasPotionEffect(effect.getType())) {
        if (!force) {
            return false;
        }
        removePotionEffect(effect.getType());
    }
    getHandle().addEffect(new MobEffect(effect.getType().getId(), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles()));
    return true;
}
项目:Craftbukkit    文件:CraftLivingEntity.java   
public Collection<PotionEffect> getActivePotionEffects() {
    List<PotionEffect> effects = new ArrayList<PotionEffect>();
    for (Object raw : getHandle().effects.values()) {
        if (!(raw instanceof MobEffect))
            continue;
        MobEffect handle = (MobEffect) raw;
        effects.add(new PotionEffect(PotionEffectType.getById(handle.getEffectId()), handle.getDuration(), handle.getAmplifier(), handle.isAmbient(), handle.isShowParticles()));
    }
    return effects;
}
项目:Almura-Server    文件:CraftLivingEntity.java   
public boolean addPotionEffect(PotionEffect effect, boolean force) {
    if (hasPotionEffect(effect.getType())) {
        if (!force) {
            return false;
        }
        removePotionEffect(effect.getType());
    }
    getHandle().addEffect(new MobEffect(effect.getType().getId(), effect.getDuration(), effect.getAmplifier(), effect.isAmbient()));
    return true;
}
项目:Almura-Server    文件:CraftLivingEntity.java   
public Collection<PotionEffect> getActivePotionEffects() {
    List<PotionEffect> effects = new ArrayList<PotionEffect>();
    for (Object raw : getHandle().effects.values()) {
        if (!(raw instanceof MobEffect))
            continue;
        MobEffect handle = (MobEffect) raw;
        effects.add(new PotionEffect(PotionEffectType.getById(handle.getEffectId()), handle.getDuration(), handle.getAmplifier(), handle.isAmbient()));
    }
    return effects;
}
项目:Tweakkit-Server    文件:CraftLivingEntity.java   
public boolean addPotionEffect(PotionEffect effect, boolean force) {
    if (hasPotionEffect(effect.getType())) {
        if (!force) {
            return false;
        }
        // removePotionEffect(effect.getType()); // Tweakkit - Now completely unecessary since this is updated internally
    }
    // Tweakkit
    getHandle().addEffect(new MobEffect(effect.getType().getId(), effect.getDuration(), effect.getAmplifier(), effect.isAmbient()), EntityPotionEffectChangeEvent.Cause.PLUGIN_ADDED);
    return true;
}
项目:Tweakkit-Server    文件:CraftLivingEntity.java   
public Collection<PotionEffect> getActivePotionEffects() {
    List<PotionEffect> effects = new ArrayList<PotionEffect>();
    for (Object raw : getHandle().effects.values()) {
        if (!(raw instanceof MobEffect))
            continue;
        MobEffect handle = (MobEffect) raw;
        effects.add(new PotionEffect(PotionEffectType.getById(handle.getEffectId()), handle.getDuration(), handle.getAmplifier(), handle.isAmbient()));
    }
    return effects;
}
项目:SpigotSource    文件:CraftLivingEntity.java   
public boolean addPotionEffect(PotionEffect effect, boolean force) {
    if (hasPotionEffect(effect.getType())) {
        if (!force) {
            return false;
        }
        removePotionEffect(effect.getType());
    }
    getHandle().addEffect(new MobEffect(MobEffectList.fromId(effect.getType().getId()), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles()));
    return true;
}
项目:SpigotSource    文件:CraftLivingEntity.java   
public Collection<PotionEffect> getActivePotionEffects() {
    List<PotionEffect> effects = new ArrayList<PotionEffect>();
    for (MobEffect handle : getHandle().effects.values()) {
        effects.add(new PotionEffect(PotionEffectType.getById(MobEffectList.getId(handle.getMobEffect())), handle.getDuration(), handle.getAmplifier(), handle.isAmbient(), handle.isShowParticles()));
    }
    return effects;
}
项目:SpigotSource    文件:CraftThrownPotion.java   
public Collection<PotionEffect> getEffects() {
    ImmutableList.Builder<PotionEffect> builder = ImmutableList.builder();
    for (MobEffect effect : PotionUtil.getEffects(getHandle().getItem())) {
        builder.add(CraftPotionUtil.toBukkit(effect));
    }
    return builder.build();
}
项目:SpigotSource    文件:CraftTippedArrow.java   
@Override
public List<PotionEffect> getCustomEffects() {
    ImmutableList.Builder<PotionEffect> builder = ImmutableList.builder();
    for (MobEffect effect : getHandle().h) {
        builder.add(CraftPotionUtil.toBukkit(effect));
    }
    return builder.build();
}
项目:SpigotSource    文件:CraftTippedArrow.java   
@Override
public boolean hasCustomEffect(PotionEffectType type) {
    for (MobEffect effect : getHandle().h) {
        if (CraftPotionUtil.equals(effect.getMobEffect(), type)) {
            return true;
        }
    }
    return false;
}
项目:SpigotSource    文件:CraftAreaEffectCloud.java   
@Override
public List<PotionEffect> getCustomEffects() {
    ImmutableList.Builder<PotionEffect> builder = ImmutableList.builder();
    for (MobEffect effect : getHandle().effects) {
        builder.add(CraftPotionUtil.toBukkit(effect));
    }
    return builder.build();
}
项目:SpigotSource    文件:CraftAreaEffectCloud.java   
@Override
public boolean hasCustomEffect(PotionEffectType type) {
    for (MobEffect effect : getHandle().effects) {
        if (CraftPotionUtil.equals(effect.getMobEffect(), type)) {
            return true;
        }
    }
    return false;
}
项目:SpigotSource    文件:CraftPotionUtil.java   
public static PotionEffect toBukkit(MobEffect effect) {
    PotionEffectType type = PotionEffectType.getById(MobEffectList.getId(effect.getMobEffect()));
    int amp = effect.getAmplifier();
    int duration = effect.getDuration();
    boolean ambient = effect.isAmbient();
    boolean particles = effect.isShowParticles();
    return new PotionEffect(type, duration, amp, ambient, particles);
}
项目:SpigotSource    文件:CraftPotionBrewer.java   
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);
}
项目:Craft-city    文件:CraftLivingEntity.java   
public boolean addPotionEffect(PotionEffect effect, boolean force) {
    if (hasPotionEffect(effect.getType())) {
        if (!force) {
            return false;
        }
        removePotionEffect(effect.getType());
    }
    getHandle().addEffect(new MobEffect(effect.getType().getId(), effect.getDuration(), effect.getAmplifier()));
    return true;
}
项目:Craft-city    文件:CraftLivingEntity.java   
public void removePotionEffect(PotionEffectType type) {
    getHandle().effects.remove(type.getId());
    getHandle().updateEffects = true;
    if (getHandle() instanceof EntityPlayer) {
        if (((EntityPlayer) getHandle()).playerConnection == null) return;
        ((EntityPlayer) getHandle()).playerConnection.sendPacket(new Packet42RemoveMobEffect(getHandle().id, new MobEffect(type.getId(), 0, 0)));
    }
}
项目:Craft-city    文件:CraftLivingEntity.java   
public Collection<PotionEffect> getActivePotionEffects() {
    List<PotionEffect> effects = new ArrayList<PotionEffect>();
    for (Object raw : getHandle().effects.values()) {
        if (!(raw instanceof MobEffect))
            continue;
        MobEffect handle = (MobEffect) raw;
        effects.add(new PotionEffect(PotionEffectType.getById(handle.getEffectId()), handle.getDuration(), handle.getAmplifier()));
    }
    return effects;
}
项目:ProjectAres    文件:NMSHacks.java   
public static void sendDeathEffects(Player player, boolean blackout) {
    sendPacket(player, new PacketPlayOutEntityEffect(player.getEntityId(),
            new MobEffect(MobEffectList.getByName("nausea"), 100, 0, true, false)));
    sendPacket(player, new PacketPlayOutEntityEffect(player.getEntityId(),
            new MobEffect(MobEffectList.getByName("blindness"), blackout ? Integer.MAX_VALUE : 21, 0, true, false)));
}
项目:Tweakkit-Server    文件:CraftEventFactory.java   
public static EntityPotionEffectChangeEvent callEntityPotionEffectChangeEvent(EntityLiving living, MobEffect mobEffect, EntityPotionEffectChangeEvent.Cause cause, World world, double locX, double locY, double locZ){
    PotionEffect effect = new PotionEffect(PotionEffectType.getById(mobEffect.getEffectId()), mobEffect.getDuration(), mobEffect.getAmplifier());
    CraftLivingEntity entity = (CraftLivingEntity) living.getBukkitEntity();
    Location location = new Location(world.getWorld(), locX, locY, locZ);
    return callEntityPotionEffectChangeEvent(entity, effect, cause, location);
}
项目:SpigotSource    文件:CraftPotionUtil.java   
public static MobEffect fromBukkit(PotionEffect effect) {
    MobEffectList type = MobEffectList.fromId(effect.getType().getId());
    return new MobEffect(type, effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles());
}