package net.minecraft.world.level.block;

import net.minecraft.world.level.block.state.AbstractStateHolder;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.DustParticleOptions;
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.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((((AbstractStateHolder<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 byj, final BlockGetter bjg, final BlockPos fk, final CollisionContext cvq) {
        return WallTorchBlock.getShape(byj);
    }
    
    @Override
    public boolean canSurvive(final BlockState byj, final LevelReader bjz, final BlockPos fk) {
        return Blocks.WALL_TORCH.canSurvive(byj, bjz, fk);
    }
    
    @Override
    public BlockState updateShape(final BlockState byj1, final Direction fp, final BlockState byj3, final LevelAccessor bjx, final BlockPos fk5, final BlockPos fk6) {
        return Blocks.WALL_TORCH.updateShape(byj1, fp, byj3, bjx, fk5, fk6);
    }
    
    @Nullable
    @Override
    public BlockState getStateForPlacement(final BlockPlaceContext bcq) {
        final BlockState byj3 = Blocks.WALL_TORCH.getStateForPlacement(bcq);
        return (byj3 == null) ? null : ((AbstractStateHolder<O, BlockState>)this.defaultBlockState()).<Comparable, Comparable>setValue((Property<Comparable>)RedstoneWallTorchBlock.FACING, (Comparable)byj3.<V>getValue((Property<V>)RedstoneWallTorchBlock.FACING));
    }
    
    @Override
    public void animateTick(final BlockState byj, final Level bjw, final BlockPos fk, final Random random) {
        if (!byj.<Boolean>getValue((Property<Boolean>)RedstoneWallTorchBlock.LIT)) {
            return;
        }
        final Direction fp6 = byj.<Direction>getValue((Property<Direction>)RedstoneWallTorchBlock.FACING).getOpposite();
        final double double7 = 0.27;
        final double double8 = fk.getX() + 0.5 + (random.nextDouble() - 0.5) * 0.2 + 0.27 * fp6.getStepX();
        final double double9 = fk.getY() + 0.7 + (random.nextDouble() - 0.5) * 0.2 + 0.22;
        final double double10 = fk.getZ() + 0.5 + (random.nextDouble() - 0.5) * 0.2 + 0.27 * fp6.getStepZ();
        bjw.addParticle(DustParticleOptions.REDSTONE, double8, double9, double10, 0.0, 0.0, 0.0);
    }
    
    @Override
    protected boolean hasNeighborSignal(final Level bjw, final BlockPos fk, final BlockState byj) {
        final Direction fp5 = byj.<Direction>getValue((Property<Direction>)RedstoneWallTorchBlock.FACING).getOpposite();
        return bjw.hasSignal(fk.relative(fp5), fp5);
    }
    
    @Override
    public int getSignal(final BlockState byj, final BlockGetter bjg, final BlockPos fk, final Direction fp) {
        if (byj.<Boolean>getValue((Property<Boolean>)RedstoneWallTorchBlock.LIT) && byj.<Comparable>getValue((Property<Comparable>)RedstoneWallTorchBlock.FACING) != fp) {
            return 15;
        }
        return 0;
    }
    
    @Override
    public BlockState rotate(final BlockState byj, final Rotation btu) {
        return Blocks.WALL_TORCH.rotate(byj, btu);
    }
    
    @Override
    public BlockState mirror(final BlockState byj, final Mirror bsu) {
        return Blocks.WALL_TORCH.mirror(byj, bsu);
    }
    
    @Override
    protected void createBlockStateDefinition(final StateDefinition.Builder<Block, BlockState> a) {
        a.add(RedstoneWallTorchBlock.FACING, RedstoneWallTorchBlock.LIT);
    }
    
    static {
        FACING = HorizontalDirectionalBlock.FACING;
        LIT = RedstoneTorchBlock.LIT;
    }
}
