WeightedListHeight .java

net.minecraft.world.level.levelgen.heightproviders.WeightedListHeight (class): members: distribution, sample, getType, CODEC. strings: "distribution".

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

API Surface (2)

int sample(final RandomSource random, final WorldGenerationContext heightAccessor)
HeightProviderType<?> getType()

Fields & Constants (2)

CODEC
distribution

String literals (1)

"distribution"

Code Graph: Dependencies (5)

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

Full Source

WeightedListHeight.java29 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.levelgen.heightproviders;
2
3
import com.mojang.serialization.MapCodec;
4
import com.mojang.serialization.codecs.RecordCodecBuilder;
5
import net.minecraft.util.RandomSource;
6
import net.minecraft.util.random.WeightedList;
7
import net.minecraft.world.level.levelgen.WorldGenerationContext;
8
9
public class WeightedListHeight extends HeightProvider {
10
	public static final MapCodec<WeightedListHeight> CODEC = RecordCodecBuilder.mapCodec(
11
		i -> i.group(WeightedList.nonEmptyCodec(HeightProvider.CODEC).fieldOf("distribution").forGetter(c -> c.distribution)).apply(i, WeightedListHeight::new)
12
	);
13
	private final WeightedList<HeightProvider> distribution;
14
15
	public WeightedListHeight(final WeightedList<HeightProvider> distribution) {
16
		this.distribution = distribution;
17
	}
18
19
	@Override
20
	public int sample(final RandomSource random, final WorldGenerationContext heightAccessor) {
21
		return this.distribution.getRandomOrThrow(random).sample(random, heightAccessor);
22
	}
23
24
	@Override
25
	public HeightProviderType<?> getType() {
26
		return HeightProviderType.WEIGHTED_LIST;
27
	}
28
}
29

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