package net.minecraft.world.level.block;

import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.world.entity.player.Player;
import net.minecraft.sounds.SoundSource;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.tags.FluidTags;
import net.minecraft.world.level.LevelReader;
import net.minecraft.core.Direction;
import net.minecraft.world.level.LevelAccessor;
import java.util.Random;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Entity;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;

public class MagmaBlock extends Block {
    public MagmaBlock(final Properties c) {
        super(c);
    }
    
    @Override
    public void stepOn(final Level bjw, final BlockPos fk, final Entity akq) {
        if (!akq.fireImmune() && akq instanceof LivingEntity && !EnchantmentHelper.hasFrostWalker((LivingEntity)akq)) {
            akq.hurt(DamageSource.HOT_FLOOR, 1.0f);
        }
        super.stepOn(bjw, fk, akq);
    }
    
    @Override
    public boolean emissiveRendering(final BlockState byj) {
        return true;
    }
    
    @Override
    public void tick(final BlockState byj, final ServerLevel xd, final BlockPos fk, final Random random) {
        BubbleColumnBlock.growColumn(xd, fk.above(), true);
    }
    
    @Override
    public BlockState updateShape(final BlockState byj1, final Direction fp, final BlockState byj3, final LevelAccessor bjx, final BlockPos fk5, final BlockPos fk6) {
        if (fp == Direction.UP && byj3.getBlock() == Blocks.WATER) {
            bjx.getBlockTicks().scheduleTick(fk5, this, this.getTickDelay(bjx));
        }
        return super.updateShape(byj1, fp, byj3, bjx, fk5, fk6);
    }
    
    @Override
    public void randomTick(final BlockState byj, final ServerLevel xd, final BlockPos fk, final Random random) {
        final BlockPos fk2 = fk.above();
        if (xd.getFluidState(fk).is(FluidTags.WATER)) {
            xd.playSound(null, fk, SoundEvents.FIRE_EXTINGUISH, SoundSource.BLOCKS, 0.5f, 2.6f + (xd.random.nextFloat() - xd.random.nextFloat()) * 0.8f);
            xd.<SimpleParticleType>sendParticles(ParticleTypes.LARGE_SMOKE, fk2.getX() + 0.5, fk2.getY() + 0.25, fk2.getZ() + 0.5, 8, 0.5, 0.25, 0.5, 0.0);
        }
    }
    
    @Override
    public int getTickDelay(final LevelReader bjz) {
        return 20;
    }
    
    @Override
    public void onPlace(final BlockState byj1, final Level bjw, final BlockPos fk, final BlockState byj4, final boolean boolean5) {
        bjw.getBlockTicks().scheduleTick(fk, this, this.getTickDelay(bjw));
    }
    
    @Override
    public boolean isValidSpawn(final BlockState byj, final BlockGetter bjg, final BlockPos fk, final EntityType<?> aku) {
        return aku.fireImmune();
    }
    
    @Override
    public boolean hasPostProcess(final BlockState byj, final BlockGetter bjg, final BlockPos fk) {
        return true;
    }
}
