Stat.java
net.minecraft.stats.Stat
信息
- 全限定名:net.minecraft.stats.Stat
- 类型:public class
- 包:net.minecraft.stats
- 源码路径:src/main/java/net/minecraft/stats/Stat.java
- 起始行号:L13
- 继承:ObjectiveCriteria
- 职责:
TODO
字段/常量
-
STREAM_CODEC- 类型:
StreamCodec<RegistryFriendlyByteBuf,Stat<?>> - 修饰符:
public static final - 源码定位:
L14 - 说明:
TODO
- 类型:
-
formatter- 类型:
StatFormatter - 修饰符:
private final - 源码定位:
L16 - 说明:
TODO
- 类型:
-
value- 类型:
T - 修饰符:
private final - 源码定位:
L17 - 说明:
TODO
- 类型:
-
type- 类型:
StatType<T> - 修饰符:
private final - 源码定位:
L18 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
protected Stat(StatType<T> type, T value, StatFormatter formatter) @ L20
- 构造器名:Stat
- 源码定位:L20
- 修饰符:protected
参数:
- type: StatType
- value: T
- formatter: StatFormatter
说明:
TODO
方法
下面的方法块按源码顺序生成。
public static <T> String buildName(StatType<T> type, T value) @ L27
- 方法名:buildName
- 源码定位:L27
- 返回类型:
String - 修饰符:public static
参数:
- type: StatType
- value: T
说明:
TODO
private static String locationToKey(Identifier location) @ L31
- 方法名:locationToKey
- 源码定位:L31
- 返回类型:String
- 修饰符:private static
参数:
- location: Identifier
说明:
TODO
public StatType<T> getType() @ L35
- 方法名:getType
- 源码定位:L35
- 返回类型:StatType
- 修饰符:public
参数:
- 无
说明:
TODO
public T getValue() @ L39
- 方法名:getValue
- 源码定位:L39
- 返回类型:T
- 修饰符:public
参数:
- 无
说明:
TODO
public String format(int value) @ L43
- 方法名:format
- 源码定位:L43
- 返回类型:String
- 修饰符:public
参数:
- value: int
说明:
TODO
public boolean equals(Object o) @ L47
- 方法名:equals
- 源码定位:L47
- 返回类型:boolean
- 修饰符:public
参数:
- o: Object
说明:
TODO
public int hashCode() @ L52
- 方法名:hashCode
- 源码定位:L52
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public String toString() @ L57
- 方法名:toString
- 源码定位:L57
- 返回类型:String
- 修饰符:public
参数:
- 无
说明:
TODO
代码
public class Stat<T> extends ObjectiveCriteria {
public static final StreamCodec<RegistryFriendlyByteBuf, Stat<?>> STREAM_CODEC = ByteBufCodecs.registry(Registries.STAT_TYPE)
.dispatch(Stat::getType, StatType::streamCodec);
private final StatFormatter formatter;
private final T value;
private final StatType<T> type;
protected Stat(StatType<T> type, T value, StatFormatter formatter) {
super(buildName(type, value));
this.type = type;
this.formatter = formatter;
this.value = value;
}
public static <T> String buildName(StatType<T> type, T value) {
return locationToKey(BuiltInRegistries.STAT_TYPE.getKey(type)) + ":" + locationToKey(type.getRegistry().getKey(value));
}
private static String locationToKey(@Nullable Identifier location) {
return location.toString().replace(':', '.');
}
public StatType<T> getType() {
return this.type;
}
public T getValue() {
return this.value;
}
public String format(int value) {
return this.formatter.format(value);
}
@Override
public boolean equals(Object o) {
return this == o || o instanceof Stat && Objects.equals(this.getName(), ((Stat)o).getName());
}
@Override
public int hashCode() {
return this.getName().hashCode();
}
@Override
public String toString() {
return "Stat{name=" + this.getName() + ", formatter=" + this.formatter + "}";
}
}引用的其他类
-
- 引用位置:
字段
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
ByteBufCodecs.registry()
- 引用位置:
-
- 引用位置:
字段
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
参数/字段/返回值
- 引用位置:
-
- 引用位置:
继承
- 引用位置: