minecraft-src/net/minecraft/world/level/block/CherryLeavesBlock.java
2025-07-04 01:41:11 +03:00

36 lines
1.2 KiB
Java

package net.minecraft.world.level.block;
import com.mojang.serialization.MapCodec;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.util.ParticleUtils;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
public class CherryLeavesBlock extends LeavesBlock {
public static final MapCodec<CherryLeavesBlock> CODEC = simpleCodec(CherryLeavesBlock::new);
@Override
public MapCodec<CherryLeavesBlock> codec() {
return CODEC;
}
public CherryLeavesBlock(BlockBehaviour.Properties properties) {
super(properties);
}
@Override
public void animateTick(BlockState state, Level level, BlockPos pos, RandomSource random) {
super.animateTick(state, level, pos, random);
if (random.nextInt(10) == 0) {
BlockPos blockPos = pos.below();
BlockState blockState = level.getBlockState(blockPos);
if (!isFaceFull(blockState.getCollisionShape(level, blockPos), Direction.UP)) {
ParticleUtils.spawnParticleBelow(level, pos, random, ParticleTypes.CHERRY_LEAVES);
}
}
}
}