mojira.dev
MC-114122

Player gets "Return to Sender" achievement (killing ghast with fireball) even if ghast was not killed

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

  1. Give yourself all required achievements

    /achievement give achievement.portal
  2. 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}]}
  3. 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

Uhh... is it Invalid , or Cannot Reproduce now that Achievements have been replaced with advancements?

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.

Marking as invalid since the advancement is created with the minecraft:player_killed_entity and no special trigger.

marcono1234

(Unassigned)

Confirmed

achievement, damage, fireball, ghast, player

Minecraft 1.11.2, Minecraft 17w06a

Retrieved