ConstantHeight .java

net.minecraft.world.level.levelgen.heightproviders.ConstantHeight (class): members: ZERO, sample, getValue, value, getType, CODEC. imports: VerticalAnchor.

net.minecraft.world.level.levelgen.heightprovidersclass40 linescommonextends HeightProvider1.1 KB

API Surface (5)

ConstantHeight of(final VerticalAnchor value)
VerticalAnchor getValue()
int sample(final RandomSource random, final WorldGenerationContext context)
HeightProviderType<?> getType()
String toString()

Fields & Constants (3)

ZERO
CODEC
value

Code Graph: Dependencies (5)

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

Full Source

ConstantHeight.java40 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.levelgen.heightproviders;
2
3
import com.mojang.serialization.MapCodec;
4
import net.minecraft.util.RandomSource;
5
import net.minecraft.world.level.levelgen.VerticalAnchor;
6
import net.minecraft.world.level.levelgen.WorldGenerationContext;
7
8
public class ConstantHeight extends HeightProvider {
9
	public static final ConstantHeight ZERO = new ConstantHeight(VerticalAnchor.absolute(0));
10
	public static final MapCodec<ConstantHeight> CODEC = VerticalAnchor.CODEC.fieldOf("value").xmap(ConstantHeight::new, ConstantHeight::getValue);
11
	private final VerticalAnchor value;
12
13
	public static ConstantHeight of(final VerticalAnchor value) {
14
		return new ConstantHeight(value);
15
	}
16
17
	private ConstantHeight(final VerticalAnchor value) {
18
		this.value = value;
19
	}
20
21
	public VerticalAnchor getValue() {
22
		return this.value;
23
	}
24
25
	@Override
26
	public int sample(final RandomSource random, final WorldGenerationContext context) {
27
		return this.value.resolveY(context);
28
	}
29
30
	@Override
31
	public HeightProviderType<?> getType() {
32
		return HeightProviderType.CONSTANT;
33
	}
34
35
	@Override
36
	public String toString() {
37
		return this.value.toString();
38
	}
39
}
40

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