TestData.java

net.minecraft.gametest.framework.TestData

信息

  • 全限定名:net.minecraft.gametest.framework.TestData
  • 类型:public record
  • 包:net.minecraft.gametest.framework
  • 源码路径:src/main/java/net/minecraft/gametest/framework/TestData.java
  • 起始行号:L12
  • 职责:

    TODO

字段/常量

  • CODEC
    • 类型: MapCodec<TestData<Holder<TestEnvironmentDefinition<?>>>>
    • 修饰符: public static final
    • 源码定位: L25
    • 说明:

      TODO

内部类/嵌套类型

构造器

public TestData(EnvironmentType environment, Identifier structure, int maxTicks, int setupTicks, boolean required, Rotation rotation) @ L42

  • 构造器名:TestData
  • 源码定位:L42
  • 修饰符:public

参数:

  • environment: EnvironmentType
  • structure: Identifier
  • maxTicks: int
  • setupTicks: int
  • required: boolean
  • rotation: Rotation

说明:

TODO

public TestData(EnvironmentType environment, Identifier structure, int maxTicks, int setupTicks, boolean required) @ L46

  • 构造器名:TestData
  • 源码定位:L46
  • 修饰符:public

参数:

  • environment: EnvironmentType
  • structure: Identifier
  • maxTicks: int
  • setupTicks: int
  • required: boolean

说明:

TODO

方法

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

public <T> TestData<T> map(Function<EnvironmentType,T> mapper) @ L50

  • 方法名:map
  • 源码定位:L50
  • 返回类型: TestData
  • 修饰符:public

参数:

  • mapper: Function<EnvironmentType,T>

说明:

TODO

代码

public record TestData<EnvironmentType>(
    EnvironmentType environment,
    Identifier structure,
    int maxTicks,
    int setupTicks,
    boolean required,
    Rotation rotation,
    boolean manualOnly,
    int maxAttempts,
    int requiredSuccesses,
    boolean skyAccess,
    int padding
) {
    public static final MapCodec<TestData<Holder<TestEnvironmentDefinition<?>>>> CODEC = RecordCodecBuilder.mapCodec(
        i -> i.group(
                TestEnvironmentDefinition.CODEC.fieldOf("environment").forGetter(TestData::environment),
                Identifier.CODEC.fieldOf("structure").forGetter(TestData::structure),
                ExtraCodecs.POSITIVE_INT.fieldOf("max_ticks").forGetter(TestData::maxTicks),
                ExtraCodecs.NON_NEGATIVE_INT.optionalFieldOf("setup_ticks", 0).forGetter(TestData::setupTicks),
                Codec.BOOL.optionalFieldOf("required", true).forGetter(TestData::required),
                Rotation.CODEC.optionalFieldOf("rotation", Rotation.NONE).forGetter(TestData::rotation),
                Codec.BOOL.optionalFieldOf("manual_only", false).forGetter(TestData::manualOnly),
                ExtraCodecs.POSITIVE_INT.optionalFieldOf("max_attempts", 1).forGetter(TestData::maxAttempts),
                ExtraCodecs.POSITIVE_INT.optionalFieldOf("required_successes", 1).forGetter(TestData::requiredSuccesses),
                Codec.BOOL.optionalFieldOf("sky_access", false).forGetter(TestData::skyAccess),
                ExtraCodecs.intRange(0, 128).optionalFieldOf("padding", 0).forGetter(TestData::padding)
            )
            .apply(i, TestData::new)
    );
 
    public TestData(EnvironmentType environment, Identifier structure, int maxTicks, int setupTicks, boolean required, Rotation rotation) {
        this(environment, structure, maxTicks, setupTicks, required, rotation, false, 1, 1, false, 0);
    }
 
    public TestData(EnvironmentType environment, Identifier structure, int maxTicks, int setupTicks, boolean required) {
        this(environment, structure, maxTicks, setupTicks, required, Rotation.NONE);
    }
 
    public <T> TestData<T> map(Function<EnvironmentType, T> mapper) {
        return new TestData<>(
            mapper.apply(this.environment),
            this.structure,
            this.maxTicks,
            this.setupTicks,
            this.required,
            this.rotation,
            this.manualOnly,
            this.maxAttempts,
            this.requiredSuccesses,
            this.skyAccess,
            this.padding
        );
    }
}

引用的其他类