BetterCombat icon indicating copy to clipboard operation
BetterCombat copied to clipboard

Divide by zero crash with certain Weapon Attributes

Open muon-rw opened this issue 9 months ago • 1 comments

Minecraft version - 1.21.1 Mod loader - Fabric Mod version - 2.1.3 I am using the latest version available - Yes!

Describe the bug Some weapon attributes containers seem to cause a crash, instead of being sanitized/marked as invalid.

An example is Simply Swords' Soulrender: https://github.com/Sweenus/SimplySwords/blob/c81638c2fe0b3d9effe90352eeb5536ba118f20b/common/src/main/resources/data/simplyswords/weapon_attributes/soulrender.json

To Reproduce Steps to reproduce the behavior:

  1. Install Simply Swords and Better Combat
  2. Equip a Soulrender
  3. Equip an item (with no weapon attributes) in your offhand
  4. Crash

Crash report https://mclo.gs/lZHow7h

Additional Info The divide by zero seems to be referring to this modulo: https://github.com/ZsoltMolnarrr/BetterCombat/blob/e267148a9d2d97e6c16396608180be62a80e03d5/common/src/main/java/net/bettercombat/logic/PlayerAttackHelper.java#L93

Changing the last two NO_OFFHAND_ITEM attacks in the example json to NOT_DUAL_WIELDING fixes the crash, so maybe this is caused by the weapon having no valid attacks available? In that case, I still think it should be sanitized/fall back/have no weapon attributes.

muon-rw avatar Apr 09 '25 02:04 muon-rw

(After some more thought, this is probably best, just putting it on here for ease of tracking)

Image

muon-rw avatar Apr 15 '25 22:04 muon-rw

I am unable to reproduce the issue.

It would help a lot if you could give feedback, whether this commit fixed the issue.

Posted on built Jar also Discord pre-release channel

ZsoltMolnarrr avatar Apr 23 '25 18:04 ZsoltMolnarrr

I can test it shortly!

muon-rw avatar Apr 23 '25 19:04 muon-rw

Could you backport this to 1.20.1?

llyyr avatar Dec 02 '25 18:12 llyyr

Backported and released

ZsoltMolnarrr avatar Dec 03 '25 14:12 ZsoltMolnarrr