package net.minecraft.world.level.block;

import net.minecraft.core.particles.ParticleTypes;
import java.util.Random;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.core.Direction;
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.BlockState;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.world.phys.shapes.VoxelShape;

public class TorchBlock extends Block {
    protected static final VoxelShape AABB;
    protected final ParticleOptions flameParticle;
    
    protected TorchBlock(final Properties c, final ParticleOptions hf) {
        super(c);
        this.flameParticle = hf;
    }
    
    @Override
    public VoxelShape getShape(final BlockState cfj, final BlockGetter bpg, final BlockPos fu, final CollisionContext der) {
        return TorchBlock.AABB;
    }
    
    @Override
    public BlockState updateShape(final BlockState cfj1, final Direction fz, final BlockState cfj3, final LevelAccessor bqc, final BlockPos fu5, final BlockPos fu6) {
        if (fz == Direction.DOWN && !this.canSurvive(cfj1, bqc, fu5)) {
            return Blocks.AIR.defaultBlockState();
        }
        return super.updateShape(cfj1, fz, cfj3, bqc, fu5, fu6);
    }
    
    @Override
    public boolean canSurvive(final BlockState cfj, final LevelReader bqd, final BlockPos fu) {
        return Block.canSupportCenter(bqd, fu.below(), Direction.UP);
    }
    
    @Override
    public void animateTick(final BlockState cfj, final Level bqb, final BlockPos fu, final Random random) {
        final double double6 = fu.getX() + 0.5;
        final double double7 = fu.getY() + 0.7;
        final double double8 = fu.getZ() + 0.5;
        bqb.addParticle(ParticleTypes.SMOKE, double6, double7, double8, 0.0, 0.0, 0.0);
        bqb.addParticle(this.flameParticle, double6, double7, double8, 0.0, 0.0, 0.0);
    }
    
    static {
        AABB = Block.box(6.0, 0.0, 6.0, 10.0, 10.0, 10.0);
    }
}
