Skip to content

Commit

Permalink
Made 'shooterless' arrows dodgeable
Browse files Browse the repository at this point in the history
  • Loading branch information
bm01 committed Jun 22, 2012
1 parent 3e20dc7 commit d51fa92
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
1 change: 1 addition & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Version 1.3.09
= Fixed possible NPE when falling with no item in hand
! API methods can now only be used in a static way
! Arrows shot from a bow having the Infitity enchantment can no longer be retrieved
! Arrows that aren't shot by an entity are now dodgeable (currently only from dispensers)
! Changed Spout settings to be in their own config file (spout.yml)
! Changed file format for parties (parties.yml), previous files are no longer used
! Changed mcMMO to inform on corrupt Chunklets and make new ones
Expand Down
12 changes: 3 additions & 9 deletions src/main/java/com/gmail/nossr50/listeners/EntityListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,19 @@ public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
}

Entity attacker = event.getDamager();
Entity defender = event.getEntity();

if (attacker instanceof Projectile) {
attacker = ((Projectile) attacker).getShooter();

//There is no shooter when a projectile is thrown by a dispenser
if (attacker == null) {
return;
}
}
else if (attacker instanceof Tameable) {
AnimalTamer animalTamer = ((Tameable) attacker).getOwner();

if (animalTamer instanceof Player) {
attacker = (Player) animalTamer;
if (animalTamer instanceof Entity) {
attacker = (Entity) animalTamer;
}
}

Entity defender = event.getEntity();

if (attacker instanceof Player && defender instanceof Player) {
if (PartyManager.getInstance().inSameParty((Player) defender, (Player) attacker)) {
event.setCancelled(true);
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/gmail/nossr50/util/Combat.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ else if (!configInstance.getTamingPVE()) {
case ARROW:
LivingEntity shooter = ((Arrow) damager).getShooter();

if (shooter.getType() != EntityType.PLAYER) {
return;
if (shooter == null || shooter.getType() != EntityType.PLAYER) {
break;
}

if (targetIsPlayer || targetIsTamedPet) {
Expand All @@ -191,7 +191,7 @@ else if (!configInstance.getArcheryPVE()) {
break;
}

if (targetIsPlayer && damager instanceof LivingEntity) {
if (targetIsPlayer) {
Player player = (Player) target;

AcrobaticsManager acroManager = new AcrobaticsManager(player);
Expand All @@ -207,7 +207,7 @@ else if (!configInstance.getArcheryPVE()) {
}
}
else {
if (configInstance.getSwordsPVE()) {
if (configInstance.getSwordsPVE() && damager instanceof LivingEntity) {
swordsManager.counterAttackChecks((LivingEntity) damager, event.getDamage());
}

Expand Down

0 comments on commit d51fa92

Please sign in to comment.