MinecraftForge/MinecraftForge

Allow enchantments to modify damage based on the entity hit

Open

#6,564 opened on Mar 14, 2020

View on GitHub
 (6 comments) (0 reactions) (0 assignees)Java (6,538 stars) (2,701 forks)batch import
1.181.19FeatureHelp Wanted

Description

Enchantments can only modify the dealt damage based on the entity's CreatureAttribute, not on the entity object itself. Therefore it's not possible to e.g. change the damage based some capability of a player. More information in the linked PR below.

I once made a PR https://github.com/MinecraftForge/MinecraftForge/pull/4052, which was eventually declined due to some thread safety concerns by Lex. However, the issue is still present. I don't assume Lex got around talking to grum about this, but I noticed that in PlayerEntity#attackTargetEntityWithCurrentItem the entity object is passed to a CriticalHitEvent just a few lines after the enchantment damage calculation, which means it is also available to modders.

I do not exactly know what's the thread safety issue here (as I don't see any difference from other parts of MC), but if there is a potential issue, then it is already exposed by said event. So why not add the enchantment thing as well.

If you agree, I would update the PR for 1.15 and make sure to add a comment that the entity should not be modified in that method.

Contributor guide