This bug effects also affects other explosions in the game, such as TNT explosions. It doesn't affect bed and respawn anchor explosions (because their damage source is specified as a BadRespawnPointDamageSource with scaleWithDifficulty = true) and creeper explosions (because it dies and the causingEntity is null).
Code Analysis (yarn mappings):
Scaling damage with difficulty is done in the damage method of the PlayerEntity class:
Whether the damage is scaled is determined on if the scaleWithDifficulty field of source is true. In the damage method of the EndCrystalEntity class, these two lines handle the explosion:
In the case of TNT lit by a player, it explodes without specifying the damage source, instead having a getCausingEntity method that is called in Explosion.getCausingEntity which is called in DamageSource.explosion which is called in the Explosion constructor called in World.createExplosion.
In both these cases, DamageSource.explosion is called:
Because both attacker and explosion are not null, a ProjectileDamageSource is created which extends EntityDamageSource which overrides the isScaledWithDifficulty method in DamageSource. Instead of
This is done to have difficulty scaling apply only to mobs and not players. Since a player lit the TNT and a player hit the end crystal, this will be false, so the damage of the explosion will not be scaled.
Proposed Fix:
Change EntityDamageSource.isScaledWithDifficulty to
This bug effects also affects other explosions in the game, such as TNT explosions. It doesn't affect bed and respawn anchor explosions (because their damage source is specified as a
BadRespawnPointDamageSource
withscaleWithDifficulty = true
) and creeper explosions (because it dies and thecausingEntity
isnull
).Code Analysis (yarn mappings):
Scaling damage with difficulty is done in the
damage
method of thePlayerEntity
class:Whether the damage is scaled is determined on if the
scaleWithDifficulty
field ofsource
is true. In thedamage
method of theEndCrystalEntity
class, these two lines handle the explosion:In the case of TNT lit by a player, it explodes without specifying the damage source, instead having a
getCausingEntity
method that is called inExplosion.getCausingEntity
which is called inDamageSource.explosion
which is called in theExplosion
constructor called inWorld.createExplosion
.In both these cases,
DamageSource.explosion
is called:Because both
attacker
andexplosion
are notnull
, aProjectileDamageSource
is created which extendsEntityDamageSource
which overrides theisScaledWithDifficulty
method inDamageSource
.Instead of
it's
This is done to have difficulty scaling apply only to mobs and not players. Since a player lit the TNT and a player hit the end crystal, this will be false, so the damage of the explosion will not be scaled.
Proposed Fix:
Change
EntityDamageSource.isScaledWithDifficulty
toThis shouldn't break anything to my knowledge.
Edit:
Because of MC-258561 and MC-157206 it's probably better to create a separate damage source for explosions instead of using the one for projectiles.