PacketUtils.java
net.minecraft.network.protocol.PacketUtils
信息
- 全限定名:net.minecraft.network.protocol.PacketUtils
- 类型:public class
- 包:net.minecraft.network.protocol
- 源码路径:src/main/java/net/minecraft/network/protocol/PacketUtils.java
- 起始行号:L14
- 职责:
TODO
字段/常量
LOGGER- 类型:
Logger - 修饰符:
private static final - 源码定位:
L15 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
- 无
方法
下面的方法块按源码顺序生成。
public static <T extends PacketListener> void ensureRunningOnSameThread(Packet<T> packet, T listener, ServerLevel level) @ L17
- 方法名:ensureRunningOnSameThread
- 源码定位:L17
- 返回类型:
void - 修饰符:public static
参数:
- packet: Packet
- listener: T
- level: ServerLevel
说明:
TODO
public static <T extends PacketListener> void ensureRunningOnSameThread(Packet<T> packet, T listener, PacketProcessor packetProcessor) @ L21
- 方法名:ensureRunningOnSameThread
- 源码定位:L21
- 返回类型:
void - 修饰符:public static
参数:
- packet: Packet
- listener: T
- packetProcessor: PacketProcessor
说明:
TODO
public static <T extends PacketListener> ReportedException makeReportedException(Exception cause, Packet<T> packet, T listener) @ L28
- 方法名:makeReportedException
- 源码定位:L28
- 返回类型:
ReportedException - 修饰符:public static
参数:
- cause: Exception
- packet: Packet
- listener: T
说明:
TODO
public static <T extends PacketListener> void fillCrashReport(CrashReport report, T listener, Packet<T> packet) @ L39
- 方法名:fillCrashReport
- 源码定位:L39
- 返回类型:
void - 修饰符:public static
参数:
- report: CrashReport
- listener: T
- packet: Packet
说明:
TODO
代码
public class PacketUtils {
private static final Logger LOGGER = LogUtils.getLogger();
public static <T extends PacketListener> void ensureRunningOnSameThread(Packet<T> packet, T listener, ServerLevel level) throws RunningOnDifferentThreadException {
ensureRunningOnSameThread(packet, listener, level.getServer().packetProcessor());
}
public static <T extends PacketListener> void ensureRunningOnSameThread(Packet<T> packet, T listener, PacketProcessor packetProcessor) throws RunningOnDifferentThreadException {
if (!packetProcessor.isSameThread()) {
packetProcessor.scheduleIfPossible(listener, packet);
throw RunningOnDifferentThreadException.RUNNING_ON_DIFFERENT_THREAD;
}
}
public static <T extends PacketListener> ReportedException makeReportedException(Exception cause, Packet<T> packet, T listener) {
if (cause instanceof ReportedException re) {
fillCrashReport(re.getReport(), listener, packet);
return re;
} else {
CrashReport report = CrashReport.forThrowable(cause, "Main thread packet handler");
fillCrashReport(report, listener, packet);
return new ReportedException(report);
}
}
public static <T extends PacketListener> void fillCrashReport(CrashReport report, T listener, @Nullable Packet<T> packet) {
if (packet != null) {
CrashReportCategory details = report.addCategory("Incoming Packet");
details.setDetail("Type", () -> packet.type().toString());
details.setDetail("Is Terminal", () -> Boolean.toString(packet.isTerminal()));
details.setDetail("Is Skippable", () -> Boolean.toString(packet.isSkippable()));
}
listener.fillCrashReport(report);
}
}引用的其他类
-
- 引用位置:
参数/方法调用 - 关联成员:
CrashReport.forThrowable()
- 引用位置:
-
- 引用位置:
构造调用/返回值 - 关联成员:
ReportedException()
- 引用位置:
-
- 引用位置:
返回值
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置: