Java Code Examples for org.bukkit.entity.Arrow#setFireTicks()

The following examples show how to use org.bukkit.entity.Arrow#setFireTicks() . 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: ProjectileArrowComponent.java    From civcraft with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void fire(Location turretLoc, Entity targetEntity) {
	if (!buildable.isValid()) {
		return;
	}
	
	Location playerLoc = targetEntity.getLocation();
	playerLoc.setY(playerLoc.getY()+1); //Target the head instead of feet.
				
	turretLoc = adjustTurretLocation(turretLoc, playerLoc);
	Vector dir = getVectorBetween(playerLoc, turretLoc).normalize();
	Arrow arrow = buildable.getCorner().getLocation().getWorld().spawnArrow(turretLoc, dir, (float)power, 0.0f);
	arrow.setVelocity(dir.multiply(power));
	
	if (buildable.getTown().getBuffManager().hasBuff(Buff.FIRE_BOMB)) {
		arrow.setFireTicks(1000);
	}
	
	CivCache.arrowsFired.put(arrow.getUniqueId(), new ArrowFiredCache(this, targetEntity, arrow));
}
 
Example 2
Source File: EntityListener.java    From Guilds with MIT License 5 votes vote down vote up
/**
 * Handles flame arrows
 *
 * @param event
 */
@EventHandler
public void onFlameArrow(EntityCombustByEntityEvent event) {

    if (!(event.getEntity() instanceof Player))
        return;

    if (!(event.getCombuster() instanceof Arrow))
        return;

    Arrow arrow = (Arrow) event.getCombuster();

    if (!(arrow.getShooter() instanceof Player))
        return;

    Player damagee = (Player) event.getEntity();
    Player damager = (Player) arrow.getShooter();

    if (settingsManager.getProperty(GuildSettings.RESPECT_WG_PVP_FLAG)) {
        event.setCancelled(ClaimUtils.checkPvpDisabled(damagee));
        return;
    }

    if (guildHandler.isSameGuild(damagee, damager)) {
        arrow.setFireTicks(0);
        event.setCancelled(!settingsManager.getProperty(GuildSettings.GUILD_DAMAGE));
        return;
    }

    if (guildHandler.isAlly(damagee, damager)) {
        arrow.setFireTicks(0);
        event.setCancelled(!settingsManager.getProperty(GuildSettings.ALLY_DAMAGE));
    }
}
 
Example 3
Source File: Volley.java    From ce with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void volley(EntityShootBowEvent e, ItemStack item, int lvl) {
    Player p = (Player) e.getEntity();
    int amount = 1 + 2 * lvl; // Keep amount of arrows uneven, 2 extra arrows in a volley per level.

    Arrow oldArrow = (Arrow) e.getProjectile();
    int fireTicks = oldArrow.getFireTicks();
    int knockbackStrength = oldArrow.getKnockbackStrength();
    boolean critical = oldArrow.isCritical();
    String metadata = oldArrow.getMetadata("ce.bow.enchantment").get(0).asString();

    double angleBetweenArrows = (CONE_DEGREES / (amount - 1)) * Math.PI / 180;
    double pitch = (p.getLocation().getPitch() + 90) * Math.PI / 180;
    double yaw = (p.getLocation().getYaw() + 90 - CONE_DEGREES / 2) * Math.PI / 180;

    // Starting direction values for the cone, each arrow increments it's direction on these values.
    double sZ = Math.cos(pitch);

    for (int i = 0; i < amount; i++) { // spawn all arrows in a cone of 90 degrees (equally distributed).;
        double nX = Math.sin(pitch) * Math.cos(yaw + angleBetweenArrows * i);
        double nY = Math.sin(pitch) * Math.sin(yaw + angleBetweenArrows * i);
        Vector newDir = new Vector(nX, sZ, nY);

        Arrow arrow = p.launchProjectile(Arrow.class);
        arrow.setShooter(p);
        arrow.setVelocity(newDir.normalize().multiply(oldArrow.getVelocity().length())); // Need to make sure arrow has same speed as original arrow.
        arrow.setFireTicks(fireTicks); // Set the new arrows on fire if the original one was 
        arrow.setKnockbackStrength(knockbackStrength);
        arrow.setCritical(critical);

        if (i == 0) {
            if (p.getGameMode().equals(GameMode.CREATIVE))
                arrow.setMetadata("ce.Volley", new FixedMetadataValue(getPlugin(), null)); //Control metadata to prevent players from duplicating arrows
        } else {
            arrow.setMetadata("ce.Volley", new FixedMetadataValue(getPlugin(), null)); //Control metadata to prevent players from duplicating arrows
        }
        arrow.setMetadata("ce.bow.enchantment", new FixedMetadataValue(getPlugin(), metadata));
    }
    oldArrow.remove(); // Remove original arrow.
}