BushFoliagePlacer .java

net.minecraft.world.level.levelgen.feature.foliageplacers.BushFoliagePlacer (class): members: shouldSkipLocation, foliageAttachment, createFoliage, tree.

net.minecraft.world.level.levelgen.feature.foliageplacersclass47 linescommonextends BlobFoliagePlacer1.7 KB

API Surface (3)

FoliagePlacerType<?> type()
void createFoliage(final WorldGenLevel level, final FoliagePlacer.FoliageSetter foliageSetter, final RandomSource random, final TreeFeature tree, final int treeHeight, final FoliagePlacer.FoliageAttachment foliageAttachment, final int foliageHeight, final int leafRadius, final int offset)
boolean shouldSkipLocation(final RandomSource random, final int dx, final int y, final int dz, final int currentRadius, final boolean doubleTrunk)

Fields & Constants (9)

CODEC
level
foliageSetter
random
tree
treeHeight
foliageAttachment
foliageHeight
leafRadius

Full Source

BushFoliagePlacer.java47 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.levelgen.feature.foliageplacers;
2
3
import com.mojang.serialization.MapCodec;
4
import com.mojang.serialization.codecs.RecordCodecBuilder;
5
import net.minecraft.util.RandomSource;
6
import net.minecraft.util.valueproviders.IntProvider;
7
import net.minecraft.world.level.WorldGenLevel;
8
import net.minecraft.world.level.levelgen.feature.TreeFeature;
9
10
public class BushFoliagePlacer extends BlobFoliagePlacer {
11
	public static final MapCodec<BushFoliagePlacer> CODEC = RecordCodecBuilder.mapCodec(i -> blobParts(i).apply(i, BushFoliagePlacer::new));
12
13
	public BushFoliagePlacer(final IntProvider radius, final IntProvider offset, final int height) {
14
		super(radius, offset, height);
15
	}
16
17
	@Override
18
	protected FoliagePlacerType<?> type() {
19
		return FoliagePlacerType.BUSH_FOLIAGE_PLACER;
20
	}
21
22
	@Override
23
	protected void createFoliage(
24
		final WorldGenLevel level,
25
		final FoliagePlacer.FoliageSetter foliageSetter,
26
		final RandomSource random,
27
		final TreeFeature tree,
28
		final int treeHeight,
29
		final FoliagePlacer.FoliageAttachment foliageAttachment,
30
		final int foliageHeight,
31
		final int leafRadius,
32
		final int offset
33
	) {
34
		int foliageHeightWithOffset = foliageHeight + foliageAttachment.foliageHeightOffset();
35
36
		for (int yo = offset; yo >= offset - foliageHeightWithOffset; yo--) {
37
			int currentRadius = leafRadius + foliageAttachment.radiusOffsetXZ() - 1 - yo;
38
			this.placeLeavesRow(level, foliageSetter, random, tree, foliageAttachment.pos(), currentRadius, yo, foliageAttachment.doubleTrunk());
39
		}
40
	}
41
42
	@Override
43
	protected boolean shouldSkipLocation(final RandomSource random, final int dx, final int y, final int dz, final int currentRadius, final boolean doubleTrunk) {
44
		return dx == currentRadius && dz == currentRadius && random.nextInt(2) == 0;
45
	}
46
}
47

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