DebugSubscription.java
net.minecraft.util.debug.DebugSubscription
信息
- 全限定名:net.minecraft.util.debug.DebugSubscription
- 类型:public class
- 包:net.minecraft.util.debug
- 源码路径:src/main/java/net/minecraft/util/debug/DebugSubscription.java
- 起始行号:L13
- 职责:
TODO
字段/常量
-
DOES_NOT_EXPIRE- 类型:
int - 修饰符:
public static final - 源码定位:
L14 - 说明:
TODO
- 类型:
-
valueStreamCodec- 类型:
StreamCodec<?super RegistryFriendlyByteBuf,T> - 修饰符:
private final - 源码定位:
L15 - 说明:
TODO
- 类型:
-
expireAfterTicks- 类型:
int - 修饰符:
private final - 源码定位:
L16 - 说明:
TODO
- 类型:
内部类/嵌套类型
-
net.minecraft.util.debug.DebugSubscription.Event- 类型:
record - 修饰符:
public - 源码定位:
L52 - 说明:
TODO
- 类型:
-
net.minecraft.util.debug.DebugSubscription.Update- 类型:
record - 修饰符:
public - 源码定位:
L64 - 说明:
TODO
- 类型:
构造器
public DebugSubscription(StreamCodec<?super RegistryFriendlyByteBuf,T> valueStreamCodec, int expireAfterTicks) @ L18
- 构造器名:DebugSubscription
- 源码定位:L18
- 修饰符:public
参数:
- valueStreamCodec: StreamCodec<?super RegistryFriendlyByteBuf,T>
- expireAfterTicks: int
说明:
TODO
public DebugSubscription(StreamCodec<?super RegistryFriendlyByteBuf,T> valueStreamCodec) @ L23
- 构造器名:DebugSubscription
- 源码定位:L23
- 修饰符:public
参数:
- valueStreamCodec: StreamCodec<?super RegistryFriendlyByteBuf,T>
说明:
TODO
方法
下面的方法块按源码顺序生成。
public DebugSubscription.Update<T> packUpdate(T value) @ L27
- 方法名:packUpdate
- 源码定位:L27
- 返回类型:DebugSubscription.Update
- 修饰符:public
参数:
- value: T
说明:
TODO
public DebugSubscription.Update<T> emptyUpdate() @ L31
- 方法名:emptyUpdate
- 源码定位:L31
- 返回类型:DebugSubscription.Update
- 修饰符:public
参数:
- 无
说明:
TODO
public DebugSubscription.Event<T> packEvent(T value) @ L35
- 方法名:packEvent
- 源码定位:L35
- 返回类型:DebugSubscription.Event
- 修饰符:public
参数:
- value: T
说明:
TODO
public String toString() @ L39
- 方法名:toString
- 源码定位:L39
- 返回类型:String
- 修饰符:public
参数:
- 无
说明:
TODO
public StreamCodec<?super RegistryFriendlyByteBuf,T> valueStreamCodec() @ L44
- 方法名:valueStreamCodec
- 源码定位:L44
- 返回类型:StreamCodec<?super RegistryFriendlyByteBuf,T>
- 修饰符:public
参数:
- 无
说明:
TODO
public int expireAfterTicks() @ L48
- 方法名:expireAfterTicks
- 源码定位:L48
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
代码
public class DebugSubscription<T> {
public static final int DOES_NOT_EXPIRE = 0;
private final @Nullable StreamCodec<? super RegistryFriendlyByteBuf, T> valueStreamCodec;
private final int expireAfterTicks;
public DebugSubscription(@Nullable StreamCodec<? super RegistryFriendlyByteBuf, T> valueStreamCodec, int expireAfterTicks) {
this.valueStreamCodec = valueStreamCodec;
this.expireAfterTicks = expireAfterTicks;
}
public DebugSubscription(@Nullable StreamCodec<? super RegistryFriendlyByteBuf, T> valueStreamCodec) {
this(valueStreamCodec, 0);
}
public DebugSubscription.Update<T> packUpdate(@Nullable T value) {
return new DebugSubscription.Update<>(this, Optional.ofNullable(value));
}
public DebugSubscription.Update<T> emptyUpdate() {
return new DebugSubscription.Update<>(this, Optional.empty());
}
public DebugSubscription.Event<T> packEvent(T value) {
return new DebugSubscription.Event<>(this, value);
}
@Override
public String toString() {
return Util.getRegisteredName(BuiltInRegistries.DEBUG_SUBSCRIPTION, this);
}
public @Nullable StreamCodec<? super RegistryFriendlyByteBuf, T> valueStreamCodec() {
return this.valueStreamCodec;
}
public int expireAfterTicks() {
return this.expireAfterTicks;
}
public record Event<T>(DebugSubscription<T> subscription, T value) {
public static final StreamCodec<RegistryFriendlyByteBuf, DebugSubscription.Event<?>> STREAM_CODEC = ByteBufCodecs.registry(
Registries.DEBUG_SUBSCRIPTION
)
.dispatch(DebugSubscription.Event::subscription, DebugSubscription.Event::streamCodec);
private static <T> StreamCodec<? super RegistryFriendlyByteBuf, DebugSubscription.Event<T>> streamCodec(DebugSubscription<T> subscription) {
return Objects.requireNonNull(subscription.valueStreamCodec)
.map(value -> new DebugSubscription.Event<>(subscription, (T)value), DebugSubscription.Event::value);
}
}
public record Update<T>(DebugSubscription<T> subscription, Optional<T> value) {
public static final StreamCodec<RegistryFriendlyByteBuf, DebugSubscription.Update<?>> STREAM_CODEC = ByteBufCodecs.registry(
Registries.DEBUG_SUBSCRIPTION
)
.dispatch(DebugSubscription.Update::subscription, DebugSubscription.Update::streamCodec);
private static <T> StreamCodec<? super RegistryFriendlyByteBuf, DebugSubscription.Update<T>> streamCodec(DebugSubscription<T> subscription) {
return ByteBufCodecs.optional(Objects.requireNonNull(subscription.valueStreamCodec))
.map(value -> new DebugSubscription.Update<>(subscription, (Optional<T>)value), DebugSubscription.Update::value);
}
}
}引用的其他类
-
- 引用位置:
参数/字段/返回值
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
ByteBufCodecs.optional(), ByteBufCodecs.registry()
- 引用位置:
-
- 引用位置:
参数/字段/返回值
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Util.getRegisteredName()
- 引用位置: