DarkOakFoliagePlacer .java

net.minecraft.world.level.levelgen.feature.foliageplacers.DarkOakFoliagePlacer (class, 73 lines): members: shouldSkipLocationSigned, currentRadius, tree.

net.minecraft.world.level.levelgen.feature.foliageplacersclass73 linescommonextends FoliagePlacer2.8 KB

API Surface (5)

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

Fields & Constants (10)

CODEC
level
foliageSetter
random
tree
treeHeight
foliageAttachment
foliageHeight
leafRadius
currentRadius

Full Source

DarkOakFoliagePlacer.java73 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.core.BlockPos;
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 DarkOakFoliagePlacer extends FoliagePlacer {
12
	public static final MapCodec<DarkOakFoliagePlacer> CODEC = RecordCodecBuilder.mapCodec(i -> foliagePlacerParts(i).apply(i, DarkOakFoliagePlacer::new));
13
14
	public DarkOakFoliagePlacer(final IntProvider radius, final IntProvider offset) {
15
		super(radius, offset);
16
	}
17
18
	@Override
19
	protected FoliagePlacerType<?> type() {
20
		return FoliagePlacerType.DARK_OAK_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
		BlockPos pos = foliageAttachment.pos().above(offset);
36
		boolean doubleTrunk = foliageAttachment.doubleTrunk();
37
		if (doubleTrunk) {
38
			this.placeLeavesRow(level, foliageSetter, random, tree, pos, leafRadius + 2, -1, doubleTrunk);
39
			this.placeLeavesRow(level, foliageSetter, random, tree, pos, leafRadius + 3, 0, doubleTrunk);
40
			this.placeLeavesRow(level, foliageSetter, random, tree, pos, leafRadius + 2, 1, doubleTrunk);
41
			if (random.nextBoolean()) {
42
				this.placeLeavesRow(level, foliageSetter, random, tree, pos, leafRadius, 2, doubleTrunk);
43
			}
44
		} else {
45
			this.placeLeavesRow(level, foliageSetter, random, tree, pos, leafRadius + 2, -1, doubleTrunk);
46
			this.placeLeavesRow(level, foliageSetter, random, tree, pos, leafRadius + 1, 0, doubleTrunk);
47
		}
48
	}
49
50
	@Override
51
	public int foliageHeight(final RandomSource random, final int treeHeight, final TreeFeature tree) {
52
		return 4;
53
	}
54
55
	@Override
56
	protected boolean shouldSkipLocationSigned(
57
		final RandomSource random, final int dx, final int y, final int dz, final int currentRadius, final boolean doubleTrunk
58
	) {
59
		return y != 0 || !doubleTrunk || dx != -currentRadius && dx < currentRadius || dz != -currentRadius && dz < currentRadius
60
			? super.shouldSkipLocationSigned(random, dx, y, dz, currentRadius, doubleTrunk)
61
			: true;
62
	}
63
64
	@Override
65
	protected boolean shouldSkipLocation(final RandomSource random, final int dx, final int y, final int dz, final int currentRadius, final boolean doubleTrunk) {
66
		if (y == -1 && !doubleTrunk) {
67
			return dx == currentRadius && dz == currentRadius;
68
		} else {
69
			return y == 1 ? dx + dz > currentRadius * 2 - 2 : false;
70
		}
71
	}
72
}
73

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