@Override public void onEntityStep(GlowBlock block, LivingEntity entity) { entity.damage(1.0, EntityDamageEvent.DamageCause.FIRE); } }
/** * Process collide with a living entity. * * @param entity the eneity that the snowball collides with */ @Override public void collide(LivingEntity entity) { ProjectileSource source = getShooter(); // the entity receives fake damage. if (source instanceof Entity) { if (entity instanceof GlowBlaze) { entity.damage(3, (Entity) source, EntityDamageEvent.DamageCause.PROJECTILE); } else { entity.damage(0, (Entity) source, EntityDamageEvent.DamageCause.PROJECTILE); } } else { entity.damage(0, EntityDamageEvent.DamageCause.PROJECTILE); } collide(location.getBlock()); }
/** * Process teleportation when collide with an entity. * * @param entity the eneity that the ender pearl collides with */ @Override public void collide(LivingEntity entity) { ProjectileSource source = getShooter(); // the entity receives fake damage. if (source instanceof Entity) { entity.damage(0, (Entity) source, EntityDamageEvent.DamageCause.PROJECTILE); } else { entity.damage(0, EntityDamageEvent.DamageCause.PROJECTILE); } collide(entity.getLocation().getBlock()); }
/** * Process random spawn chicks when collide with a living entity. * * @param entity the eneity that the egg collides with */ @Override public void collide(LivingEntity entity) { ProjectileSource source = getShooter(); // the entity receives fake damage. if (entity instanceof Entity) { entity.damage(0, (Entity) source, EntityDamageEvent.DamageCause.PROJECTILE); } else { entity.damage(0, EntityDamageEvent.DamageCause.PROJECTILE); } collide(entity.getLocation().getBlock()); }
private void explode() { if (!EventFactory.getInstance().callEvent(new FireworkExplodeEvent(this)).isCancelled()) { this.playEffect(EntityEffect.FIREWORK_EXPLODE); int effectsSize = getFireworkMeta().getEffectsSize(); if (effectsSize > 0) { if (boostedEntity != null) { boostedEntity.damage((5 + effectsSize * 2), DamageCause.ENTITY_EXPLOSION); } List<Entity> nearbyEntities = this.getNearbyEntities(2.5, 2.5, 2.5); for (Entity nearbyEntity : nearbyEntities) { if (!(nearbyEntity instanceof LivingEntity)) { continue; } if (this.getLocation().distanceSquared(nearbyEntity.getLocation()) > 25) { continue; } // "The explosion of firework rockets deals 2.5 hearts of damage, per firework // star." ((LivingEntity) nearbyEntity) .damage((effectsSize * 5), DamageCause.ENTITY_EXPLOSION); } } } remove(); }
@Override public void collide(LivingEntity entity) { double damage = spigot.getDamage(); ProjectileSource shooter = getShooter(); if (isCritical()) { damage += 1.0; } entity.damage(damage, shooter instanceof Entity ? (Entity) shooter : null, EntityDamageEvent.DamageCause.PROJECTILE); // Burning arrow ignites target, but doesn't stack if target is already on fire. if (getFireTicks() > 0 && entity.getFireTicks() < TARGET_BURN_TICKS) { entity.setFireTicks(TARGET_BURN_TICKS); } // TODO: knockback entity.setArrowsStuck(entity.getArrowsStuck() + 1); remove(); }
target.damage((3 << baseAmplifier) * instantIntensity, EntityDamageEvent.DamageCause.MAGIC);
((LivingEntity) entity).damage(ENDER_PEARL_DAMAGE, EntityDamageEvent.DamageCause.FALL);
} else if (entity instanceof LivingEntity) { LivingEntity living = (LivingEntity) entity; living.damage(Double.MAX_VALUE, EntityDamageEvent.DamageCause.SUICIDE); new LocalizedStringImpl("kill.done", commandMessages.getResourceBundle()) .send(sender, CommandUtils.getName(entity)); if (entity instanceof LivingEntity) { LivingEntity living = (LivingEntity) entity; living.damage(Double.MAX_VALUE, EntityDamageEvent.DamageCause.VOID); } else { entity.remove();
/** * Damages this Entity, damage caused by another Entity * * @param damage dealt * @param damager that caused the damage */ public void damage(double damage, Entity damager) { entity.damage(damage, damager); }
/** * Damages this Entity, damage caused by an unknown source * * @param damage dealt */ public void damage(double damage) { entity.damage(damage); }
@Override public void damage(double i) { le.damage(i); }
@Deprecated public static void dmg(LivingEntity attacker, LivingEntity victim, double damage) { attacker.damage(damage, victim); } }
public void enqueueMob(LivingEntity mob) { mobThrowerQueue.add(mob); if (mobThrowerQueue.size() > 4) { LivingEntity oldmob = mobThrowerQueue.remove(0); if (oldmob != null) { oldmob.damage(500.0); } } }
List<Entity> nearbyEntities = player.getNearbyEntities(8, 2, 8); // Get entities within 16x4x16 box centered around player for (Entity entity : nearbyEntities) { // For each Entity found if (entity instanceof LivingEntity) { // If the Entity is an instance of a LivingEntity LivingEntity living = (LivingEntity) entity; // Cast if (isLocationInTriangle(living.getLocation(), player.getLocation(), v2, v3)) { // If the LivingEntity is inside the triangle living.damage(6); // Damage the entity (just as an example) } } }
@Override public void damage(double amount, MCEntity source) { le.damage(amount, ((BukkitMCEntity) source).getHandle()); }
/** * Attempt to damage target for value dmg with reason ENTITY_ATTACK with damager attacker * * @param target LivingEntity which to attempt to damage * @param damage Amount of damage to attempt to do * @param attacker Player to pass to event as damager */ @Deprecated public static void dealDamage(LivingEntity target, double damage, DamageCause cause, Entity attacker) { if (target.isDead()) { return; } target.damage(callFakeDamageEvent(attacker, target, cause, damage)); }
/** * Attempt to damage target for value dmg with reason ENTITY_ATTACK with damager attacker * * @param target LivingEntity which to attempt to damage * @param damage Amount of damage to attempt to do * @param attacker Player to pass to event as damager */ public static void dealDamage(LivingEntity target, double damage, Map<DamageModifier, Double> modifiers, LivingEntity attacker) { if (target.isDead()) { return; } // Aren't we applying the damage twice???? target.damage(callFakeDamageEvent(attacker, target, damage, modifiers)); }
public void apply(LivingEntity target) { Player owner = myPet.getOwner().getPlayer(); isStriking = true; Location loc = target.getLocation(); MyPetApi.getPlatformHelper().strikeLightning(loc, 32); for (Entity entity : myPet.getEntity().get().getNearbyEntities(1.5, 1.5, 1.5)) { if (entity instanceof LivingEntity && entity != owner) { ((LivingEntity) entity).damage(damage.getValue().doubleValue(), myPet.getEntity().get()); } } isStriking = false; }
@EventHandler public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { if (event.getDamager() instanceof Egg && event.getEntity() instanceof LivingEntity) { // If damager is an egg and hurt entity is a living entity LivingEntity hurt = (LivingEntity) event.getEntity(); // Cast living entity so we can use damage() method event.setCancelled(true); // Cancel the event, removing any knockback/velocity changes hurt.damage(event.getFinalDamage()); // Re-apply final/original damage } }