package net.minecraft.commands.arguments; import com.mojang.brigadier.context.CommandContext; import com.mojang.serialization.Codec; import java.util.Arrays; import java.util.Locale; import net.minecraft.commands.CommandSourceStack; import net.minecraft.util.StringRepresentable; import net.minecraft.world.level.levelgen.Heightmap; public class HeightmapTypeArgument extends StringRepresentableArgument { private static final Codec LOWER_CASE_CODEC = StringRepresentable.fromEnumWithMapping( HeightmapTypeArgument::keptTypes, s -> s.toLowerCase(Locale.ROOT) ); private static Heightmap.Types[] keptTypes() { return (Heightmap.Types[])Arrays.stream(Heightmap.Types.values()).filter(Heightmap.Types::keepAfterWorldgen).toArray(Heightmap.Types[]::new); } private HeightmapTypeArgument() { super(LOWER_CASE_CODEC, HeightmapTypeArgument::keptTypes); } public static HeightmapTypeArgument heightmap() { return new HeightmapTypeArgument(); } public static Heightmap.Types getHeightmap(final CommandContext context, final String name) { return context.getArgument(name, Heightmap.Types.class); } @Override protected String convertId(final String id) { return id.toLowerCase(Locale.ROOT); } }