Java Code Examples for org.bukkit.entity.Entity#getFireTicks()

The following examples show how to use org.bukkit.entity.Entity#getFireTicks() . 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: Pyroaxe.java    From ce with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean effect(Event event, Player player) {
	
	EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
	Entity entity = e.getEntity();
	

	if(e.getDamager() == player && entity.getFireTicks() > 0) {
		e.setDamage(damageMultiplier * e.getDamage());
		entity.getWorld().playEffect(entity.getLocation(), Effect.ZOMBIE_DESTROY_DOOR, 10);
		EffectManager.playSound(entity.getLocation(), "BLOCK_ANVIL_LAND", 1f, 0.001f);
		return true;
	}
	return false;
}
 
Example 2
Source File: ModifyBowProjectileMatchModule.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void fixEntityDamage(EntityDamageByEntityEvent event) {
  Entity projectile = event.getDamager();
  if (projectile.hasMetadata("customProjectile")) {

    // If the custom projectile replaced an arrow, recreate some effects specific to arrows
    if (projectile.hasMetadata("damage")) {
      boolean critical = projectile.getMetadata("critical").get(0).asBoolean();
      int knockback = projectile.getMetadata("knockback").get(0).asInt();
      double damage = projectile.getMetadata("damage").get(0).asDouble();
      double speed = projectile.getVelocity().length();

      // Reproduce the damage calculation from nms.EntityArrow with the addition of our modifier
      int finalDamage = (int) Math.ceil(speed * damage * this.velocityMod);
      if (critical) {
        finalDamage += match.getRandom().nextInt(finalDamage / 2 + 2);
      }
      event.setDamage(finalDamage);

      // Flame arrows - target burns for 5 seconds always
      if (projectile.getFireTicks() > 0) {
        event.getEntity().setFireTicks(100);
      }

      // Reproduce the knockback calculation for punch bows
      if (knockback > 0) {
        Vector projectileVelocity = projectile.getVelocity();
        double horizontalSpeed =
            Math.sqrt(
                projectileVelocity.getX() * projectileVelocity.getX()
                    + projectileVelocity.getZ() * projectileVelocity.getZ());
        Vector velocity = event.getEntity().getVelocity();
        velocity.setX(
            velocity.getX() + projectileVelocity.getX() * knockback * 0.6 / horizontalSpeed);
        velocity.setY(velocity.getY() + 0.1);
        velocity.setZ(
            velocity.getZ() + projectileVelocity.getZ() * knockback * 0.6 / horizontalSpeed);
        event.getEntity().setVelocity(velocity);
      }

      // If the projectile is not an arrow, play an impact sound.
      if (event.getEntity() instanceof Player
          && (projectile instanceof Projectile && !(projectile instanceof Arrow))) {
        Projectile customProjectile = (Projectile) projectile;
        if (customProjectile.getShooter() instanceof Player) {
          Player bukkitShooter = (Player) customProjectile.getShooter();
          MatchPlayer shooter = match.getPlayer(bukkitShooter);
          if (shooter != null && event.getEntity() != null) {
            shooter.playSound(PROJECTILE_SOUND);
          }
        }
      }
    }

    // Apply any potion effects attached to the projectile
    if (event.getEntity() instanceof LivingEntity) {
      for (PotionEffect potionEffect : this.potionEffects) {
        ((LivingEntity) event.getEntity()).addPotionEffect(potionEffect);
      }
    }
  }
}
 
Example 3
Source File: ModifyBowProjectileMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void fixEntityDamage(EntityDamageByEntityEvent event) {
    Entity projectile = event.getDamager();
    if(projectile.hasMetadata("customProjectile")) {

        // If the custom projectile replaced an arrow, recreate some effects specific to arrows
        if(projectile.hasMetadata("damage")) {
            boolean critical = projectile.getMetadata("critical").get(0).asBoolean();
            int knockback = projectile.getMetadata("knockback").get(0).asInt();
            double damage = projectile.getMetadata("damage").get(0).asDouble();
            double speed = projectile.getVelocity().length();

            // Reproduce the damage calculation from nms.EntityArrow with the addition of our modifier
            int finalDamage = (int) Math.ceil(speed * damage * this.velocityMod);
            if(critical) {
                finalDamage += random.nextInt(finalDamage / 2 + 2);
            }
            event.setDamage(finalDamage);

            // Flame arrows - target burns for 5 seconds always
            if(projectile.getFireTicks() > 0) {
                event.getEntity().setFireTicks(100);
            }

            // Reproduce the knockback calculation for punch bows
            if(knockback > 0) {
                Vector projectileVelocity = projectile.getVelocity();
                double horizontalSpeed = Math.sqrt(projectileVelocity.getX() * projectileVelocity.getX() +
                                                   projectileVelocity.getZ() * projectileVelocity.getZ());
                Vector velocity = event.getEntity().getVelocity();
                velocity.setX(velocity.getX() + projectileVelocity.getX() * knockback * 0.6 / horizontalSpeed);
                velocity.setY(velocity.getY() + 0.1);
                velocity.setZ(velocity.getZ() + projectileVelocity.getZ() * knockback * 0.6 / horizontalSpeed);
                event.getEntity().setVelocity(velocity);
            }
        }

        // Apply any potion effects attached to the projectile
        if(event.getEntity() instanceof LivingEntity) {
            for(PotionEffect potionEffect : this.potionEffects) {
                ((LivingEntity) event.getEntity()).addPotionEffect(potionEffect);
            }
        }
    }
}
 
Example 4
Source File: CondIsBurning.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean check(final Entity e) {
	return e.getFireTicks() > 0;
}