LongArgumentInfo.java
net.minecraft.commands.synchronization.brigadier.LongArgumentInfo
信息
- 全限定名:net.minecraft.commands.synchronization.brigadier.LongArgumentInfo
- 类型:public class
- 包:net.minecraft.commands.synchronization.brigadier
- 源码路径:src/main/java/net/minecraft/commands/synchronization/brigadier/LongArgumentInfo.java
- 起始行号:L11
- 实现:ArgumentTypeInfo<LongArgumentType,LongArgumentInfo.Template>
- 职责:
TODO
字段/常量
- 无
内部类/嵌套类型
net.minecraft.commands.synchronization.brigadier.LongArgumentInfo.Template- 类型:
class - 修饰符:
public final - 源码定位:
L46 - 说明:
TODO
- 类型:
构造器
- 无
方法
下面的方法块按源码顺序生成。
public void serializeToNetwork(LongArgumentInfo.Template template, FriendlyByteBuf out) @ L12
- 方法名:serializeToNetwork
- 源码定位:L12
- 返回类型:void
- 修饰符:public
参数:
- template: LongArgumentInfo.Template
- out: FriendlyByteBuf
说明:
TODO
public LongArgumentInfo.Template deserializeFromNetwork(FriendlyByteBuf in) @ L25
- 方法名:deserializeFromNetwork
- 源码定位:L25
- 返回类型:LongArgumentInfo.Template
- 修饰符:public
参数:
- in: FriendlyByteBuf
说明:
TODO
public void serializeToJson(LongArgumentInfo.Template template, JsonObject out) @ L32
- 方法名:serializeToJson
- 源码定位:L32
- 返回类型:void
- 修饰符:public
参数:
- template: LongArgumentInfo.Template
- out: JsonObject
说明:
TODO
public LongArgumentInfo.Template unpack(LongArgumentType argument) @ L42
- 方法名:unpack
- 源码定位:L42
- 返回类型:LongArgumentInfo.Template
- 修饰符:public
参数:
- argument: LongArgumentType
说明:
TODO
代码
public class LongArgumentInfo implements ArgumentTypeInfo<LongArgumentType, LongArgumentInfo.Template> {
public void serializeToNetwork(LongArgumentInfo.Template template, FriendlyByteBuf out) {
boolean hasMin = template.min != Long.MIN_VALUE;
boolean hasMax = template.max != Long.MAX_VALUE;
out.writeByte(ArgumentUtils.createNumberFlags(hasMin, hasMax));
if (hasMin) {
out.writeLong(template.min);
}
if (hasMax) {
out.writeLong(template.max);
}
}
public LongArgumentInfo.Template deserializeFromNetwork(FriendlyByteBuf in) {
byte flags = in.readByte();
long min = ArgumentUtils.numberHasMin(flags) ? in.readLong() : Long.MIN_VALUE;
long max = ArgumentUtils.numberHasMax(flags) ? in.readLong() : Long.MAX_VALUE;
return new LongArgumentInfo.Template(min, max);
}
public void serializeToJson(LongArgumentInfo.Template template, JsonObject out) {
if (template.min != Long.MIN_VALUE) {
out.addProperty("min", template.min);
}
if (template.max != Long.MAX_VALUE) {
out.addProperty("max", template.max);
}
}
public LongArgumentInfo.Template unpack(LongArgumentType argument) {
return new LongArgumentInfo.Template(argument.getMinimum(), argument.getMaximum());
}
public final class Template implements ArgumentTypeInfo.Template<LongArgumentType> {
private final long min;
private final long max;
private Template(long min, long max) {
Objects.requireNonNull(LongArgumentInfo.this);
super();
this.min = min;
this.max = max;
}
public LongArgumentType instantiate(CommandBuildContext context) {
return LongArgumentType.longArg(this.min, this.max);
}
@Override
public ArgumentTypeInfo<LongArgumentType, ?> type() {
return LongArgumentInfo.this;
}
}
}引用的其他类
-
- 引用位置:
实现
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
ArgumentUtils.createNumberFlags(), ArgumentUtils.numberHasMax(), ArgumentUtils.numberHasMin()
- 引用位置:
-
- 引用位置:
参数
- 引用位置: