MarkusBordihn / BOs-Easy-NPC

Create easily NPC for your world or for your mod.
Other
20 stars 8 forks source link

[Bug] Compatibility issue with "Passive Skill Tree" resulting in crash when NPC uses Bow/Crossbow. #144

Closed Sable-17 closed 7 months ago

Sable-17 commented 7 months ago

I seem to be having a crash when my EasyNPC uses a Crossbow or a Bow to attack a monster. The game crashes as soon as he goes to draw. Crash log points to Passive Skill Tree so I'm going to post my issue there as well, but figured I'd share here too in case it helps.

https://pastebin.com/raw/E9TX27PU

MarkusBordihn commented 7 months ago

Thanks for the report. This is something which needs to be fixed within the "Passive Skill Tree" mod itself.

I see the following relevant code:

    AttributeInstance attribute = event.getEntity().getAttribute(Attributes.ATTACK_SPEED);
    if (attribute == null) return;
    double attackSpeedBonus = attribute.getValue() / attribute.getBaseValue() - 1;

Source: https://github.com/Daripher/Passive-Skill-Tree/blob/ec00ac2db67ac2047adfd7348afb769ad13e1a4d/src/main/java/daripher/skilltree/attribute/event/AttributeEvents.java#L175

The NPC has a ATTACK_SPEED base value of 0 (if not adjusted), which means this cause the ArithmeticException: / by zero crash. They can easily fix this by checking if the value is 0 before they are performing any division.

Feel free to open a bug request on their side and reference to this bug, so that they easily understand the problem in this case.

Sable-17 commented 7 months ago

Thank you so much! Changing the attack speed to anything but 0 worked! I linked back to this over on their github.