/** * Attempts to add the effect represented by this object to the given * {@link LivingEntity}. * * @see LivingEntity#addPotionEffect(PotionEffect) * @param entity The entity to add this effect to * @return Whether the effect could be added */ public boolean apply(LivingEntity entity) { return entity.addPotionEffect(this); }
@Override public void collide(LivingEntity entity) { super.collide(entity); entity.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, glowingTicks, 1)); }
target.addPotionEffect((instantIntensity >= 1.0 || baseAmplifier <= 1) ? effect : new PotionEffect( return; target.addPotionEffect(durationIntensity >= 1.0 ? effect : new PotionEffect( type, (int) (effect.getDuration() * durationIntensity),
/** * Attempts to add the effect represented by this object to the given * {@link LivingEntity}. * * @see LivingEntity#addPotionEffect(PotionEffect) * @param entity The entity to add this effect to * @return Whether the effect could be added */ public boolean apply(LivingEntity entity) { return entity.addPotionEffect(this); }
@Override public void run() { target.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) (Suffocate.this.slowRepeat * 20), (int) Suffocate.this.slow)); } };
@Override public void run() { target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, (int) (Suffocate.this.blindRepeat * 20), (int) Suffocate.this.blind)); } };
@Override public boolean addEffect(MCPotionEffectType type, int strength, int ticks, boolean ambient, boolean particles, boolean icon) { PotionEffect pe = new PotionEffect((PotionEffectType) type.getConcrete(), ticks, strength, ambient, particles, icon); return le.addPotionEffect(pe, true); }
public void apply(LivingEntity target) { PotionEffect effect = new PotionEffect(PotionEffectType.WITHER, duration.getValue() * 20, 1, false); target.addPotionEffect(effect); }
public void apply(LivingEntity target) { PotionEffect effect = new PotionEffect(PotionEffectType.POISON, duration.getValue() * 20, 1, false); target.addPotionEffect(effect); }
public void apply(LivingEntity target) { PotionEffect effect = new PotionEffect(PotionEffectType.SLOW, duration.getValue() * 20, 1, false); target.addPotionEffect(effect); }
private void setNewPotionEffect(LivingEntity livingEntity, PotionEffectType pet, PotionEffect pe){ if(livingEntity.hasPotionEffect(pet)){ PotionEffect activepe = PotionEffects.getOrNull(livingEntity, pet); int remainingDuration = activepe.getDuration(); //If new effect it type II while old wasn't, or // new would last longer than remaining time but isn't a level downgrade (eg II -> I), set it int newAmplifier = pe.getAmplifier(); int activeAmplifier = activepe.getAmplifier(); if(newAmplifier > activeAmplifier || (newAmplifier == activeAmplifier && remainingDuration < pe.getDuration())) livingEntity.addPotionEffect(pe, true); } else livingEntity.addPotionEffect(pe, false); }
@Override public PowerResult<Double> hit(Player player, ItemStack stack, LivingEntity entity, double damage, EntityDamageByEntityEvent event) { if (!checkCooldown(this, player, cooldown, true, true)) return PowerResult.cd(); if (random.nextInt(chance) == 0) { if (!getItem().consumeDurability(stack, cost)) return PowerResult.cost(); stucked.put(entity.getUniqueId(), System.currentTimeMillis()); entity.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, duration, 10), true); entity.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, duration, 128), true); return PowerResult.ok(damage); } return PowerResult.noop(); }
public void addEffectToEntity(Field field, LivingEntity entity, List<String> types) { if (field.envelops(entity.getLocation())) { if (isMatchingLivingEntity(entity, types)) { HashMap<PotionEffectType, Integer> potions = field.getSettings().getPotions(); for (Entry<PotionEffectType, Integer> potion : potions.entrySet()) { int intensity = potion.getValue(); PotionEffectType pot = potion.getKey(); if (!entity.hasPotionEffect(pot)) { entity.addPotionEffect(new PotionEffect(pot, 72000, intensity)); } } } } }
private void applyHealing(final LivingEntity livingEntity) { if (livingEntity.getHealth() < livingEntity.getMaxHealth()) { livingEntity.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, this.potDuration, this.power)); AirAbility.breakBreathbendingHold(livingEntity); this.healing = true; this.healingSelf = false; } }
@Override public PowerResult<Void> fire(Player player, ItemStack stack, LivingEntity entity, Double value) { if (rand.nextInt(chance) != 0) { return PowerResult.noop(); } if (!getItem().consumeDurability(stack, cost)) return PowerResult.cost(); entity.addPotionEffect(new PotionEffect(type, duration, amplifier)); return PowerResult.ok(); } }
@Override public boolean onHit(EntityDamageByEntityEvent e, LivingEntity n) { if (SlimefunManager.isItemSimiliar(Variables.arrows.get(e.getDamager().getUniqueId()), SlimefunItems.ICY_BOW, true)) { n.getWorld().playEffect(n.getLocation(), Effect.STEP_SOUND, Material.ICE); n.getWorld().playEffect(n.getEyeLocation(), Effect.STEP_SOUND, Material.ICE); n.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20 * 2, 10)); n.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 20 * 2, -10)); return true; } else return false; } });
@Override public PowerResult<Void> rightClick(Player player, ItemStack stack, PlayerInteractEvent event) { if (!checkCooldown(this, player, cooldown, true, true)) return PowerResult.cd(); if (!getItem().consumeDurability(stack, costAoe)) return PowerResult.cost(); List<LivingEntity> entities = getLivingEntitiesInCone(getNearestLivingEntities(this, player.getEyeLocation(), player, range, 0), player.getLocation().toVector(), facing, player.getLocation().getDirection()); entities.forEach(entity -> { if (!getItem().consumeDurability(stack, costPerEntity)) return; stucked.put(entity.getUniqueId(), System.currentTimeMillis()); entity.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, duration, 10), true); entity.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, duration, 128), true); } ); return PowerResult.ok(); }
public static void applyPotionEffect(LivingEntity entity, PotionEffect effect) { // Avoid nerfing existing effects boolean applyEffect = true; Collection<PotionEffect> currentEffects = entity.getActivePotionEffects(); for (PotionEffect currentEffect : currentEffects) { if (currentEffect.getType().equals(effect.getType())) { if (effect.getAmplifier() < 0) { applyEffect = false; break; } else if (currentEffect.getAmplifier() > effect.getAmplifier() || effect.getDuration() > Integer.MAX_VALUE / 4) { applyEffect = false; break; } } } if (applyEffect) { entity.addPotionEffect(effect, true); } }
@Override public PowerResult<Void> fire(Player player, ItemStack stack) { if (!checkCooldown(this, player, cooldown, true, true)) return PowerResult.cd(); if (!getItem().consumeDurability(stack, cost)) return PowerResult.cost(); PotionEffect effect = new PotionEffect(type, duration, amplifier - 1); if (selfapplication) { player.addPotionEffect(effect); } player.getWorld().playEffect(player.getLocation(), Effect.POTION_BREAK, type.getColor().asRGB()); for (Entity ent : getNearbyEntities(this, player.getLocation(), player, range)) { if (ent instanceof LivingEntity && !player.equals(ent)) { ((LivingEntity) ent).addPotionEffect(effect); } } return PowerResult.ok(); }
/** * Handle PotionSplash events in order to fix broken Splash Potion of * Saturation. * * @param event * The event to process */ @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPotionSplash(PotionSplashEvent event) { /* WORLD BLACKLIST CHECK */ if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) return; for (PotionEffect effect : ((PotionMeta) event.getPotion().getItem().getItemMeta()).getCustomEffects()) { if (!effect.getType().equals(PotionEffectType.SATURATION)) { return; } for (LivingEntity entity : event.getAffectedEntities()) { int duration = (int) (effect.getDuration() * event.getIntensity(entity)); entity.addPotionEffect(new PotionEffect(effect.getType(), duration, effect.getAmplifier(), effect.isAmbient())); } } }