package net.minecraft.world.damagesource;

import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.item.ItemStack;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.LivingEntity;
import javax.annotation.Nullable;
import net.minecraft.world.entity.Entity;

public class IndirectEntityDamageSource extends EntityDamageSource {
    private final Entity owner;
    
    public IndirectEntityDamageSource(final String string, final Entity akq2, @Nullable final Entity akq3) {
        super(string, akq2);
        this.owner = akq3;
    }
    
    @Nullable
    @Override
    public Entity getDirectEntity() {
        return this.entity;
    }
    
    @Nullable
    @Override
    public Entity getEntity() {
        return this.owner;
    }
    
    @Override
    public Component getLocalizedDeathMessage(final LivingEntity akz) {
        final Component lf3 = (this.owner == null) ? this.entity.getDisplayName() : this.owner.getDisplayName();
        final ItemStack ben4 = (this.owner instanceof LivingEntity) ? ((LivingEntity)this.owner).getMainHandItem() : ItemStack.EMPTY;
        final String string5 = "death.attack." + this.msgId;
        final String string6 = string5 + ".item";
        if (!ben4.isEmpty() && ben4.hasCustomHoverName()) {
            return new TranslatableComponent(string6, new Object[] { akz.getDisplayName(), lf3, ben4.getDisplayName() });
        }
        return new TranslatableComponent(string5, new Object[] { akz.getDisplayName(), lf3 });
    }
}
