SingletonArgumentInfo.java

net.minecraft.commands.synchronization.SingletonArgumentInfo

信息

  • 全限定名:net.minecraft.commands.synchronization.SingletonArgumentInfo
  • 类型:public class
  • 包:net.minecraft.commands.synchronization
  • 源码路径:src/main/java/net/minecraft/commands/synchronization/SingletonArgumentInfo.java
  • 起始行号:L11
  • 实现:ArgumentTypeInfo<A,SingletonArgumentInfo.Template>
  • 职责:

    TODO

字段/常量

  • template
    • 类型: SingletonArgumentInfo<A>.Template
    • 修饰符: private final
    • 源码定位: L12
    • 说明:

      TODO

内部类/嵌套类型

  • net.minecraft.commands.synchronization.SingletonArgumentInfo.Template
    • 类型: class
    • 修饰符: public final
    • 源码定位: L40
    • 说明:

      TODO

构造器

private SingletonArgumentInfo(Function<CommandBuildContext,A> constructor) @ L14

  • 构造器名:SingletonArgumentInfo
  • 源码定位:L14
  • 修饰符:private

参数:

  • constructor: Function<CommandBuildContext,A>

说明:

TODO

方法

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

public static <T extends ArgumentType<?>> SingletonArgumentInfo<T> contextFree(Supplier<T> constructor) @ L18

  • 方法名:contextFree
  • 源码定位:L18
  • 返回类型:<T extends ArgumentType<?>> SingletonArgumentInfo
  • 修饰符:public static

参数:

  • constructor: Supplier

说明:

TODO

public static <T extends ArgumentType<?>> SingletonArgumentInfo<T> contextAware(Function<CommandBuildContext,T> constructor) @ L22

  • 方法名:contextAware
  • 源码定位:L22
  • 返回类型:<T extends ArgumentType<?>> SingletonArgumentInfo
  • 修饰符:public static

参数:

  • constructor: Function<CommandBuildContext,T>

说明:

TODO

public void serializeToNetwork(SingletonArgumentInfo<A>.Template template, FriendlyByteBuf out) @ L26

  • 方法名:serializeToNetwork
  • 源码定位:L26
  • 返回类型:void
  • 修饰符:public

参数:

说明:

TODO

public void serializeToJson(SingletonArgumentInfo<A>.Template template, JsonObject out) @ L29

  • 方法名:serializeToJson
  • 源码定位:L29
  • 返回类型:void
  • 修饰符:public

参数:

说明:

TODO

public SingletonArgumentInfo<A>.Template deserializeFromNetwork(FriendlyByteBuf in) @ L32

参数:

  • in: FriendlyByteBuf

说明:

TODO

public SingletonArgumentInfo<A>.Template unpack(A argument) @ L36

参数:

  • argument: A

说明:

TODO

代码

public class SingletonArgumentInfo<A extends ArgumentType<?>> implements ArgumentTypeInfo<A, SingletonArgumentInfo<A>.Template> {
    private final SingletonArgumentInfo<A>.Template template;
 
    private SingletonArgumentInfo(Function<CommandBuildContext, A> constructor) {
        this.template = new SingletonArgumentInfo.Template(constructor);
    }
 
    public static <T extends ArgumentType<?>> SingletonArgumentInfo<T> contextFree(Supplier<T> constructor) {
        return new SingletonArgumentInfo<>(context -> constructor.get());
    }
 
    public static <T extends ArgumentType<?>> SingletonArgumentInfo<T> contextAware(Function<CommandBuildContext, T> constructor) {
        return new SingletonArgumentInfo<>(constructor);
    }
 
    public void serializeToNetwork(SingletonArgumentInfo<A>.Template template, FriendlyByteBuf out) {
    }
 
    public void serializeToJson(SingletonArgumentInfo<A>.Template template, JsonObject out) {
    }
 
    public SingletonArgumentInfo<A>.Template deserializeFromNetwork(FriendlyByteBuf in) {
        return this.template;
    }
 
    public SingletonArgumentInfo<A>.Template unpack(A argument) {
        return this.template;
    }
 
    public final class Template implements ArgumentTypeInfo.Template<A> {
        private final Function<CommandBuildContext, A> constructor;
 
        public Template(Function<CommandBuildContext, A> constructor) {
            Objects.requireNonNull(SingletonArgumentInfo.this);
            super();
            this.constructor = constructor;
        }
 
        @Override
        public A instantiate(CommandBuildContext context) {
            return this.constructor.apply(context);
        }
 
        @Override
        public ArgumentTypeInfo<A, ?> type() {
            return SingletonArgumentInfo.this;
        }
    }
}

引用的其他类