Skip to content

Commit

Permalink
fix fishing trait errors with non-players
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jun 5, 2020
1 parent be63cbb commit e0c1e66
Showing 1 changed file with 11 additions and 8 deletions.
Expand Up @@ -178,11 +178,13 @@ private void cast() {
v = v + (CoreUtilities.getRandom().nextDouble() - .8) / 2;
victor = victor.multiply(v / 20.0);

fishHook = NMSHandler.getFishingHelper().spawnHook(from, (Player) npc.getEntity());
fishHook.setShooter((ProjectileSource) npc.getEntity());
fishHook.setVelocity(victor);
if (npc.getEntity() instanceof Player) {
fishHook = NMSHandler.getFishingHelper().spawnHook(from, (Player) npc.getEntity());
fishHook.setShooter((ProjectileSource) npc.getEntity());
fishHook.setVelocity(victor);

PlayerAnimation.ARM_SWING.play((Player) npc.getEntity());
PlayerAnimation.ARM_SWING.play((Player) npc.getEntity());
}
}

// <--[action]
Expand All @@ -200,10 +202,9 @@ private void reel() {

int chance = (int) (Math.random() * 100);

try {
if (fishHook != null && fishHook.isValid()) {
fishHook.remove();
}
catch (Exception e) {
fishHook = null;
}

if (catchPercent > chance && fishHook != null && catchType != FishingHelper.CatchType.NONE) {
Expand All @@ -227,7 +228,9 @@ private void reel() {
DenizenAPI.getDenizenNPC(npc).action("catch fish", null);
}

PlayerAnimation.ARM_SWING.play((Player) npc.getEntity());
if (npc.getEntity() instanceof Player) {
PlayerAnimation.ARM_SWING.play((Player) npc.getEntity());
}
}

/**
Expand Down

0 comments on commit e0c1e66

Please sign in to comment.