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.level.block.state.BlockBehaviour;
import net.minecraft.world.item.DyeColor;

public abstract class AbstractBannerBlock extends BaseEntityBlock {
    private final DyeColor color;
    
    protected AbstractBannerBlock(final DyeColor bje, final Properties c) {
        super(c);
        this.color = bje;
    }
    
    @Override
    public boolean isPossibleToRespawnInThis() {
        return true;
    }
    
    @Override
    public BlockEntity newBlockEntity(final BlockGetter bpg) {
        return new BannerBlockEntity(this.color);
    }
    
    @Override
    public void setPlacedBy(final Level bqb, final BlockPos fu, final BlockState cfj, @Nullable final LivingEntity aoy, final ItemStack bki) {
        if (bki.hasCustomHoverName()) {
            final BlockEntity cdl7 = bqb.getBlockEntity(fu);
            if (cdl7 instanceof BannerBlockEntity) {
                ((BannerBlockEntity)cdl7).setCustomName(bki.getHoverName());
            }
        }
    }
    
    @Override
    public ItemStack getCloneItemStack(final BlockGetter bpg, final BlockPos fu, final BlockState cfj) {
        final BlockEntity cdl5 = bpg.getBlockEntity(fu);
        if (cdl5 instanceof BannerBlockEntity) {
            return ((BannerBlockEntity)cdl5).getItem(cfj);
        }
        return super.getCloneItemStack(bpg, fu, cfj);
    }
    
    public DyeColor getColor() {
        return this.color;
    }
}
