package net.minecraft.world.level.block;

import net.minecraft.world.level.block.state.StateHolder;
import net.minecraft.world.level.block.state.StateDefinition;
import java.util.Random;
import net.minecraft.world.level.Level;
import javax.annotation.Nullable;
import net.minecraft.world.item.BlockPlaceContext;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.DirectionProperty;

public class RedstoneWallTorchBlock extends RedstoneTorchBlock {
    public static final DirectionProperty FACING;
    public static final BooleanProperty LIT;
    
    protected RedstoneWallTorchBlock(final Properties c) {
        super(c);
        this.registerDefaultState((((StateHolder<O, BlockState>)this.stateDefinition.any()).setValue((Property<Comparable>)RedstoneWallTorchBlock.FACING, Direction.NORTH)).<Comparable, Boolean>setValue((Property<Comparable>)RedstoneWallTorchBlock.LIT, true));
    }
    
    @Override
    public String getDescriptionId() {
        return this.asItem().getDescriptionId();
    }
    
    @Override
    public VoxelShape getShape(final BlockState cfj, final BlockGetter bpg, final BlockPos fu, final CollisionContext der) {
        return WallTorchBlock.getShape(cfj);
    }
    
    @Override
    public boolean canSurvive(final BlockState cfj, final LevelReader bqd, final BlockPos fu) {
        return Blocks.WALL_TORCH.canSurvive(cfj, bqd, fu);
    }
    
    @Override
    public BlockState updateShape(final BlockState cfj1, final Direction fz, final BlockState cfj3, final LevelAccessor bqc, final BlockPos fu5, final BlockPos fu6) {
        return Blocks.WALL_TORCH.updateShape(cfj1, fz, cfj3, bqc, fu5, fu6);
    }
    
    @Nullable
    @Override
    public BlockState getStateForPlacement(final BlockPlaceContext bin) {
        final BlockState cfj3 = Blocks.WALL_TORCH.getStateForPlacement(bin);
        return (cfj3 == null) ? null : ((StateHolder<O, BlockState>)this.defaultBlockState()).<Comparable, Comparable>setValue((Property<Comparable>)RedstoneWallTorchBlock.FACING, (Comparable)cfj3.<V>getValue((Property<V>)RedstoneWallTorchBlock.FACING));
    }
    
    @Override
    public void animateTick(final BlockState cfj, final Level bqb, final BlockPos fu, final Random random) {
        if (!cfj.<Boolean>getValue((Property<Boolean>)RedstoneWallTorchBlock.LIT)) {
            return;
        }
        final Direction fz6 = cfj.<Direction>getValue((Property<Direction>)RedstoneWallTorchBlock.FACING).getOpposite();
        final double double7 = 0.27;
        final double double8 = fu.getX() + 0.5 + (random.nextDouble() - 0.5) * 0.2 + 0.27 * fz6.getStepX();
        final double double9 = fu.getY() + 0.7 + (random.nextDouble() - 0.5) * 0.2 + 0.22;
        final double double10 = fu.getZ() + 0.5 + (random.nextDouble() - 0.5) * 0.2 + 0.27 * fz6.getStepZ();
        bqb.addParticle(this.flameParticle, double8, double9, double10, 0.0, 0.0, 0.0);
    }
    
    @Override
    protected boolean hasNeighborSignal(final Level bqb, final BlockPos fu, final BlockState cfj) {
        final Direction fz5 = cfj.<Direction>getValue((Property<Direction>)RedstoneWallTorchBlock.FACING).getOpposite();
        return bqb.hasSignal(fu.relative(fz5), fz5);
    }
    
    @Override
    public int getSignal(final BlockState cfj, final BlockGetter bpg, final BlockPos fu, final Direction fz) {
        if (cfj.<Boolean>getValue((Property<Boolean>)RedstoneWallTorchBlock.LIT) && cfj.<Comparable>getValue((Property<Comparable>)RedstoneWallTorchBlock.FACING) != fz) {
            return 15;
        }
        return 0;
    }
    
    @Override
    public BlockState rotate(final BlockState cfj, final Rotation cap) {
        return Blocks.WALL_TORCH.rotate(cfj, cap);
    }
    
    @Override
    public BlockState mirror(final BlockState cfj, final Mirror bzj) {
        return Blocks.WALL_TORCH.mirror(cfj, bzj);
    }
    
    @Override
    protected void createBlockStateDefinition(final StateDefinition.Builder<Block, BlockState> a) {
        a.add(RedstoneWallTorchBlock.FACING, RedstoneWallTorchBlock.LIT);
    }
    
    static {
        FACING = HorizontalDirectionalBlock.FACING;
        LIT = RedstoneTorchBlock.LIT;
    }
}
