package net.minecraft.world.level.block;

import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.Difficulty;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.world.phys.shapes.CollisionContext;
import java.util.Random;
import net.minecraft.world.level.Level;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.effect.MobEffect;

public class WitherRoseBlock extends FlowerBlock {
    public WitherRoseBlock(final MobEffect aki, final Properties c) {
        super(aki, 8, c);
    }
    
    @Override
    protected boolean mayPlaceOn(final BlockState byj, final BlockGetter bjg, final BlockPos fk) {
        final Block bph5 = byj.getBlock();
        return super.mayPlaceOn(byj, bjg, fk) || bph5 == Blocks.NETHERRACK || bph5 == Blocks.SOUL_SAND;
    }
    
    @Override
    public void animateTick(final BlockState byj, final Level bjw, final BlockPos fk, final Random random) {
        final VoxelShape cwf6 = this.getShape(byj, bjw, fk, CollisionContext.empty());
        final Vec3 cvl7 = cwf6.bounds().getCenter();
        final double double8 = fk.getX() + cvl7.x;
        final double double9 = fk.getZ() + cvl7.z;
        for (int integer12 = 0; integer12 < 3; ++integer12) {
            if (random.nextBoolean()) {
                bjw.addParticle(ParticleTypes.SMOKE, double8 + random.nextFloat() / 5.0f, fk.getY() + (0.5 - random.nextFloat()), double9 + random.nextFloat() / 5.0f, 0.0, 0.0, 0.0);
            }
        }
    }
    
    @Override
    public void entityInside(final BlockState byj, final Level bjw, final BlockPos fk, final Entity akq) {
        if (bjw.isClientSide || bjw.getDifficulty() == Difficulty.PEACEFUL) {
            return;
        }
        if (akq instanceof LivingEntity) {
            final LivingEntity akz6 = (LivingEntity)akq;
            if (!akz6.isInvulnerableTo(DamageSource.WITHER)) {
                akz6.addEffect(new MobEffectInstance(MobEffects.WITHER, 40));
            }
        }
    }
}
