HeightProvider .java

net.minecraft.world.level.levelgen.heightproviders.HeightProvider (class): members: CONSTANT_OR_DISPATCH_CODEC, sample, getType, CODEC. imports: Either.

net.minecraft.world.level.levelgen.heightprovidersclass23 linescommon1.1 KB

API Surface (0)

No public/protected methods detected (fields or constants only).

Fields & Constants (2)

CONSTANT_OR_DISPATCH_CODEC
CODEC

Code Graph: Dependencies (5)

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

Full Source

HeightProvider.java23 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.levelgen.heightproviders;
2
3
import com.mojang.datafixers.util.Either;
4
import com.mojang.serialization.Codec;
5
import net.minecraft.core.registries.BuiltInRegistries;
6
import net.minecraft.util.RandomSource;
7
import net.minecraft.world.level.levelgen.VerticalAnchor;
8
import net.minecraft.world.level.levelgen.WorldGenerationContext;
9
10
public abstract class HeightProvider {
11
	private static final Codec<Either<VerticalAnchor, HeightProvider>> CONSTANT_OR_DISPATCH_CODEC = Codec.either(
12
		VerticalAnchor.CODEC, BuiltInRegistries.HEIGHT_PROVIDER_TYPE.byNameCodec().dispatch(HeightProvider::getType, HeightProviderType::codec)
13
	);
14
	public static final Codec<HeightProvider> CODEC = CONSTANT_OR_DISPATCH_CODEC.xmap(
15
		either -> either.map(ConstantHeight::of, f -> (HeightProvider)f),
16
		f -> f.getType() == HeightProviderType.CONSTANT ? Either.left(((ConstantHeight)f).getValue()) : Either.right(f)
17
	);
18
19
	public abstract int sample(final RandomSource random, final WorldGenerationContext heightAccessor);
20
21
	public abstract HeightProviderType<?> getType();
22
}
23

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