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

The following examples show how to use org.bukkit.entity.LivingEntity#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: IgniteEffect.java    From Civs with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void remove() {
    Entity origin = getOrigin();
    if (!(origin instanceof LivingEntity)) {
        return;
    }
    LivingEntity livingEntity = (LivingEntity) origin;
    livingEntity.setFireTicks(0);
}
 
Example 2
Source File: FireBomb.java    From NBTEditor with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void affectEntity(Item item, Location location, LivingEntity entity, Vector delta, double factor) {
	Random random = new Random();
	if (random.nextInt(2) == 0) {
		location.getWorld().spawnEntity(location, EntityType.SMALL_FIREBALL).setVelocity(delta.normalize());
	}
	if (random.nextInt(4) == 0) {
		LivingEntity livingEntity = ((LivingEntity) entity);
		int ticks = (int) (factor * 200);
		if (livingEntity.getFireTicks() < ticks) {
			livingEntity.setFireTicks(ticks);
		}
	}
}
 
Example 3
Source File: IgniteEffect.java    From Civs with GNU General Public License v3.0 4 votes vote down vote up
public void apply() {
    Object target = getTarget();
    Spell spell = getSpell();
    String key = getKey();
    if (!(target instanceof LivingEntity)) {
        return;
    }

    LivingEntity livingEntity = (LivingEntity) target;

    livingEntity.setFireTicks(this.ticks);

    if (!(livingEntity instanceof Player)) {
        //TODO make states for mobs
        return;
    }
    Player player = (Player) livingEntity;
    Civilian champion1 = CivilianManager.getInstance().getCivilian(player.getUniqueId());
    CivState state = champion1.getStates().get(spell.getType() + "." + key);
    if (state != null) {
        state.remove(champion1);
        champion1.getStates().remove(spell.getType() + "." + key);
    }
    HashMap<String, Object> variables = new HashMap<String, Object>();

    final Civilian champion = champion1;
    final String stateName = spell.getType() + "." + key;
    int durationId = Bukkit.getScheduler().scheduleSyncDelayedTask(Civs.getInstance(), new Runnable() {
        @Override
        public void run() {
            champion.getStates().remove(stateName);
        }
    }, this.ticks);

    if (config != null) {
        state = new CivState(spell, key, durationId, -1, config, variables);
    } else {
        state = new CivState(spell, key, durationId, -1, "" + this.ticks, variables);
    }

    champion.getStates().put(spell.getType() + "." + key, state);
}
 
Example 4
Source File: Molten.java    From ce with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void effect(Event e, ItemStack item, int level) {
	EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e;
	LivingEntity target = (LivingEntity) event.getDamager();
		target.setFireTicks(duration * level);
}