@EventHandler(priority = EventPriority.NORMAL) public void onPlayerDamage(EntityDamageByEntityEvent evt) { if (evt.getDamager() instanceof Player) { Player p = (Player) evt.getDamager(); if (p.hasPotionEffect(PotionEffectType.INCREASE_DAMAGE)) { for (PotionEffect eff : p.getActivePotionEffects()) { if (eff.getType().equals(PotionEffectType.INCREASE_DAMAGE)) { double div = (eff.getAmplifier() + 1) * 1.3D + 1.0D; int dmg; if (evt.getDamage() / div <= 1.0D) { dmg = (eff.getAmplifier() + 1) * 3 + 1; } else { double flatdmg = 2.0; dmg = (int) (evt.getDamage() / div) + (int) ((eff.getAmplifier() + 1) * flatdmg); } evt.setDamage(dmg); break; } } } } }
public static void applySerratedStrikes( Player attacker, EntityDamageByEntityEvent event, mcMMO pluginx) { int targets = 0; if (event.getEntity() instanceof LivingEntity) { LivingEntity x = (LivingEntity) event.getEntity(); targets = Utils.getTier(attacker); for (Entity derp : x.getWorld().getEntities()) { if (Utils.getDistance(x.getLocation(), derp.getLocation()) < 5) { // Make sure the Wolf is not friendly if (derp instanceof Wolf) { Wolf hurrDurr = (Wolf) derp; if (Taming.getOwner(hurrDurr, pluginx) == attacker) continue; // if(Party.getInstance().inSameParty(attacker, Taming.getOwner(hurrDurr, // pluginx))) // continue; } // Damage nearby LivingEntities if (derp instanceof LivingEntity && targets >= 1) { if (derp instanceof Player) { Player target = (Player) derp; if (target.getName().equals(attacker.getName())) continue; if (Users.getProfile(target).getGodMode()) continue; // if(Party.getInstance().inSameParty(attacker, target)) // continue; if (targets >= 1 && derp.getWorld().getPVP()) { target.damage(event.getDamage() / 4); target.sendMessage(ChatColor.DARK_RED + "Struck by Serrated Strikes!"); if (Combat.dealDamage(attacker, target, 0)) target.increaseBleedTicks(5); target.setLastCustomDamageCause( new EntityDamageByEntityEvent(attacker, target, DamageCause.ENTITY_ATTACK, 0)); targets--; continue; } } else { LivingEntity target = (LivingEntity) derp; target.increaseBleedTicks(5); target.damage(event.getDamage() / 4); target.setLastCustomDamageCause( new EntityDamageByEntityEvent(attacker, target, DamageCause.ENTITY_ATTACK, 0)); targets--; } } } } } }
/** * Entity damaged by another entity event. Cancels the event and sends damager a message if either * damager or attacked player have not enabled PvP * * @param event event being handled */ @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent event) { if (event.getEntity() instanceof Player) { final Player attackedPlayer = (Player) event.getEntity(); final Player attacker; if (event.getDamager() instanceof Player) { attacker = (Player) event.getDamager(); } else if (event.getDamager() instanceof Projectile) { if (((Projectile) event.getDamager()).getShooter() instanceof Player) { attacker = (Player) ((Projectile) event.getDamager()).getShooter(); } else { return; } } else { return; } final World world = attacker.getWorld(); final Localisation localisation = plugin.getLocalisation(); if (PVPConfigUtils.getPlayerStatus(attacker, world, plugin)) { if (PVPConfigUtils.getPlayerStatus(attackedPlayer, world, plugin)) { LastPVPActionTimeConfigUtils.update(attacker, world, plugin); if (DebugConfigUtils.getDebugEnabled(plugin)) { attacker.sendMessage( localisation.get( LocalisationEntry.DEBUG_ATTACKED_PLAYER, new Object[] {attackedPlayer.getDisplayName(), event.getDamage()})); attackedPlayer.sendMessage( localisation.get( LocalisationEntry.DEBUG_ATTACKED_BY_PLAYER, new Object[] {attacker.getDisplayName(), event.getDamage()})); } } else { event.setCancelled(true); attacker.sendMessage( localisation.get( LocalisationEntry.MSG_ATTACK_CANCELLED_PLAYER_DOES_NOT_HAVE_PVP_ENABLED, new Object[] {attackedPlayer.getDisplayName()})); } } else { event.setCancelled(true); attacker.sendMessage( localisation.get(LocalisationEntry.MSG_ATTACK_CANCELLED_PVP_NOT_ENABLED)); } // Stop arrows bouncing back, possibly hitting you. if ((event.isCancelled()) && (event.getDamager() instanceof Projectile)) { ((Projectile) event.getDamager()).setBounce(false); } } }
public static void global_no_mana_damaged( Player pl, final Plugin plugin, final EntityDamageByEntityEvent event) { event.setDamage(event.getDamage() * 2D); if (pl.isSneaking()) { pl.sendMessage(THRPlugin.thrpre + ChatColor.RED + pl.getName() + "貴方は霊力再生モードの為非常に柔いです!"); } }
@EventHandler(priority = EventPriority.HIGH) public void onEDamageByE(EntityDamageByEntityEvent event) { // if (event.getEntity() instanceof Player) { /* Player Damagee = (Player) event.getEntity(); String damager = event.getDamager().toString(); Damagee. Bukkit.broadcastMessage("entity "+ Damagee); Bukkit.broadcastMessage("damager "+ damager);*/ if (event.getDamager() instanceof Player) { Player p = (Player) event.getDamager(); // int dmg = event.getDamage(); double cRate = plugin.critRate.get(p.getName().toLowerCase()); double random = ((double) Math.random() * 100); if (cRate > 0) { if (random <= cRate) { int oldmg = event.getDamage(); int newdmg = oldmg * 2; event.setDamage(newdmg); p.sendMessage(ChatColor.AQUA + "Critical!"); Location loc = p.getLocation(); p.playEffect(loc, Effect.BLAZE_SHOOT, 0); } } } /* Player p = (Player) event.getDamager(); String player = p.getName(); Bukkit.broadcastMessage("name "+ player);*/ // } }
private boolean causePain(Player player, LivingEntity target, float power) { if (target.isDead()) return false; double dam = damage * power; if (target instanceof Player && checkPlugins && player != null) { // handle the event myself so I can detect cancellation properly EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(player, target, damageType, dam); Bukkit.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return false; } dam = event.getDamage(); target.setLastDamageCause(event); } if (ignoreArmor) { double health = target.getHealth(); if (health > target.getMaxHealth()) health = target.getMaxHealth(); health = health - dam; if (health < 0) health = 0; if (health > target.getMaxHealth()) health = target.getMaxHealth(); if (health == 0 && player != null) { MagicSpells.getVolatileCodeHandler().setKiller(target, player); } target.setHealth(health); target.playEffect(EntityEffect.HURT); } else { target.damage(dam, player); } if (player != null) { playSpellEffects(player, target); } else { playSpellEffects(EffectPosition.TARGET, target); } return true; }
@EventHandler public void onDamageByEntity(EntityDamageByEntityEvent event) { if (dmgBuff.containsKey(event.getDamager())) { DmgBoost boost = dmgBuff.get(event.getDamager()); if (boost.expires < HungergamesApi.getHungergames().currentTime) dmgBuff.remove(event.getDamager()); else event.setDamage(event.getDamage() + boost.extraDamage); } }
/** * Check EntityDamageByEntityEvent events. * * @param event The event to check */ @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onEntityDeath(EntityDamageByEntityEvent event) { if (event.getDamage() == 0 || event.getEntity().isDead()) { return; } if (event.getEntity() instanceof LivingEntity) { combatChecks(event); } }
public static void unarmedBonus(Player attacker, EntityDamageByEntityEvent event) { int bonus = 3; // Add 1 DMG for every 50 skill levels bonus += Users.getProfile(attacker).getSkillLevel(SkillType.UNARMED) / 50; if (bonus > 8) bonus = 8; event.setDamage(event.getDamage() + bonus); }
@EventHandler public void onArrowDamage(EntityDamageByEntityEvent e) { if (!Api.allowsPVP(e.getEntity())) return; if (!Api.allowsPVP(e.getDamager())) return; if (e.getDamager() instanceof Arrow) { if (e.getEntity() instanceof LivingEntity) { LivingEntity en = (LivingEntity) e.getEntity(); Projectile arrow = (Projectile) e.getDamager(); if (Arrow.containsKey(arrow)) { if (Api.isFriendly(P.get(e.getDamager()), e.getEntity())) { if (Enchant.get(arrow).equalsIgnoreCase("Doctor")) { if (Api.isEnchantmentEnabled("Doctor")) { int heal = 2 + Api.getPower(Arrow.get(arrow) + "", Api.getEnchName("Doctor")); if (en.getHealth() + heal < en.getMaxHealth()) { en.setHealth(en.getHealth() + heal); } if (en.getHealth() + heal >= en.getMaxHealth()) { en.setHealth(en.getMaxHealth()); } } } } if (!Api.isFriendly(P.get(arrow), e.getEntity())) { if (Enchant.get(arrow).equalsIgnoreCase("IceFreeze")) { if (Api.isEnchantmentEnabled("IceFreeze")) { if (Api.randomPicker(5)) { en.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 5 * 20, 1)); } } } if (Enchant.get(arrow).equalsIgnoreCase("Piercing")) { if (Api.isEnchantmentEnabled("Piercing")) { if (Api.randomPicker( 20 - Api.getPower(Arrow.get(arrow) + "", Api.getEnchName("Piercing")))) { e.setDamage(e.getDamage() * 2); } } } if (Enchant.get(arrow).equalsIgnoreCase("Venom")) { if (Api.isEnchantmentEnabled("Venom")) { if (Api.randomPicker(10)) { en.addPotionEffect( new PotionEffect( PotionEffectType.POISON, 2 * 20, Api.getPower(Arrow.get(arrow) + "", Api.getEnchName("Venom")) - 1)); } } } } } } } return; }
@EventHandler public void fenceDefense(EntityDamageByEntityEvent event) { if (event.getEntity() instanceof Player) { Player player = (Player) event.getEntity(); if (isIn(player, 1)) { if (player.getItemInHand().getType() == Material.FENCE) { if (event.getCause() == DamageCause.ENTITY_ATTACK || checkProjectile(event.getDamager(), event.getCause())) { event.setDamage(event.getDamage() - (event.getDamage() / 3)); } } } } }
/** * Apply bonus to Unarmed damage. * * @param PPa Profile of the attacking player * @param event The event to modify */ public static void unarmedBonus(PlayerProfile PPa, EntityDamageByEntityEvent event) { final int MAX_BONUS = 8; int bonus = 3; bonus += PPa.getSkillLevel(SkillType.UNARMED) / 50; // Add 1 DMG for every 50 skill levels if (bonus > MAX_BONUS) { bonus = MAX_BONUS; } event.setDamage(event.getDamage() + bonus); }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onDamage(EntityDamageByEntityEvent e) { double damage = e.getDamage(); if (e.getDamager() instanceof Player) { damage = playerDamager(e, damage); } else if (e.getDamager() instanceof Projectile) { damage = projectileDamager(e, damage); } if (e.getEntity() instanceof Player) { damage = playerHit(e, damage); } e.setDamage(damage); }
@EventHandler public void onHit(EntityDamageByEntityEvent e) { if (((e.getEntity() instanceof Player)) && ((e.getDamager() instanceof Player))) { Player entity = (Player) e.getEntity(); Entity damager = (Player) e.getDamager(); if (getRemaining(entity) > 0L) { Double damage = Double.valueOf(e.getDamage() * 0.3D); e.setDamage(e.getDamage() + damage.doubleValue()); } } if (((e.getEntity() instanceof Player)) && ((e.getDamager() instanceof Arrow))) { Player entity = (Player) e.getEntity(); Entity damager = (Player) ((Arrow) e.getDamager()).getShooter(); if (((damager instanceof Player)) && (getRemaining(entity) > 0L)) { if (((UUID) ArcherClass.tagged.get(entity.getUniqueId())).equals(damager.getUniqueId())) { setCooldown(entity, entity.getUniqueId()); } Double damage = Double.valueOf(e.getDamage() * 0.3D); e.setDamage(e.getDamage() + damage.doubleValue()); } } }
@SuppressWarnings("deprecation") public static void damage(LivingEntity damager, LivingEntity damagee, double damage) { if (damager instanceof Player) { Player p = (Player) damager; if (!(p.isOnline())) return; } EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, DamageCause.ENTITY_ATTACK, damage); Bukkit.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) return; if (event.getDamage() != damage) damage = event.getDamage(); if (damage <= 1) { damagee.damage(1, damager); } else if (damage >= damagee.getHealth()) { damagee.setHealth(1); damagee.damage(200, damager); } else { double damageChanged = damage - 1; damagee.damage(damageChanged); damagee.damage(3, damager); } }
@EventHandler public void onEntityDamagebyEntity(EntityDamageByEntityEvent event) { if (event.getEntity() instanceof Zombie) { if (event.getDamager() instanceof Player) { event.setDamage(event.getDamage() * getDamage(((Player) event.getDamager())) / 2); } } if (event.getEntity() instanceof Giant) { if ((event.getCause().equals(DamageCause.FIRE_TICK) || event.getCause().equals(DamageCause.FIRE) || event.getCause().equals(DamageCause.LIGHTNING))) { event.setCancelled(true); event.getEntity().setFireTicks(0); } event.setDamage(event.getDamage() / 4); } if (event.getEntity() instanceof Player) { if (event.getDamager() instanceof Zombie) { event.setDamage(event.getDamage() * getDamage(((Player) event.getEntity()))); } } }
@EventHandler public void onDamage(EntityDamageByEntityEvent event) { if (event.getEntity() instanceof Player == false || GameManager.INSTANCE.getSession((Player) event.getEntity()) == null) return; if (event.getDamager() instanceof Zombie) { event.setDamage( (int) (Configs.Config.ZOMBIE_DAMAGE_MULTIPLIER.getGlobalDouble() * event.getDamage())); } else if (event.getDamager() instanceof Player) { Player p = (Player) event.getDamager(); if (p.getItemInHand().getType().equals(Material.PAPER)) { event.setCancelled(true); bandage.put(p.getName(), ((Player) event.getEntity()).getName()); GeneralUtils.subtractItemInHand(p); } } }
private double projectileDamager(EntityDamageByEntityEvent e, double damage) { Projectile entity = (Projectile) e.getDamager(); if (rpgProjectiles.contains(entity.getEntityId())) { RPGItem rItem = ItemManager.getItemById(rpgProjectiles.get(entity.getEntityId())); if (rItem == null) return damage; damage = rItem.getDamageMin() != rItem.getDamageMax() ? (rItem.getDamageMin() + random.nextInt(rItem.getDamageMax() - rItem.getDamageMin())) : rItem.getDamageMin(); if (e.getEntity() instanceof LivingEntity) { LivingEntity le = (LivingEntity) e.getEntity(); rItem.hit((Player) entity.getShooter(), le, e.getDamage()); } } return damage; }
@Override public boolean onDamageOther(final EntityDamageByEntityEvent e, Player p, int level) { if (e.getEntity().getLocation().getDirection().dot(e.getDamager().getLocation().getDirection()) > 0.0D) { e.setDamage(e.getDamage() * level); p.sendMessage("Backstab!"); if (e.getEntity() instanceof Player) { ((Player) e.getEntity()).sendMessage("You were backstabbed!"); } return true; } return false; }
// Game ending & freezing/unfreezing logic @EventHandler(priority = EventPriority.HIGHEST) public void checkDeath(EntityDamageByEntityEvent e) { Entity entity = e.getEntity(); Player p; if (entity instanceof Player) { p = (Player) entity; } else { return; } if (!((p.getHealth() - e.getDamage()) <= 0)) { // This is not wrong. // http://forums.bukkit.org/threads/oops-i-didnt-break-your-plugins-ambiguous-gethealth.156975/ return; // If he is not going to die. } if (plugin.wsplayersHM.containsValue(p)) { // p.sendMessage("testdead"); if (isRedTeam(p)) { // if player isn't frozen, freeze him. If he is, unfreeze him. if (!isFrozenRed(p)) { // p.sendMessage("testdead"); plugin.frozenred.add(p.getName()); } else { plugin.frozenred.remove(p); } if (plugin.frozengreen.size() == plugin.wsgreen.values().size()) { // end the game... Bukkit.broadcastMessage(ChatColor.GREEN + "The RED team has won the game!"); return; } } else if (isGreenTeam(p)) { if (!isFrozenGreen(p)) { plugin.frozengreen.add(p.getName()); } if (plugin.frozenred.size() == plugin.wsred.values().size()) { // end the game... Bukkit.broadcastMessage(ChatColor.GREEN + "The GREEN team has won the game!"); return; } } else { return; } } }
@EventHandler public void EntityDamagebyPlayer(EntityDamageByEntityEvent event) { if (event.getDamager() instanceof Player) { Player player = (Player) event.getDamager(); UUID id = player.getUniqueId(); double damagestart = event.getDamage(); if (!(hasSkill(id))) { return; } ItemStack item = player.getItemInHand(); for (Material m : weapons) { if (item.getType().equals(m)) { Double dmg = UserManager.getUser(id).getUserSkillClass().getLevel(this) * damage; event.setDamage(DamageModifier.BASE, damagestart + dmg); } } } }
@SuppressWarnings("deprecation") private double playerDamager(EntityDamageByEntityEvent e, double damage) { Player player = (Player) e.getDamager(); ItemStack item = player.getItemInHand(); if (item.getType() == Material.BOW || item.getType() == Material.SNOW_BALL || item.getType() == Material.EGG || item.getType() == Material.POTION) return damage; RPGItem rItem = ItemManager.toRPGItem(item); if (rItem == null) return damage; if (!WorldGuard.canPvP(player.getLocation()) && !rItem.ignoreWorldGuard) return damage; if (rItem.getHasPermission() == true && player.hasPermission(rItem.getPermission()) == false) { damage = 0; e.setCancelled(true); player.sendMessage( ChatColor.RED + String.format( Locale.get("message.error.permission", Locale.getPlayerLocale(player)))); } damage = rItem.getDamageMin() != rItem.getDamageMax() ? (rItem.getDamageMin() + random.nextInt(rItem.getDamageMax() - rItem.getDamageMin())) : rItem.getDamageMin(); if (e.getEntity() instanceof LivingEntity) { LivingEntity le = (LivingEntity) e.getEntity(); rItem.hit(player, le, e.getDamage()); } RPGMetadata meta = RPGItem.getMetadata(item); if (rItem.getMaxDurability() != -1) { int durability = meta.containsKey(RPGMetadata.DURABILITY) ? ((Number) meta.get(RPGMetadata.DURABILITY)).intValue() : rItem.getMaxDurability(); durability--; if (durability <= 0) { player.setItemInHand(null); } meta.put(RPGMetadata.DURABILITY, Integer.valueOf(durability)); } RPGItem.updateItem(item, Locale.getPlayerLocale(player), meta); player.updateInventory(); return damage; }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onEntityDamage(EntityDamageByEntityEvent event) { if (this.lastDamageEvent.get() == event) { // We're already in the midst of the original event. return; } Entity damagee = getVehicleEntity(event.getEntity()); if (damagee != null) { event.setCancelled(true); this.lastDamageEvent = new WeakReference<>( new EntityDamageByEntityEvent( event.getDamager(), damagee, event.getCause(), event.getDamage())); this.npcManager .getOwner() .getServer() .getPluginManager() .callEvent(this.lastDamageEvent.get()); } }
public void a(EntityWeatherStorm entityweatherstorm) { // CraftBukkit start int damage = 5; EntityDamageByEntityEvent event = new EntityDamageByEntityEvent( entityweatherstorm.getBukkitEntity(), getBukkitEntity(), DamageCause.LIGHTNING, damage); Bukkit.getServer().getPluginManager().callEvent(event); damage = event.getDamage(); if (event.isCancelled()) { return; } this.a(damage); // CraftBukkit end ++this.fireTicks; if (this.fireTicks == 0) { this.fireTicks = 300; } }
/** * Cancels left clicks on disabled items * * @param event event details */ @EventHandler(priority = EventPriority.LOWEST) public void onAttack(EntityDamageByEntityEvent event) { if (event.getDamager() instanceof Player) { Player player = (Player) event.getDamager(); if (InventoryTask.cannotUse(SkillAPI.getPlayerData(player), player.getItemInHand())) { SkillAPI.getLanguage().sendMessage(ErrorNodes.CANNOT_USE, player, FilterType.COLOR); event.setCancelled(true); } } if (event.getEntity() instanceof Player && VersionManager.isVersionAtLeast(VersionManager.V1_9_0)) { Player player = (Player) event.getEntity(); if (event.getDamage(EntityDamageEvent.DamageModifier.BLOCKING) < 0 && InventoryTask.cannotUse( SkillAPI.getPlayerData(player), player.getInventory().getItemInMainHand())) { SkillAPI.getLanguage() .sendMessage(ErrorNodes.CANNOT_USE, event.getEntity(), FilterType.COLOR); event.setDamage(EntityDamageEvent.DamageModifier.BLOCKING, 0); } } }
// Create damage logs @EventHandler(priority = EventPriority.MONITOR) public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { if (!(event.getEntity() instanceof Player)) return; Player player = (Player) event.getEntity(); Player damager = null; if (event.getDamager() instanceof Player) { damager = (Player) event.getDamager(); } else if (event.getDamager() instanceof Wolf) { Wolf wolf = (Wolf) event.getDamager(); if (wolf.getOwner() instanceof Player) damager = (Player) wolf.getOwner(); } else if (event.getDamager() instanceof Arrow) { Arrow arrow = (Arrow) event.getDamager(); if (!(arrow.getShooter() instanceof Player)) return; damager = (Player) arrow.getShooter(); } if (damager == null || damager == player) return; recordDamage(player, damager, event.getDamage()); }
public static void counterAttackChecks(EntityDamageByEntityEvent event) { // Don't want to counter attack arrows if (event.getDamager() instanceof Projectile) return; if (event instanceof EntityDamageByEntityEvent) { Entity damager = ((EntityDamageByEntityEvent) event).getDamager(); if (event.getEntity() instanceof Player) { Player damaged = (Player) event.getEntity(); PlayerProfile PPd = Users.getProfile(damaged); if (Utils.isSword(damaged.getItemInHand()) && mcPermissions.skillPermission(SkillType.SWORDS, damaged)) { if (Math.random() * 2000 <= Math.min(PPd.getSkillLevel(SkillType.SWORDS), 600)) { Combat.dealDamage(damaged, damager, event.getDamage() / 2); damaged.sendMessage(ChatColor.GREEN + "**COUNTER-ATTACKED**"); if (damager instanceof Player) { ((Player) damager).sendMessage(ChatColor.DARK_RED + "Hit with counterattack!"); } } } } } }
public boolean bleed() { if (target == null || damager == null || target.isDead()) return false; if (damager instanceof Player && !Bukkit.getOfflinePlayer(damager.getUniqueId()).isOnline()) { return false; } EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, target, EntityDamageEvent.DamageCause.CUSTOM, 1); Bukkit.getPluginManager().callEvent(e); if (WGUtil.canGetDamage(target) && !e.isCancelled()) { target.damage(e.getDamage()); target.setLastDamageCause(e); if (target instanceof Player) { target.sendMessage(ChatColor.DARK_RED + "You are bleeding.."); } } EffectUtil.playParticle(target, Effect.CRIT); duration--; return duration > 0; }
@Override public void onDefense(EntityDamageByEntityEvent event) { double damage = event.getDamage(); damage -= this.defense; if (damage < 0.5) { damage = 0.0; Player player = null; if (event.getDamager() instanceof Arrow) { Arrow arrow = (Arrow) event.getDamager(); if (arrow.getShooter() instanceof Player) { player = (Player) arrow.getShooter(); } } else if (event.getDamager() instanceof Player) { player = (Player) event.getDamager(); } if (player != null) { CivMessage.send(player, CivColor.LightGray + "Our attack was ineffective"); } } event.setDamage(damage); }
public void w_() { super.w_(); if (this.lastPitch == 0.0F && this.lastYaw == 0.0F) { float f = MathHelper.a(this.motX * this.motX + this.motZ * this.motZ); this.lastYaw = this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D); this.lastPitch = this.pitch = (float) (Math.atan2(this.motY, (double) f) * 180.0D / 3.1415927410125732D); } int i = this.world.getTypeId(this.e, this.f, this.g); if (i > 0) { Block.byId[i].updateShape(this.world, this.e, this.f, this.g); AxisAlignedBB axisalignedbb = Block.byId[i].e(this.world, this.e, this.f, this.g); if (axisalignedbb != null && axisalignedbb.a(Vec3D.create(this.locX, this.locY, this.locZ))) { this.inGround = true; } } if (this.shake > 0) { --this.shake; } if (this.inGround) { i = this.world.getTypeId(this.e, this.f, this.g); int j = this.world.getData(this.e, this.f, this.g); if (i == this.h && j == this.i) { ++this.k; if (this.k == 1200) { this.die(); } } else { this.inGround = false; this.motX *= (double) (this.random.nextFloat() * 0.2F); this.motY *= (double) (this.random.nextFloat() * 0.2F); this.motZ *= (double) (this.random.nextFloat() * 0.2F); this.k = 0; this.l = 0; } } else { ++this.l; Vec3D vec3d = Vec3D.create(this.locX, this.locY, this.locZ); Vec3D vec3d1 = Vec3D.create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); MovingObjectPosition movingobjectposition = this.world.rayTrace(vec3d, vec3d1, false, true); vec3d = Vec3D.create(this.locX, this.locY, this.locZ); vec3d1 = Vec3D.create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); if (movingobjectposition != null) { vec3d1 = Vec3D.create( movingobjectposition.f.a, movingobjectposition.f.b, movingobjectposition.f.c); } Entity entity = null; List list = this.world.b( (Entity) this, this.boundingBox.a(this.motX, this.motY, this.motZ).b(1.0D, 1.0D, 1.0D)); double d0 = 0.0D; int k; float f1; for (k = 0; k < list.size(); ++k) { Entity entity1 = (Entity) list.get(k); if (entity1.e_() && (entity1 != this.shooter || this.l >= 5)) { f1 = 0.3F; AxisAlignedBB axisalignedbb1 = entity1.boundingBox.b((double) f1, (double) f1, (double) f1); MovingObjectPosition movingobjectposition1 = axisalignedbb1.a(vec3d, vec3d1); if (movingobjectposition1 != null) { double d1 = vec3d.b(movingobjectposition1.f); if (d1 < d0 || d0 == 0.0D) { entity = entity1; d0 = d1; } } } } if (entity != null) { movingobjectposition = new MovingObjectPosition(entity); } float f2; if (movingobjectposition != null) { // CraftBukkit start ProjectileHitEvent phe = new ProjectileHitEvent((Projectile) this.getBukkitEntity()); this.world.getServer().getPluginManager().callEvent(phe); // CraftBukkit end if (movingobjectposition.entity != null) { f2 = MathHelper.a(this.motX * this.motX + this.motY * this.motY + this.motZ * this.motZ); int l = (int) Math.ceil((double) f2 * 2.0D); if (this.d) { l += this.random.nextInt(l / 2 + 2); } DamageSource damagesource = null; if (this.shooter == null) { damagesource = DamageSource.arrow(this, this); } else { damagesource = DamageSource.arrow(this, this.shooter); } // CraftBukkit start boolean stick; if (entity instanceof EntityLiving) { org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity(); Projectile projectile = (Projectile) this.getBukkitEntity(); EntityDamageByEntityEvent event = new EntityDamageByEntityEvent( projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, l); Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) { stick = !projectile.doesBounce(); } else { // this function returns if the arrow should stick in or not, i.e. !bounce stick = movingobjectposition.entity.damageEntity(damagesource, event.getDamage()); } } else { stick = movingobjectposition.entity.damageEntity(damagesource, l); } if (stick) { // CraftBukkit end if (movingobjectposition.entity instanceof EntityLiving) { ++((EntityLiving) movingobjectposition.entity).aH; } this.world.makeSound( this, "random.bowhit", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F)); this.die(); } else { this.motX *= -0.10000000149011612D; this.motY *= -0.10000000149011612D; this.motZ *= -0.10000000149011612D; this.yaw += 180.0F; this.lastYaw += 180.0F; this.l = 0; } } else { this.e = movingobjectposition.b; this.f = movingobjectposition.c; this.g = movingobjectposition.d; this.h = this.world.getTypeId(this.e, this.f, this.g); this.i = this.world.getData(this.e, this.f, this.g); this.motX = (double) ((float) (movingobjectposition.f.a - this.locX)); this.motY = (double) ((float) (movingobjectposition.f.b - this.locY)); this.motZ = (double) ((float) (movingobjectposition.f.c - this.locZ)); f2 = MathHelper.a(this.motX * this.motX + this.motY * this.motY + this.motZ * this.motZ); this.locX -= this.motX / (double) f2 * 0.05000000074505806D; this.locY -= this.motY / (double) f2 * 0.05000000074505806D; this.locZ -= this.motZ / (double) f2 * 0.05000000074505806D; this.world.makeSound( this, "random.bowhit", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F)); this.inGround = true; this.shake = 7; this.d = false; } } if (this.d) { for (k = 0; k < 4; ++k) { this.world.a( "crit", this.locX + this.motX * (double) k / 4.0D, this.locY + this.motY * (double) k / 4.0D, this.locZ + this.motZ * (double) k / 4.0D, -this.motX, -this.motY + 0.2D, -this.motZ); } } this.locX += this.motX; this.locY += this.motY; this.locZ += this.motZ; f2 = MathHelper.a(this.motX * this.motX + this.motZ * this.motZ); this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D); for (this.pitch = (float) (Math.atan2(this.motY, (double) f2) * 180.0D / 3.1415927410125732D); this.pitch - this.lastPitch < -180.0F; this.lastPitch -= 360.0F) {; } while (this.pitch - this.lastPitch >= 180.0F) { this.lastPitch += 360.0F; } while (this.yaw - this.lastYaw < -180.0F) { this.lastYaw -= 360.0F; } while (this.yaw - this.lastYaw >= 180.0F) { this.lastYaw += 360.0F; } this.pitch = this.lastPitch + (this.pitch - this.lastPitch) * 0.2F; this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F; float f3 = 0.99F; f1 = 0.05F; if (this.az()) { for (int i1 = 0; i1 < 4; ++i1) { float f4 = 0.25F; this.world.a( "bubble", this.locX - this.motX * (double) f4, this.locY - this.motY * (double) f4, this.locZ - this.motZ * (double) f4, this.motX, this.motY, this.motZ); } f3 = 0.8F; } this.motX *= (double) f3; this.motY *= (double) f3; this.motZ *= (double) f3; this.motY -= (double) f1; this.setPosition(this.locX, this.locY, this.locZ); } }