IntegerArgumentInfo.java

net.minecraft.commands.synchronization.brigadier.IntegerArgumentInfo

信息

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

    TODO

字段/常量

内部类/嵌套类型

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

      TODO

构造器

方法

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

public void serializeToNetwork(IntegerArgumentInfo.Template template, FriendlyByteBuf out) @ L12

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

参数:

  • template: IntegerArgumentInfo.Template
  • out: FriendlyByteBuf

说明:

TODO

public IntegerArgumentInfo.Template deserializeFromNetwork(FriendlyByteBuf in) @ L25

  • 方法名:deserializeFromNetwork
  • 源码定位:L25
  • 返回类型:IntegerArgumentInfo.Template
  • 修饰符:public

参数:

  • in: FriendlyByteBuf

说明:

TODO

public void serializeToJson(IntegerArgumentInfo.Template template, JsonObject out) @ L32

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

参数:

  • template: IntegerArgumentInfo.Template
  • out: JsonObject

说明:

TODO

public IntegerArgumentInfo.Template unpack(IntegerArgumentType argument) @ L42

  • 方法名:unpack
  • 源码定位:L42
  • 返回类型:IntegerArgumentInfo.Template
  • 修饰符:public

参数:

  • argument: IntegerArgumentType

说明:

TODO

代码

public class IntegerArgumentInfo implements ArgumentTypeInfo<IntegerArgumentType, IntegerArgumentInfo.Template> {
    public void serializeToNetwork(IntegerArgumentInfo.Template template, FriendlyByteBuf out) {
        boolean hasMin = template.min != Integer.MIN_VALUE;
        boolean hasMax = template.max != Integer.MAX_VALUE;
        out.writeByte(ArgumentUtils.createNumberFlags(hasMin, hasMax));
        if (hasMin) {
            out.writeInt(template.min);
        }
 
        if (hasMax) {
            out.writeInt(template.max);
        }
    }
 
    public IntegerArgumentInfo.Template deserializeFromNetwork(FriendlyByteBuf in) {
        byte flags = in.readByte();
        int min = ArgumentUtils.numberHasMin(flags) ? in.readInt() : Integer.MIN_VALUE;
        int max = ArgumentUtils.numberHasMax(flags) ? in.readInt() : Integer.MAX_VALUE;
        return new IntegerArgumentInfo.Template(min, max);
    }
 
    public void serializeToJson(IntegerArgumentInfo.Template template, JsonObject out) {
        if (template.min != Integer.MIN_VALUE) {
            out.addProperty("min", template.min);
        }
 
        if (template.max != Integer.MAX_VALUE) {
            out.addProperty("max", template.max);
        }
    }
 
    public IntegerArgumentInfo.Template unpack(IntegerArgumentType argument) {
        return new IntegerArgumentInfo.Template(argument.getMinimum(), argument.getMaximum());
    }
 
    public final class Template implements ArgumentTypeInfo.Template<IntegerArgumentType> {
        private final int min;
        private final int max;
 
        private Template(int min, int max) {
            Objects.requireNonNull(IntegerArgumentInfo.this);
            super();
            this.min = min;
            this.max = max;
        }
 
        public IntegerArgumentType instantiate(CommandBuildContext context) {
            return IntegerArgumentType.integer(this.min, this.max);
        }
 
        @Override
        public ArgumentTypeInfo<IntegerArgumentType, ?> type() {
            return IntegerArgumentInfo.this;
        }
    }
}

引用的其他类

  • ArgumentTypeInfo

    • 引用位置: 实现
  • ArgumentUtils

    • 引用位置: 方法调用
    • 关联成员: ArgumentUtils.createNumberFlags(), ArgumentUtils.numberHasMax(), ArgumentUtils.numberHasMin()
  • FriendlyByteBuf

    • 引用位置: 参数