FallingParticlesLeavesBlock .java

net.minecraft.world.level.block.FallingParticlesLeavesBlock (class, 39 lines): members: leafParticleChance, ambientLeavesBlockSoundPlayer, animateTick.

net.minecraft.world.level.blockclass39 linescommonextends LeavesBlock1.5 KB

API Surface (1)

void animateTick(final BlockState state, final Level level, final BlockPos pos, final RandomSource random)

Fields & Constants (2)

leafParticleChance
ambientLeavesBlockSoundPlayer

Full Source

FallingParticlesLeavesBlock.java39 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.block;
2
3
import net.minecraft.core.BlockPos;
4
import net.minecraft.core.Direction;
5
import net.minecraft.util.RandomSource;
6
import net.minecraft.world.level.Level;
7
import net.minecraft.world.level.block.sounds.AmbientLeavesBlockSoundPlayer;
8
import net.minecraft.world.level.block.state.BlockBehaviour;
9
import net.minecraft.world.level.block.state.BlockState;
10
11
public abstract class FallingParticlesLeavesBlock extends LeavesBlock {
12
	protected final float leafParticleChance;
13
14
	public FallingParticlesLeavesBlock(
15
		final float leafParticleChance, final AmbientLeavesBlockSoundPlayer ambientLeavesBlockSoundPlayer, final BlockBehaviour.Properties properties
16
	) {
17
		super(ambientLeavesBlockSoundPlayer, properties);
18
		this.leafParticleChance = leafParticleChance;
19
	}
20
21
	@Override
22
	public void animateTick(final BlockState state, final Level level, final BlockPos pos, final RandomSource random) {
23
		super.animateTick(state, level, pos, random);
24
		this.makeFallingLeavesParticles(level, pos, random);
25
	}
26
27
	private void makeFallingLeavesParticles(final Level level, final BlockPos pos, final RandomSource random) {
28
		BlockPos below = pos.below();
29
		BlockState belowState = level.getBlockState(below);
30
		if (!(random.nextFloat() >= this.leafParticleChance)) {
31
			if (!isFaceFull(belowState.getCollisionShape(level, below), Direction.UP)) {
32
				this.spawnFallingLeavesParticle(level, pos, random);
33
			}
34
		}
35
	}
36
37
	protected abstract void spawnFallingLeavesParticle(Level level, BlockPos pos, RandomSource random);
38
}
39

Decompiled Minecraft 26.3 source of FallingParticlesLeavesBlock (net/minecraft/world/level/block/FallingParticlesLeavesBlock.java) with Mojang official mappings, stored verbatim on the site.