FancyFoliagePlacer .java

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

net.minecraft.world.level.levelgen.feature.foliageplacersclass46 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

FancyFoliagePlacer.java46 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.Mth;
6
import net.minecraft.util.RandomSource;
7
import net.minecraft.util.valueproviders.IntProvider;
8
import net.minecraft.world.level.WorldGenLevel;
9
import net.minecraft.world.level.levelgen.feature.TreeFeature;
10
11
public class FancyFoliagePlacer extends BlobFoliagePlacer {
12
	public static final MapCodec<FancyFoliagePlacer> CODEC = RecordCodecBuilder.mapCodec(i -> blobParts(i).apply(i, FancyFoliagePlacer::new));
13
14
	public FancyFoliagePlacer(final IntProvider radius, final IntProvider offset, final int height) {
15
		super(radius, offset, height);
16
	}
17
18
	@Override
19
	protected FoliagePlacerType<?> type() {
20
		return FoliagePlacerType.FANCY_FOLIAGE_PLACER;
21
	}
22
23
	@Override
24
	protected void createFoliage(
25
		final WorldGenLevel level,
26
		final FoliagePlacer.FoliageSetter foliageSetter,
27
		final RandomSource random,
28
		final TreeFeature tree,
29
		final int treeHeight,
30
		final FoliagePlacer.FoliageAttachment foliageAttachment,
31
		final int foliageHeight,
32
		final int leafRadius,
33
		final int offset
34
	) {
35
		for (int yo = offset; yo >= offset - foliageHeight; yo--) {
36
			int currentRadius = leafRadius + (yo != offset && yo != offset - foliageHeight ? 1 : 0);
37
			this.placeLeavesRow(level, foliageSetter, random, tree, foliageAttachment.pos(), currentRadius, yo, foliageAttachment.doubleTrunk());
38
		}
39
	}
40
41
	@Override
42
	protected boolean shouldSkipLocation(final RandomSource random, final int dx, final int y, final int dz, final int currentRadius, final boolean doubleTrunk) {
43
		return Mth.square(dx + 0.5F) + Mth.square(dz + 0.5F) > currentRadius * currentRadius;
44
	}
45
}
46

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