HeightmapTypeArgument.java

net.minecraft.commands.arguments.HeightmapTypeArgument

信息

  • 全限定名:net.minecraft.commands.arguments.HeightmapTypeArgument
  • 类型:public class
  • 包:net.minecraft.commands.arguments
  • 源码路径:src/main/java/net/minecraft/commands/arguments/HeightmapTypeArgument.java
  • 起始行号:L11
  • 继承:StringRepresentableArgument<Heightmap.Types>
  • 职责:

    TODO

字段/常量

  • LOWER_CASE_CODEC
    • 类型: Codec<Heightmap.Types>
    • 修饰符: private static final
    • 源码定位: L12
    • 说明:

      TODO

内部类/嵌套类型

构造器

private HeightmapTypeArgument() @ L20

  • 构造器名:HeightmapTypeArgument
  • 源码定位:L20
  • 修饰符:private

参数:

说明:

TODO

方法

下面的方法块按源码顺序生成。

private static Heightmap.Types[] keptTypes() @ L16

  • 方法名:keptTypes
  • 源码定位:L16
  • 返回类型:Heightmap.Types[]
  • 修饰符:private static

参数:

说明:

TODO

public static HeightmapTypeArgument heightmap() @ L24

  • 方法名:heightmap
  • 源码定位:L24
  • 返回类型:HeightmapTypeArgument
  • 修饰符:public static

参数:

说明:

TODO

public static Heightmap.Types getHeightmap(CommandContext<CommandSourceStack> context, String name) @ L28

  • 方法名:getHeightmap
  • 源码定位:L28
  • 返回类型:Heightmap.Types
  • 修饰符:public static

参数:

  • context: CommandContext
  • name: String

说明:

TODO

protected String convertId(String id) @ L32

  • 方法名:convertId
  • 源码定位:L32
  • 返回类型:String
  • 修饰符:protected

参数:

  • id: String

说明:

TODO

代码

public class HeightmapTypeArgument extends StringRepresentableArgument<Heightmap.Types> {
    private static final Codec<Heightmap.Types> LOWER_CASE_CODEC = StringRepresentable.fromEnumWithMapping(
        HeightmapTypeArgument::keptTypes, s -> s.toLowerCase(Locale.ROOT)
    );
 
    private static Heightmap.Types[] keptTypes() {
        return 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(CommandContext<CommandSourceStack> context, String name) {
        return context.getArgument(name, Heightmap.Types.class);
    }
 
    @Override
    protected String convertId(String id) {
        return id.toLowerCase(Locale.ROOT);
    }
}

引用的其他类

  • CommandSourceStack

    • 引用位置: 参数
  • StringRepresentable

    • 引用位置: 方法调用
    • 关联成员: StringRepresentable.fromEnumWithMapping()
  • Heightmap

    • 引用位置: 字段/方法调用/继承/返回值
    • 关联成员: Heightmap.Types.values()