58 lines
2.4 KiB
Java
58 lines
2.4 KiB
Java
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 akf, final Properties c) {
|
|
super(akf, 8, c);
|
|
}
|
|
|
|
@Override
|
|
protected boolean mayPlaceOn(final BlockState byg, final BlockGetter bjd, final BlockPos fk) {
|
|
final Block bpe5 = byg.getBlock();
|
|
return super.mayPlaceOn(byg, bjd, fk) || bpe5 == Blocks.NETHERRACK || bpe5 == Blocks.SOUL_SAND;
|
|
}
|
|
|
|
@Override
|
|
public void animateTick(final BlockState byg, final Level bjt, final BlockPos fk, final Random random) {
|
|
final VoxelShape cwc6 = this.getShape(byg, bjt, fk, CollisionContext.empty());
|
|
final Vec3 cvi7 = cwc6.bounds().getCenter();
|
|
final double double8 = fk.getX() + cvi7.x;
|
|
final double double9 = fk.getZ() + cvi7.z;
|
|
for (int integer12 = 0; integer12 < 3; ++integer12) {
|
|
if (random.nextBoolean()) {
|
|
bjt.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 byg, final Level bjt, final BlockPos fk, final Entity akn) {
|
|
if (bjt.isClientSide || bjt.getDifficulty() == Difficulty.PEACEFUL) {
|
|
return;
|
|
}
|
|
if (akn instanceof LivingEntity) {
|
|
final LivingEntity akw6 = (LivingEntity)akn;
|
|
if (!akw6.isInvulnerableTo(DamageSource.WITHER)) {
|
|
akw6.addEffect(new MobEffectInstance(MobEffects.WITHER, 40));
|
|
}
|
|
}
|
|
}
|
|
}
|