package net.minecraft.world.level.block;

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;
import net.minecraft.world.level.block.entity.BannerBlockEntity;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.item.DyeColor;

public abstract class AbstractBannerBlock extends BaseEntityBlock {
    private final DyeColor color;
    
    protected AbstractBannerBlock(final DyeColor bdj, final Properties c) {
        super(c);
        this.color = bdj;
    }
    
    @Override
    public boolean isPossibleToRespawnInThis() {
        return true;
    }
    
    @Override
    public BlockEntity newBlockEntity(final BlockGetter bjg) {
        return new BannerBlockEntity(this.color);
    }
    
    @Override
    public void setPlacedBy(final Level bjw, final BlockPos fk, final BlockState byj, @Nullable final LivingEntity akz, final ItemStack ben) {
        if (ben.hasCustomHoverName()) {
            final BlockEntity bwl7 = bjw.getBlockEntity(fk);
            if (bwl7 instanceof BannerBlockEntity) {
                ((BannerBlockEntity)bwl7).setCustomName(ben.getHoverName());
            }
        }
    }
    
    @Override
    public ItemStack getCloneItemStack(final BlockGetter bjg, final BlockPos fk, final BlockState byj) {
        final BlockEntity bwl5 = bjg.getBlockEntity(fk);
        if (bwl5 instanceof BannerBlockEntity) {
            return ((BannerBlockEntity)bwl5).getItem(byj);
        }
        return super.getCloneItemStack(bjg, fk, byj);
    }
    
    public DyeColor getColor() {
        return this.color;
    }
}
