/* * Decompiled with CFR 0.152. * * Could not load the following classes: * com.mojang.datafixers.kinds.App * com.mojang.datafixers.kinds.Applicative * com.mojang.serialization.MapCodec * com.mojang.serialization.codecs.RecordCodecBuilder */ package net.minecraft.world.level.block; import com.mojang.datafixers.kinds.App; import com.mojang.datafixers.kinds.Applicative; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.RandomSource; import net.minecraft.world.Difficulty; import net.minecraft.world.effect.MobEffect; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.InsideBlockEffectApplier; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.component.SuspiciousStewEffects; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.FlowerBlock; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; public class WitherRoseBlock extends FlowerBlock { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(i -> i.group((App)EFFECTS_FIELD.forGetter(FlowerBlock::getSuspiciousEffects), WitherRoseBlock.propertiesCodec()).apply((Applicative)i, WitherRoseBlock::new)); public MapCodec codec() { return CODEC; } public WitherRoseBlock(Holder mobEffect, float effectSeconds, BlockBehaviour.Properties properties) { this(WitherRoseBlock.makeEffectList(mobEffect, effectSeconds), properties); } public WitherRoseBlock(SuspiciousStewEffects suspiciousStewEffects, BlockBehaviour.Properties properties) { super(suspiciousStewEffects, properties); } @Override protected boolean mayPlaceOn(BlockState state, BlockGetter level, BlockPos pos) { return super.mayPlaceOn(state, level, pos) || state.is(Blocks.NETHERRACK) || state.is(Blocks.SOUL_SAND) || state.is(Blocks.SOUL_SOIL); } @Override public void animateTick(BlockState state, Level level, BlockPos pos, RandomSource random) { VoxelShape shape = this.getShape(state, level, pos, CollisionContext.empty()); Vec3 shapeCenter = shape.bounds().getCenter(); double x = (double)pos.getX() + shapeCenter.x; double z = (double)pos.getZ() + shapeCenter.z; for (int i = 0; i < 3; ++i) { if (!random.nextBoolean()) continue; level.addParticle(ParticleTypes.SMOKE, x + random.nextDouble() / 5.0, (double)pos.getY() + (0.5 - random.nextDouble()), z + random.nextDouble() / 5.0, 0.0, 0.0, 0.0); } } @Override protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier, boolean isPrecise) { if (level instanceof ServerLevel) { LivingEntity livingEntity; ServerLevel serverLevel = (ServerLevel)level; if (level.getDifficulty() != Difficulty.PEACEFUL && entity instanceof LivingEntity && !(livingEntity = (LivingEntity)entity).isInvulnerableTo(serverLevel, level.damageSources().wither())) { livingEntity.addEffect(this.getBeeInteractionEffect()); } } } @Override public MobEffectInstance getBeeInteractionEffect() { return new MobEffectInstance(MobEffects.WITHER, 40); } }