Java Code Examples for cn.nukkit.entity.Entity#addEffect()
The following examples show how to use
cn.nukkit.entity.Entity#addEffect() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EnchantmentDamageArthropods.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public void doPostAttack(Entity attacker, Entity entity) { if (entity instanceof EntityArthropod) { int duration = 20 + ThreadLocalRandom.current().nextInt(10 * this.level); entity.addEffect(Effect.getEffect(Effect.SLOWNESS).setDuration(duration).setAmplifier(3)); } }
Example 2
Source File: Potion.java From Jupiter with GNU General Public License v3.0 | 5 votes |
public void applyPotion(Entity entity, double health) { if (!(entity instanceof EntityLiving)) { return; } Effect applyEffect = getEffect(this.getId(), this.isSplash()); if (applyEffect == null) { return; } if (entity instanceof Player) { if (!((Player) entity).isSurvival() && applyEffect.isBad()) { return; } } PotionApplyEvent event = new PotionApplyEvent(this, entity); entity.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return; } switch (this.getId()) { case INSTANT_HEALTH: case INSTANT_HEALTH_II: entity.heal(new EntityRegainHealthEvent(entity, (float) (health * (double) (4 << (applyEffect.getAmplifier() + 1))), EntityRegainHealthEvent.CAUSE_EATING)); break; case HARMING: case HARMING_II: entity.attack(new EntityDamageEvent(entity, DamageCause.MAGIC, (float) (health * (double) (6 << (applyEffect.getAmplifier() + 1))))); break; default: int duration = (int) ((isSplash() ? health : 1) * (double) applyEffect.getDuration() + 0.5); applyEffect.setDuration(duration); entity.addEffect(applyEffect); } }
Example 3
Source File: EnchantmentDamageArthropods.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public void doPostAttack(Entity attacker, Entity entity) { if (entity instanceof EntityArthropod) { int duration = 20 + ThreadLocalRandom.current().nextInt(10 * this.level); entity.addEffect(Effect.getEffect(Effect.SLOWNESS).setDuration(duration).setAmplifier(3)); } }
Example 4
Source File: EnchantmentDamageArthropods.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public void doPostAttack(Entity attacker, Entity entity) { if (entity instanceof EntityArthropod) { int duration = 20 + ThreadLocalRandom.current().nextInt(10 * this.level); entity.addEffect(Effect.getEffect(Effect.SLOWNESS).setDuration(duration).setAmplifier(3)); } }
Example 5
Source File: Potion.java From Nukkit with GNU General Public License v3.0 | 4 votes |
public void applyPotion(Entity entity, double health) { if (!(entity instanceof EntityLiving)) { return; } Effect applyEffect = getEffect(this.getId(), this.isSplash()); if (applyEffect == null) { return; } if (entity instanceof Player) { if (!((Player) entity).isSurvival() && !((Player) entity).isAdventure() && applyEffect.isBad()) { return; } } PotionApplyEvent event = new PotionApplyEvent(this, applyEffect, entity); entity.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return; } applyEffect = event.getApplyEffect(); switch (this.getId()) { case INSTANT_HEALTH: case INSTANT_HEALTH_II: entity.heal(new EntityRegainHealthEvent(entity, (float) (health * (double) (4 << (applyEffect.getAmplifier() + 1))), EntityRegainHealthEvent.CAUSE_MAGIC)); break; case HARMING: case HARMING_II: entity.attack(new EntityDamageEvent(entity, DamageCause.MAGIC, (float) (health * (double) (6 << (applyEffect.getAmplifier() + 1))))); break; default: int duration = (int) ((isSplash() ? health : 1) * (double) applyEffect.getDuration() + 0.5); applyEffect.setDuration(duration); entity.addEffect(applyEffect); } }
Example 6
Source File: Potion.java From Nukkit with GNU General Public License v3.0 | 4 votes |
public void applyPotion(Entity entity, double health) { if (!(entity instanceof EntityLiving)) { return; } Effect applyEffect = getEffect(this.getId(), this.isSplash()); if (applyEffect == null) { return; } if (entity instanceof Player) { if (!((Player) entity).isSurvival() && applyEffect.isBad()) { return; } } PotionApplyEvent event = new PotionApplyEvent(this, applyEffect, entity); entity.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return; } applyEffect = event.getApplyEffect(); switch (this.getId()) { case INSTANT_HEALTH: case INSTANT_HEALTH_II: entity.heal(new EntityRegainHealthEvent(entity, (float) (health * (double) (4 << (applyEffect.getAmplifier() + 1))), EntityRegainHealthEvent.CAUSE_EATING)); break; case HARMING: case HARMING_II: entity.attack(new EntityDamageEvent(entity, DamageCause.MAGIC, (float) (health * (double) (6 << (applyEffect.getAmplifier() + 1))))); break; default: int duration = (int) ((isSplash() ? health : 1) * (double) applyEffect.getDuration() + 0.5); applyEffect.setDuration(duration); entity.addEffect(applyEffect); } }