package net.minecraft.world.level.block;

import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.block.entity.BlockEntity;
import java.util.UUID;
import com.mojang.authlib.GameProfile;
import org.apache.commons.lang3.StringUtils;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.world.level.block.entity.SkullBlockEntity;
import net.minecraft.world.item.ItemStack;
import javax.annotation.Nullable;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;

public class PlayerHeadBlock extends SkullBlock {
    protected PlayerHeadBlock(final Properties c) {
        super(Types.PLAYER, c);
    }
    
    @Override
    public void setPlacedBy(final Level bjw, final BlockPos fk, final BlockState byj, @Nullable final LivingEntity akz, final ItemStack ben) {
        super.setPlacedBy(bjw, fk, byj, akz, ben);
        final BlockEntity bwl7 = bjw.getBlockEntity(fk);
        if (bwl7 instanceof SkullBlockEntity) {
            final SkullBlockEntity bxi8 = (SkullBlockEntity)bwl7;
            GameProfile gameProfile9 = null;
            if (ben.hasTag()) {
                final CompoundTag jt10 = ben.getTag();
                if (jt10.contains("SkullOwner", 10)) {
                    gameProfile9 = NbtUtils.readGameProfile(jt10.getCompound("SkullOwner"));
                }
                else if (jt10.contains("SkullOwner", 8) && !StringUtils.isBlank((CharSequence)jt10.getString("SkullOwner"))) {
                    gameProfile9 = new GameProfile((UUID)null, jt10.getString("SkullOwner"));
                }
            }
            bxi8.setOwner(gameProfile9);
        }
    }
}
