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;

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