Andrew6rant / precise-damage

Changes damage calculations to allow for fractional values.
MIT License
5 stars 1 forks source link

Precise Damage force closes the world with the Illager Expansion [Rematch] mod #2

Open PootisWizard opened 1 year ago

PootisWizard commented 1 year ago

Not sure how long the title can be so I'll be much clearer here.

This mod when used with the Illager Expansion [Rematch] mod causes all Illagers added from that mod unable to take melee damage from the player, if they take any damage from player bows or outside sources, it force closes the world, and might softlock the world.

Andrew6rant commented 1 year ago

Huh, that is really weird. Looks like I get java.lang.NullPointerException: Cannot invoke "net.minecraft.entity.attribute.DefaultAttributeContainer.getValue(net.minecraft.entity.attribute.EntityAttribute)" because "this.fallback" is null when melee attacking an Illager Expansion entity.

Precise Damage queries the entities' true armor and armor toughness values to do the damage calculation, instead of their rounded values. It seems like Illager Expansion entities override the getAttributes() method, which is the cause of the armor value being null and not 0.

I can fix this by wrapping my attribute check in a try catch block (and falling back to vanilla's code if the error pops up), but there is a minor performance impact, and I really think this should be something that should be handled on Illager Expansion's side.

EDIT: I've fixed it instead by shadowing Vanilla's methods instead of implementing my own attribute lookup. Why this fixes the issue, I truly do not know. My old code should be 1-1 to Vanilla's, but slightly more performant.

Andrew6rant commented 1 year ago

Whoops, I didn't realize putting the keyword "Fixes" before the issue tag (in the commit) automatically closes the issue. I would like to keep this issue open until the fix is released on CurseForge, GitHub, and Modrinth.