HeightmapTypeArgument .java

net.minecraft.commands.arguments.HeightmapTypeArgument (class): members: LOWER_CASE_CODEC, getHeightmap, convertId, heightmap. imports: CommandContext.

net.minecraft.commands.argumentsclass37 linescommonextends StringRepresentableArgument<Heightmap.Types>1.2 KB

API Surface (3)

HeightmapTypeArgument heightmap()
Heightmap.Types getHeightmap(final CommandContext<CommandSourceStack> context, final String name)
String convertId(final String id)

Fields & Constants (1)

LOWER_CASE_CODEC

Code Graph: Dependencies (4)

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

Full Source

HeightmapTypeArgument.java37 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.commands.arguments;
2
3
import com.mojang.brigadier.context.CommandContext;
4
import com.mojang.serialization.Codec;
5
import java.util.Arrays;
6
import java.util.Locale;
7
import net.minecraft.commands.CommandSourceStack;
8
import net.minecraft.util.StringRepresentable;
9
import net.minecraft.world.level.levelgen.Heightmap;
10
11
public class HeightmapTypeArgument extends StringRepresentableArgument<Heightmap.Types> {
12
	private static final Codec<Heightmap.Types> LOWER_CASE_CODEC = StringRepresentable.fromEnumWithMapping(
13
		HeightmapTypeArgument::keptTypes, s -> s.toLowerCase(Locale.ROOT)
14
	);
15
16
	private static Heightmap.Types[] keptTypes() {
17
		return Arrays.stream(Heightmap.Types.values()).filter(Heightmap.Types::keepAfterWorldgen).toArray(Heightmap.Types[]::new);
18
	}
19
20
	private HeightmapTypeArgument() {
21
		super(LOWER_CASE_CODEC, HeightmapTypeArgument::keptTypes);
22
	}
23
24
	public static HeightmapTypeArgument heightmap() {
25
		return new HeightmapTypeArgument();
26
	}
27
28
	public static Heightmap.Types getHeightmap(final CommandContext<CommandSourceStack> context, final String name) {
29
		return context.getArgument(name, Heightmap.Types.class);
30
	}
31
32
	@Override
33
	protected String convertId(final String id) {
34
		return id.toLowerCase(Locale.ROOT);
35
	}
36
}
37

Decompiled Minecraft 26.3 source of HeightmapTypeArgument (net/minecraft/commands/arguments/HeightmapTypeArgument.java) with Mojang official mappings, stored verbatim on the site.