package net.minecraft.world.level.block;

import net.minecraft.world.item.ItemStack;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.stats.Stats;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.entity.BeaconBlockEntity;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.item.DyeColor;

public class BeaconBlock extends BaseEntityBlock implements BeaconBeamBlock {
    public BeaconBlock(final Properties c) {
        super(c);
    }
    
    @Override
    public DyeColor getColor() {
        return DyeColor.WHITE;
    }
    
    @Override
    public BlockEntity newBlockEntity(final BlockGetter bjg) {
        return new BeaconBlockEntity();
    }
    
    @Override
    public InteractionResult use(final BlockState byj, final Level bjw, final BlockPos fk, final Player ayj, final InteractionHand ajk, final BlockHitResult cvg) {
        if (bjw.isClientSide) {
            return InteractionResult.SUCCESS;
        }
        final BlockEntity bwl8 = bjw.getBlockEntity(fk);
        if (bwl8 instanceof BeaconBlockEntity) {
            ayj.openMenu((MenuProvider)bwl8);
            ayj.awardStat(Stats.INTERACT_WITH_BEACON);
        }
        return InteractionResult.SUCCESS;
    }
    
    @Override
    public boolean isRedstoneConductor(final BlockState byj, final BlockGetter bjg, final BlockPos fk) {
        return false;
    }
    
    @Override
    public RenderShape getRenderShape(final BlockState byj) {
        return RenderShape.MODEL;
    }
    
    @Override
    public void setPlacedBy(final Level bjw, final BlockPos fk, final BlockState byj, final LivingEntity akz, final ItemStack ben) {
        if (ben.hasCustomHoverName()) {
            final BlockEntity bwl7 = bjw.getBlockEntity(fk);
            if (bwl7 instanceof BeaconBlockEntity) {
                ((BeaconBlockEntity)bwl7).setCustomName(ben.getHoverName());
            }
        }
    }
}
