HeightmapPlacement .java

net.minecraft.world.level.levelgen.placement.HeightmapPlacement (record): members: heightmap, onHeightmap, modify, codec, CODEC. strings: "heightmap".

net.minecraft.world.level.levelgen.placementrecord34 linescommon1.2 KB

Implements

API Surface (3)

HeightmapPlacement onHeightmap(final Heightmap.Types heightmap)
void modify(final PlacementContext context, final RandomSource random, final BlockPos origin, final Consumer<BlockPos> output)
MapCodec<HeightmapPlacement> codec()

Fields & Constants (1)

CODEC

String literals (1)

"heightmap"

Code Graph: Dependencies (5)

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

Full Source

HeightmapPlacement.java34 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.levelgen.placement;
2
3
import com.mojang.serialization.MapCodec;
4
import com.mojang.serialization.codecs.RecordCodecBuilder;
5
import java.util.function.Consumer;
6
import net.minecraft.core.BlockPos;
7
import net.minecraft.util.RandomSource;
8
import net.minecraft.world.level.levelgen.Heightmap;
9
10
public record HeightmapPlacement(Heightmap.Types heightmap) implements PlacementModifier {
11
	public static final MapCodec<HeightmapPlacement> CODEC = RecordCodecBuilder.mapCodec(
12
		i -> i.group(Heightmap.Types.CODEC.fieldOf("heightmap").forGetter(HeightmapPlacement::heightmap)).apply(i, HeightmapPlacement::new)
13
	);
14
15
	public static HeightmapPlacement onHeightmap(final Heightmap.Types heightmap) {
16
		return new HeightmapPlacement(heightmap);
17
	}
18
19
	@Override
20
	public void modify(final PlacementContext context, final RandomSource random, final BlockPos origin, final Consumer<BlockPos> output) {
21
		int x = origin.getX();
22
		int z = origin.getZ();
23
		int height = context.getHeight(this.heightmap, x, z);
24
		if (height > context.getMinY()) {
25
			output.accept(new BlockPos(x, height, z));
26
		}
27
	}
28
29
	@Override
30
	public MapCodec<HeightmapPlacement> codec() {
31
		return CODEC;
32
	}
33
}
34

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