/** * Gets the potion which caused this event * * @return The thrown potion entity */ public ThrownPotion getPotion() { return (ThrownPotion) getEntity(); }
/** * Gets the raw amount of damage caused by the event * * @return The raw amount of damage caused by the event * @see DamageModifier#BASE */ public double getDamage() { return getDamage(DamageModifier.BASE); }
public LivingEntity getTarget() { return (LivingEntity) super.getTarget(); }
/** * Sets the damage for the specified modifier. * * @param damage the scalar value of the damage's modifier * @see #getFinalDamage() * @throws IllegalArgumentException if type is null * @throws UnsupportedOperationException if the caller does not support * the particular DamageModifier, or to rephrase, when {@link * #isApplicable(DamageModifier)} returns false */ public void setDamage(DamageModifier type, double damage) throws IllegalArgumentException, UnsupportedOperationException { if (!modifiers.containsKey(type)) { throw type == null ? new IllegalArgumentException("Cannot have null DamageModifier") : new UnsupportedOperationException(type + " is not applicable to " + getEntity()); } modifiers.put(type, damage); }
/** * Gets the location at which the creature is spawning. * * @return The location at which the creature is spawning */ public Location getLocation() { return getEntity().getLocation(); }
/** * This method exists for legacy reasons to provide backwards * compatibility. It will not exist at runtime and should not be used * under any circumstances. */ @Deprecated public void _INVALID_setDamage(int damage) { setDamage(damage); }
/** * Gets the type of creature being spawned. * * @return A CreatureType value detailing the type of creature being * spawned * @deprecated In favour of {@link #getEntityType()}. */ @Deprecated public CreatureType getCreatureType() { return CreatureType.fromEntityType(getEntityType()); }
@Override public void damage(double amount, Entity source, DamageCause cause) { super.damage(amount, source, cause); if (DamageCause.LIGHTNING.equals(cause) && !isPowered()) { CreeperPowerEvent event = EventFactory.getInstance() .callEvent(new CreeperPowerEvent( this, (LightningStrike) source, CreeperPowerEvent.PowerCause.LIGHTNING)); if (!event.isCancelled()) { setPowered(true); } } } }
/** * This method exists for legacy reasons to provide backwards * compatibility. It will not exist at runtime and should not be used * under any circumstances. */ @Deprecated public int _INVALID_getAmount() { return NumberConversions.ceil(getAmount()); }
private void explode() { ExplosionPrimeEvent event = EventFactory.getInstance() .callEvent(new ExplosionPrimeEvent(this)); if (!event.isCancelled()) { Location location = getLocation(); world.createExplosion(this, location.getX(), location.getY() + 0.06125, location.getZ(), event.getRadius(), event.getFire(), true); } remove(); }
@Override public boolean blockInteract(GlowPlayer player, GlowBlock block, BlockFace face, Vector clickedLoc) { EntityChangeBlockEvent changeBlockEvent = new EntityChangeBlockEvent(player, block, Material.GLOWING_REDSTONE_ORE, (byte) 0); EventFactory.getInstance().callEvent(changeBlockEvent); if (!changeBlockEvent.isCancelled()) { GlowBlockState state = block.getState(); state.setType(Material.GLOWING_REDSTONE_ORE); state.update(true); } return false; } }
@Override public void damage(double amount, Entity source, DamageCause cause) { if (!DamageCause.LIGHTNING.equals(cause)) { super.damage(amount, source, cause); return; } PigZombie pigZombie = world.spawn(this.location, PigZombie.class); pigZombie.damage(amount, source, cause); remove(); }
/** * Set the Entity that you want the mob to target. * <p> * It is possible to be null, null will cause the entity to be * target-less. * <p> * Must be a LivingEntity, or null. * * @param target The entity to target */ public void setTarget(Entity target) { if (target == null || target instanceof LivingEntity) { super.setTarget(target); } } }
/** * This method exists for legacy reasons to provide backwards * compatibility. It will not exist at runtime and should not be used * under any circumstances. */ @Deprecated public void _INVALID_setAmount(int amount) { setAmount(amount); }
@Override public void setRemainingAir(int ticks) { ticks = Math.min(ticks, maximumAir); if (ticks == remainingAir) { return; } EntityAirChangeEvent event = EventFactory.getInstance().callEvent( new EntityAirChangeEvent(this, remainingAir) ); if (event.isCancelled()) { return; } remainingAir = event.getAmount(); }
/** * Fires an {@link EntityTameEvent}, and checks whether it was cancelled. * * @param owner the {@link AnimalTamer} performing the action. * @return false if the event was cancelled, true otherwise. */ protected boolean fireEntityTameEvent(AnimalTamer owner) { return !EventFactory.getInstance().callEvent( new EntityTameEvent(this, owner) ).isCancelled(); } }
@Override public void setGliding(boolean gliding) { if (EventFactory.getInstance().callEvent( new EntityToggleGlideEvent(this, gliding)).isCancelled()) { return; } metadata.setBit(MetadataIndex.STATUS, MetadataIndex.StatusFlags.GLIDING, gliding); }
/** * Gets the amount of damage caused by the event after all damage * reduction is applied. * * @return the amount of damage caused by the event */ public final double getFinalDamage() { double damage = 0; for (DamageModifier modifier : MODIFIERS) { damage += getDamage(modifier); } return damage; }
@Override public void damage(double amount, Entity source, DamageCause cause) { if (!DamageCause.LIGHTNING.equals(cause)) { super.damage(amount, source, cause); return; } Witch witch = world.spawn(this.location, Witch.class); witch.damage(amount, source, cause); witch.setFireTicks(this.getFireTicks()); remove(); }
/** * This method exists for legacy reasons to provide backwards * compatibility. It will not exist at runtime and should not be used * under any circumstances. */ @Deprecated public int _INVALID_getDamage() { return NumberConversions.ceil(getDamage()); }