NoiseThresholdCountPlacement .java

net.minecraft.world.level.levelgen.placement.NoiseThresholdCountPlacement (record): members: noiseLevel, belowNoise, aboveNoise, count, codec, CODEC.

net.minecraft.world.level.levelgen.placementrecord35 linescommon1.4 KB

Implements

API Surface (3)

NoiseThresholdCountPlacement of(final double noiseLevel, final int belowNoise, final int aboveNoise)
int count(final RandomSource random, final BlockPos origin)
MapCodec<NoiseThresholdCountPlacement> codec()

Fields & Constants (1)

CODEC

String literals (3)

"noise_level"
"below_noise"
"above_noise"

Code Graph: Dependencies (4)

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

Full Source

NoiseThresholdCountPlacement.java35 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.levelgen.placement;
2
3
import com.mojang.serialization.Codec;
4
import com.mojang.serialization.MapCodec;
5
import com.mojang.serialization.codecs.RecordCodecBuilder;
6
import net.minecraft.core.BlockPos;
7
import net.minecraft.util.RandomSource;
8
import net.minecraft.world.level.biome.Biome;
9
10
public record NoiseThresholdCountPlacement(double noiseLevel, int belowNoise, int aboveNoise) implements RepeatingPlacement {
11
	public static final MapCodec<NoiseThresholdCountPlacement> CODEC = RecordCodecBuilder.mapCodec(
12
		i -> i.group(
13
				Codec.DOUBLE.fieldOf("noise_level").forGetter(NoiseThresholdCountPlacement::noiseLevel),
14
				Codec.INT.fieldOf("below_noise").forGetter(NoiseThresholdCountPlacement::belowNoise),
15
				Codec.INT.fieldOf("above_noise").forGetter(NoiseThresholdCountPlacement::aboveNoise)
16
			)
17
			.apply(i, NoiseThresholdCountPlacement::new)
18
	);
19
20
	public static NoiseThresholdCountPlacement of(final double noiseLevel, final int belowNoise, final int aboveNoise) {
21
		return new NoiseThresholdCountPlacement(noiseLevel, belowNoise, aboveNoise);
22
	}
23
24
	@Override
25
	public int count(final RandomSource random, final BlockPos origin) {
26
		double flowerNoise = Biome.BIOME_INFO_NOISE.get(origin.getX() / 200.0, origin.getZ() / 200.0);
27
		return flowerNoise < this.noiseLevel ? this.belowNoise : this.aboveNoise;
28
	}
29
30
	@Override
31
	public MapCodec<NoiseThresholdCountPlacement> codec() {
32
		return CODEC;
33
	}
34
}
35

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