package net.minecraft.world.level.block;

import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.core.Direction;
import net.minecraft.sounds.SoundSource;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.level.block.state.properties.Property;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.stats.Stats;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.entity.player.Player;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.FurnaceBlockEntity;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.state.BlockBehaviour;

public class FurnaceBlock extends AbstractFurnaceBlock {
    protected FurnaceBlock(final Properties c) {
        super(c);
    }
    
    @Override
    public BlockEntity newBlockEntity(final BlockGetter bpg) {
        return new FurnaceBlockEntity();
    }
    
    @Override
    protected void openContainer(final Level bqb, final BlockPos fu, final Player bec) {
        final BlockEntity cdl5 = bqb.getBlockEntity(fu);
        if (cdl5 instanceof FurnaceBlockEntity) {
            bec.openMenu((MenuProvider)cdl5);
            bec.awardStat(Stats.INTERACT_WITH_FURNACE);
        }
    }
    
    @Override
    public void animateTick(final BlockState cfj, final Level bqb, final BlockPos fu, final Random random) {
        if (!cfj.<Boolean>getValue((Property<Boolean>)FurnaceBlock.LIT)) {
            return;
        }
        final double double6 = fu.getX() + 0.5;
        final double double7 = fu.getY();
        final double double8 = fu.getZ() + 0.5;
        if (random.nextDouble() < 0.1) {
            bqb.playLocalSound(double6, double7, double8, SoundEvents.FURNACE_FIRE_CRACKLE, SoundSource.BLOCKS, 1.0f, 1.0f, false);
        }
        final Direction fz12 = cfj.<Direction>getValue((Property<Direction>)FurnaceBlock.FACING);
        final Direction.Axis a13 = fz12.getAxis();
        final double double9 = 0.52;
        final double double10 = random.nextDouble() * 0.6 - 0.3;
        final double double11 = (a13 == Direction.Axis.X) ? (fz12.getStepX() * 0.52) : double10;
        final double double12 = random.nextDouble() * 6.0 / 16.0;
        final double double13 = (a13 == Direction.Axis.Z) ? (fz12.getStepZ() * 0.52) : double10;
        bqb.addParticle(ParticleTypes.SMOKE, double6 + double11, double7 + double12, double8 + double13, 0.0, 0.0, 0.0);
        bqb.addParticle(ParticleTypes.FLAME, double6 + double11, double7 + double12, double8 + double13, 0.0, 0.0, 0.0);
    }
}
