ZsoltMolnarrr / BetterCombat

⚔️ Easy, spectacular and fun melee combat system from Minecraft Dungeons.
https://www.curseforge.com/minecraft/mc-mods/better-combat-by-daedelus
Other
129 stars 49 forks source link

Attacking crashes when the offhand's attributes are null #365

Closed MindFaer closed 4 months ago

MindFaer commented 4 months ago

Minecraft version - 1.20.1 Mod loader - Forge 47.2.32 Mod version - 1.8.5+1.20.1-forge I am using the latest version available - Yes, for 1.20.1

Describe the bug If you give a weapon attribute of {} to a an item you would like to blacklist, it works normally in the main hand, but if you swing with a one handed weapon with the other item in the offhand, the game crashes.

To Reproduce Steps to reproduce the behavior:

  1. Make a datapack that gives any item attributes from a .json file containing just {}
  2. Give yourself that item and a one-handed weapon, the item that has the new attributes won't use better combat's animations if it was before
  3. Put the item in your offhand and the one-handed weapon in your main hand, attack, and the game crashes
  4. Error: java.lang.NullPointerException: Cannot invoke "net.bettercombat.api.AttackHand.attack()" because "hand" is null

Expected behavior Currently, in your discord server, the way people have been blacklisting items is by using a file with just {} in it, so that people who download a mod/datapack don't have to change their config and the .json does it for them. All it should do is swing as if the item in the offhand was a blacklisted item

Additional context crash-2024-05-27_22.44.50-client.txt latest.log

MindFaer commented 4 months ago

Forgot to mention, the json can be fully blank, or just contain {}, I somehow forgot it could be blank and still cause this

ZsoltMolnarrr commented 4 months ago

Use correct JSON please. Validator will be improved in the future.