SimpleDensityFunction .java

net.minecraft.world.level.levelgen.densityfunction.generator.SimpleDensityFunction (enum, 64 lines): members: BLEND_ALPHA, BLEND_OFFSET, BEARDIFIER, range.

net.minecraft.world.level.levelgen.densityfunction.generatorenum64 linescommon1.9 KB

Implements

API Surface (5)

DensitySampler compileSampler(final DensityFunction.CompileContext context)
DensityFunction rewriteChildren(final DfRewriteRule rule)
Interval range()
String id()
MapCodec<SimpleDensityFunction> codec()

Fields & Constants (2)

id
codec

String literals (3)

"blend_alpha"
"blend_offset"
"beardifier"

Full Source

SimpleDensityFunction.java64 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.levelgen.densityfunction.generator;
2
3
import com.mojang.serialization.MapCodec;
4
import net.minecraft.util.Interval;
5
import net.minecraft.world.level.levelgen.Beardifier;
6
import net.minecraft.world.level.levelgen.blending.Blender;
7
import net.minecraft.world.level.levelgen.densityfunction.ContextBoundSampler;
8
import net.minecraft.world.level.levelgen.densityfunction.DensityFunction;
9
import net.minecraft.world.level.levelgen.densityfunction.DensitySampler;
10
import net.minecraft.world.level.levelgen.densityfunction.DfRewriteRule;
11
12
public enum SimpleDensityFunction implements DensityFunction {
13
	BLEND_ALPHA("blend_alpha"),
14
	BLEND_OFFSET("blend_offset"),
15
	BEARDIFIER("beardifier");
16
17
	private final String id;
18
	private final MapCodec<SimpleDensityFunction> codec = MapCodec.unit(this);
19
20
	SimpleDensityFunction(final String id) {
21
		this.id = id;
22
	}
23
24
	@Override
25
	public DensitySampler compileSampler(final DensityFunction.CompileContext context) {
26
		return switch (this) {
27
			case BLEND_ALPHA -> new ContextBoundSampler(Blender.ALPHA_KEY, new ConstantFunction.Sampler(1.0F));
28
			case BLEND_OFFSET -> new ContextBoundSampler(Blender.OFFSET_KEY, new ConstantFunction.Sampler(0.0F));
29
			case BEARDIFIER -> new ContextBoundSampler(Beardifier.CONTEXT_KEY, new ConstantFunction.Sampler(0.0F));
30
		};
31
	}
32
33
	@Override
34
	public DensityFunction rewriteChildren(final DfRewriteRule rule) {
35
		return this;
36
	}
37
38
	@Override
39
	public Interval range() {
40
		return switch (this) {
41
			case BLEND_ALPHA -> Interval.of(0.0F, 1.0F);
42
			case BLEND_OFFSET -> Interval.INFINITE;
43
			case BEARDIFIER -> Beardifier.RANGE;
44
		};
45
	}
46
47
	@Override
48
	public @DensityFunction.Axes int domainAxes() {
49
		return switch (this) {
50
			case BLEND_ALPHA, BLEND_OFFSET -> 5;
51
			case BEARDIFIER -> 7;
52
		};
53
	}
54
55
	public String id() {
56
		return this.id;
57
	}
58
59
	@Override
60
	public MapCodec<SimpleDensityFunction> codec() {
61
		return this.codec;
62
	}
63
}
64

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