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.level.block.state.BlockBehaviour;
import net.minecraft.world.effect.MobEffect;

public class WitherRoseBlock extends FlowerBlock {
    public WitherRoseBlock(final MobEffect aoe, final Properties c) {
        super(aoe, 8, c);
    }
    
    @Override
    protected boolean mayPlaceOn(final BlockState cfj, final BlockGetter bpg, final BlockPos fu) {
        return super.mayPlaceOn(cfj, bpg, fu) || cfj.is(Blocks.NETHERRACK) || cfj.is(Blocks.SOUL_SAND) || cfj.is(Blocks.SOUL_SOIL);
    }
    
    @Override
    public void animateTick(final BlockState cfj, final Level bqb, final BlockPos fu, final Random random) {
        final VoxelShape dfg6 = this.getShape(cfj, bqb, fu, CollisionContext.empty());
        final Vec3 dem7 = dfg6.bounds().getCenter();
        final double double8 = fu.getX() + dem7.x;
        final double double9 = fu.getZ() + dem7.z;
        for (int integer12 = 0; integer12 < 3; ++integer12) {
            if (random.nextBoolean()) {
                bqb.addParticle(ParticleTypes.SMOKE, double8 + random.nextDouble() / 5.0, fu.getY() + (0.5 - random.nextDouble()), double9 + random.nextDouble() / 5.0, 0.0, 0.0, 0.0);
            }
        }
    }
    
    @Override
    public void entityInside(final BlockState cfj, final Level bqb, final BlockPos fu, final Entity aom) {
        if (bqb.isClientSide || bqb.getDifficulty() == Difficulty.PEACEFUL) {
            return;
        }
        if (aom instanceof LivingEntity) {
            final LivingEntity aoy6 = (LivingEntity)aom;
            if (!aoy6.isInvulnerableTo(DamageSource.WITHER)) {
                aoy6.addEffect(new MobEffectInstance(MobEffects.WITHER, 40));
            }
        }
    }
}
