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
BadRespawnPointDamageSourcewithscaleWithDifficulty = true) and creeper explosions (because it dies and thecausingEntityisnull).Code Analysis (yarn mappings):
Scaling damage with difficulty is done in the
damagemethod of thePlayerEntityclass:Whether the damage is scaled is determined on if the
scaleWithDifficultyfield ofsourceis true. In thedamagemethod of theEndCrystalEntityclass, 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
getCausingEntitymethod that is called inExplosion.getCausingEntitywhich is called inDamageSource.explosionwhich is called in theExplosionconstructor called inWorld.createExplosion.In both these cases,
DamageSource.explosionis called:Because both
attackerandexplosionare notnull, aProjectileDamageSourceis created which extendsEntityDamageSourcewhich overrides theisScaledWithDifficultymethod 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.isScaledWithDifficultytoThis 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.