MegaJungleFoliagePlacer .java

net.minecraft.world.level.levelgen.feature.foliageplacers.MegaJungleFoliagePlacer (class, 57 lines): members: shouldSkipLocation, foliageAttachment, tree.

net.minecraft.world.level.levelgen.feature.foliageplacersclass57 linescommonextends FoliagePlacer2.1 KB

API Surface (4)

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)
int foliageHeight(final RandomSource random, final int treeHeight, final TreeFeature tree)
boolean shouldSkipLocation(final RandomSource random, final int dx, final int y, final int dz, final int currentRadius, final boolean doubleTrunk)

Fields & Constants (10)

CODEC
height
level
foliageSetter
random
tree
treeHeight
foliageAttachment
foliageHeight
leafRadius

String literals (1)

"height"

Code Graph: Dependencies (6)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

MegaJungleFoliagePlacer.java57 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.levelgen.feature.foliageplacers;
2
3
import com.mojang.serialization.Codec;
4
import com.mojang.serialization.MapCodec;
5
import com.mojang.serialization.codecs.RecordCodecBuilder;
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 MegaJungleFoliagePlacer extends FoliagePlacer {
12
	public static final MapCodec<MegaJungleFoliagePlacer> CODEC = RecordCodecBuilder.mapCodec(
13
		i -> foliagePlacerParts(i).and(Codec.intRange(0, 16).fieldOf("height").forGetter(p -> p.height)).apply(i, MegaJungleFoliagePlacer::new)
14
	);
15
	protected final int height;
16
17
	public MegaJungleFoliagePlacer(final IntProvider radius, final IntProvider offset, final int height) {
18
		super(radius, offset);
19
		this.height = height;
20
	}
21
22
	@Override
23
	protected FoliagePlacerType<?> type() {
24
		return FoliagePlacerType.MEGA_JUNGLE_FOLIAGE_PLACER;
25
	}
26
27
	@Override
28
	protected void createFoliage(
29
		final WorldGenLevel level,
30
		final FoliagePlacer.FoliageSetter foliageSetter,
31
		final RandomSource random,
32
		final TreeFeature tree,
33
		final int treeHeight,
34
		final FoliagePlacer.FoliageAttachment foliageAttachment,
35
		final int foliageHeight,
36
		final int leafRadius,
37
		final int offset
38
	) {
39
		int leafHeight = (foliageAttachment.doubleTrunk() ? foliageHeight : 1 + random.nextInt(2)) + foliageAttachment.foliageHeightOffset();
40
41
		for (int yo = offset; yo >= offset - leafHeight; yo--) {
42
			int currentRadius = leafRadius + foliageAttachment.radiusOffsetXZ() + 1 - yo;
43
			this.placeLeavesRow(level, foliageSetter, random, tree, foliageAttachment.pos(), currentRadius, yo, foliageAttachment.doubleTrunk());
44
		}
45
	}
46
47
	@Override
48
	public int foliageHeight(final RandomSource random, final int treeHeight, final TreeFeature tree) {
49
		return this.height;
50
	}
51
52
	@Override
53
	protected boolean shouldSkipLocation(final RandomSource random, final int dx, final int y, final int dz, final int currentRadius, final boolean doubleTrunk) {
54
		return dx + dz >= 7 ? true : dx * dx + dz * dz > currentRadius * currentRadius;
55
	}
56
}
57

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