Closed Kiryonn closed 2 years ago
I have all of MCDungeons (weapons, armors, artifacts) mod on my world and not a single crash has occurred. I'm on 1.18 btw.
i'm on 1.18.1
yeah im on 1.18.1. that's probably caused by other mods coz Im literally using a MCDW weapon rn (Void Touch Blade)
I'm getting the same crash log when using Levelz with The Graveyard. It crashes as soon as you use a weapon from The Graveyard in survival (not creative). The weapon extends the SwordItem class and Levelz tries to convert it to MiningToolItem causing the crash (https://pastebin.com/VvQLh6S6). It seems unlikely to be caused by the weapon - it is just extending the vanilla sword class, without adding extra stuff.
We'll see here: https://github.com/chronosacaria/MCDungeonsWeapons/issues/69
The problem lies within the mixin in LevelZ for calculating max damage (PlayerEntityMixin.java row 142): it is caused because the mod uses fabric tags to determine if a toolitem is a sword, axe, hoe or else. Since many other mods dont register their items tag to be bound inside those fabric tags, even though the dagger in graveyard is a SwordItem, it is not registered in the FabricToolItems.SWORDS tag.
PlayerEntityMixin.java Row 129 : if (playerEntity.getMainHandStack().isIn(FabricToolTags.SWORDS))
--> this returns false and the boolean isSword is not set to true. Because of this at line 142 the items is casted to MiningToolItem, which is not.
Row 142: return zero ? 0 : original - ((MiningToolItem) playerEntity.getMainHandStack().getItem()).getAttackDamage();
A simple solution although not the best it may be to use reflection since the method in SwordItem and MiningToolItem is named the same and returns in both cases a float -> then the method can be invoked onto the item.
SO FROM
Line 139: if (isSword) return zero ? 0 : original - ((SwordItem) playerEntity.getMainHandStack().getItem()).getAttackDamage(); else return zero ? 0 : original - ((MiningToolItem) playerEntity.getMainHandStack().getItem()).getAttackDamage(); }
TO
Line 139: try { Method getter = playerEntity.getMainHandStack().getItem().getClass().getDeclaredMethod("getAttackDamage"); float attackDamage = (float) getter.invoke(playerEntity.getMainHandStack().getItem()); return zero ? 0 : original - attackDamage; } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); }
Thanks @MartinTornesello that is actually a very good idea, thanks for contributing
Looks like it doesn't work outside dev env:
java.lang.NoSuchMethodException: net.minecraft.class_1829.getAttackDamage()
I don't know yet if it's doing it for all weapons or just a few but at least 2 weapons makes the game crash when using levelZ
it's hard to tell if it's comming from levelZ or mcdw since the crash report indicate that mcdw makes the game crash but i'm pretty sure it comes from levelZ.
also here is the issue made to chronosacari by someone else about something extremelly similar. let's not talk about the id of the issue x)