The bug
The player gets the "Return to Sender" (achievement.ghast
) achievement even if the ghast was not killed. You would expect not to get the achievement because the description of it says "Destroy a Ghast with a fireball".
How to reproduce
Give yourself all required achievements
/achievement give achievement.portal
Summon a ghast with more than 1000 health, because a fireball reflected by a player does 1000 damage to a ghast
/summon armor_stand ~ ~ ~ {Invulnerable:1b,Passengers:[{id:"ghast",Attributes:[{Name:"generic.maxHealth",Base:1000.1}],Health:1000.1f}]}
Summon a fireball and punch it towards the ghast
/summon fireball ~ ~ ~ {direction:[0.0,0.0,0.0]}
→ You will get the achievement even though the ghast was not killed
Code analysis
Based on 1.11.2 decompiled using MCP 9.35 rc1
The method net.minecraft.entity.monster.EntityGhast.attackEntityFrom(DamageSource, float)
always gives the achievement regardless of it the ghast is dead.
Suggested fix
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource source, float amount)
{
if (this.isEntityInvulnerable(source))
{
return false;
}
else if ("fireball".equals(source.getDamageType()) && source.getEntity() instanceof EntityPlayer)
{
// Replaced this
// super.attackEntityFrom(source, 1000.0F);
// ((EntityPlayer)source.getEntity()).addStat(AchievementList.GHAST);
// return true;
boolean successfullyAttacked = super.attackEntityFrom(source, 1000.0F);
if (successfullyAttacked && !this.isEntityAlive()) {
((EntityPlayer)source.getEntity()).addStat(AchievementList.GHAST);
}
return successfullyAttacked;
}
else
{
return super.attackEntityFrom(source, amount);
}
}
Comments 4
Might still be the case with advancements; all achievements will be converted, so we have to wait until then to see if this is still the case or fixed.
Uhh... is it Invalid , or Cannot Reproduce now that Achievements have been replaced with advancements?