Hello forum,
I wanted to try modding Project Zomboid so for the past day or two I have been making a barbwire baseball bat mod (that works like the nail bat) using posts from here at the forum and the PZ modding wiki. I've almost finished the core of the mod which is just the weapon, the repair scripts, model , & texture(s) and everything works fine until you strike with the weapon. There seems to be a 1/5(and if not the first, then at some point in the next four swings) chance that the game fades to black with error codes like (1,2,3,4,5, or 6) just a single number seemingly increasing by one with every crash. This has happened when striking a zombie or just swinging in the air, but only when my character swings the bat, not while idle with it. the screen fades to black and then loads the main menu.
Ive narrowed it down in the debug logs to this one line that seems to cause the crash,
ExceptionLogger.logException> Exception thrown java.lang.NullPointerException: Cannot invoke "zombie.inventory.types.HandWeapon.getSwingAnim()" because "<parameter1>.bareHands" is null at SwipeStatePlayer.CalcAttackVars line:651..
I've looked up "zombie.inventory.types.HandWeapon.getSwingAnim()" through this page https://projectzomboid.com/modding/zombie/inventory/types/HandWeapon.html
and am not entirely sure what is going wrong. I will attach the mod itself (forgive me if its formatted oddly or if i made some mistakes of somekind, and please let me know if i did) so you can see for yourself.
I have attached the FBX model file for the bat
the Fixing script
the weapon script itself
and mod.info
And if you want to recreate the error for yourself here is a dropbox link to all of the Mod
https://www.dropbox.com/scl/fo/ru8vdce4b3sqtkftwndmz/h?rlkey=0l3mq81dvlgx2oiy5h798gl8z&dl=0
the work folder in their is just to keep track of files I was using.
And help is greatly appreciated!
edit: rewording
WiredBaseballBat.fbx fixing.txt items_weapons.txt mod.info