Skip to content

Commit

Permalink
Merge pull request #264 from GameModsBR/PN-68
Browse files Browse the repository at this point in the history
Fixes fishing hooks not attaching to entities.
  • Loading branch information
joserobjr committed May 17, 2020
2 parents f4b6a84 + 87eae6a commit e65c544
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Click the link above to see the future.
- [#79] Sugarcane can grow without water
- [#262] Removing the water don't break the sugarcane (using empty bucket or breaking water flow)
- [#263] Fixes disconnect messages not reaching the player sometimes
- [#116] Fishing hooks don't attach to entities and damages multiples entities

### Changed
- [#247] Invalid BlockId:Meta combinations now log an error when found. It logs only once
Expand Down Expand Up @@ -225,6 +226,7 @@ Fixes several anvil issues.
[#102]: https://github.com/GameModsBR/PowerNukkit/pull/102
[#103]: https://github.com/GameModsBR/PowerNukkit/issues/103
[#108]: https://github.com/GameModsBR/PowerNukkit/pull/108
[#116]: https://github.com/GameModsBR/PowerNukkit/issues/116
[#129]: https://github.com/GameModsBR/PowerNukkit/pull/129
[#140]: https://github.com/GameModsBR/PowerNukkit/pull/140
[#152]: https://github.com/GameModsBR/PowerNukkit/pull/152
Expand Down
13 changes: 12 additions & 1 deletion src/main/java/cn/nukkit/entity/item/EntityFishingHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@ public void spawnTo(Player player) {
super.spawnTo(player);
}

@Override
public boolean canCollide() {
return getRiding() == null;
}

@Override
public void onCollideWithEntity(Entity entity) {
this.server.getPluginManager().callEvent(new ProjectileHitEvent(this, MovingObjectPosition.fromEntity(entity)));
Expand All @@ -297,6 +302,12 @@ public void onCollideWithEntity(Entity entity) {
ev = new EntityDamageByChildEntityEvent(this.shootingEntity, this, entity, DamageCause.PROJECTILE, damage);
}

entity.attack(ev);
if (entity.attack(ev)) {
Entity top = entity;
for (Entity current = top; current != null; current = current.getPassenger()) {
top = current;
}
top.mountEntity(this);
}
}
}

0 comments on commit e65c544

Please sign in to comment.