package net.minecraft.world.level.block;

import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.core.Direction;
import java.util.Random;
import net.minecraft.world.entity.player.Player;
import net.minecraft.sounds.SoundSource;
import net.minecraft.sounds.SoundEvents;
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.state.BlockBehaviour;

public class WetSpongeBlock extends Block {
    protected WetSpongeBlock(final Properties c) {
        super(c);
    }
    
    @Override
    public void onPlace(final BlockState cfj1, final Level bqb, final BlockPos fu, final BlockState cfj4, final boolean boolean5) {
        if (bqb.dimensionType().ultraWarm()) {
            bqb.setBlock(fu, Blocks.SPONGE.defaultBlockState(), 3);
            bqb.levelEvent(2009, fu, 0);
            bqb.playSound(null, fu, SoundEvents.FIRE_EXTINGUISH, SoundSource.BLOCKS, 1.0f, (1.0f + bqb.getRandom().nextFloat() * 0.2f) * 0.7f);
        }
    }
    
    @Override
    public void animateTick(final BlockState cfj, final Level bqb, final BlockPos fu, final Random random) {
        final Direction fz6 = Direction.getRandom(random);
        if (fz6 == Direction.UP) {
            return;
        }
        final BlockPos fu2 = fu.relative(fz6);
        final BlockState cfj2 = bqb.getBlockState(fu2);
        if (cfj.canOcclude() && cfj2.isFaceSturdy(bqb, fu2, fz6.getOpposite())) {
            return;
        }
        double double9 = fu.getX();
        double double10 = fu.getY();
        double double11 = fu.getZ();
        if (fz6 == Direction.DOWN) {
            double10 -= 0.05;
            double9 += random.nextDouble();
            double11 += random.nextDouble();
        }
        else {
            double10 += random.nextDouble() * 0.8;
            if (fz6.getAxis() == Direction.Axis.X) {
                double11 += random.nextDouble();
                if (fz6 == Direction.EAST) {
                    double9 += 1.1;
                }
                else {
                    double9 += 0.05;
                }
            }
            else {
                double9 += random.nextDouble();
                if (fz6 == Direction.SOUTH) {
                    double11 += 1.1;
                }
                else {
                    double11 += 0.05;
                }
            }
        }
        bqb.addParticle(ParticleTypes.DRIPPING_WATER, double9, double10, double11, 0.0, 0.0, 0.0);
    }
}
