CrashReportCategory.java
net.minecraft.CrashReportCategory
信息
- 全限定名:net.minecraft.CrashReportCategory
- 类型:public class
- 包:net.minecraft
- 源码路径:src/main/java/net/minecraft/CrashReportCategory.java
- 起始行号:L12
- 职责:
TODO
字段/常量
-
title- 类型:
String - 修饰符:
private final - 源码定位:
L13 - 说明:
TODO
- 类型:
-
entries- 类型:
List<CrashReportCategory.Entry> - 修饰符:
private final - 源码定位:
L14 - 说明:
TODO
- 类型:
-
stackTrace- 类型:
StackTraceElement[] - 修饰符:
private - 源码定位:
L15 - 说明:
TODO
- 类型:
内部类/嵌套类型
net.minecraft.CrashReportCategory.Entry- 类型:
class - 修饰符:
private static - 源码定位:
L212 - 说明:
TODO
- 类型:
构造器
public CrashReportCategory(String title) @ L17
- 构造器名:CrashReportCategory
- 源码定位:L17
- 修饰符:public
参数:
- title: String
说明:
TODO
方法
下面的方法块按源码顺序生成。
public static String formatLocation(double x, double y, double z) @ L21
- 方法名:formatLocation
- 源码定位:L21
- 返回类型:String
- 修饰符:public static
参数:
- x: double
- y: double
- z: double
说明:
TODO
public static String formatLocation(LevelHeightAccessor levelHeightAccessor, double x, double y, double z) @ L25
- 方法名:formatLocation
- 源码定位:L25
- 返回类型:String
- 修饰符:public static
参数:
- levelHeightAccessor: LevelHeightAccessor
- x: double
- y: double
- z: double
说明:
TODO
public static String formatLocation(LevelHeightAccessor levelHeightAccessor, BlockPos pos) @ L29
- 方法名:formatLocation
- 源码定位:L29
- 返回类型:String
- 修饰符:public static
参数:
- levelHeightAccessor: LevelHeightAccessor
- pos: BlockPos
说明:
TODO
public static String formatLocation(LevelHeightAccessor levelHeightAccessor, int x, int y, int z) @ L33
- 方法名:formatLocation
- 源码定位:L33
- 返回类型:String
- 修饰符:public static
参数:
- levelHeightAccessor: LevelHeightAccessor
- x: int
- y: int
- z: int
说明:
TODO
public CrashReportCategory setDetail(String key, CrashReportDetail<String> callback) @ L119
- 方法名:setDetail
- 源码定位:L119
- 返回类型:CrashReportCategory
- 修饰符:public
参数:
- key: String
- callback: CrashReportDetail
说明:
TODO
public CrashReportCategory setDetail(String key, Object value) @ L129
- 方法名:setDetail
- 源码定位:L129
- 返回类型:CrashReportCategory
- 修饰符:public
参数:
- key: String
- value: Object
说明:
TODO
public void setDetailError(String key, Throwable t) @ L134
- 方法名:setDetailError
- 源码定位:L134
- 返回类型:void
- 修饰符:public
参数:
- key: String
- t: Throwable
说明:
TODO
public int fillInStackTrace(int nestedOffset) @ L138
- 方法名:fillInStackTrace
- 源码定位:L138
- 返回类型:int
- 修饰符:public
参数:
- nestedOffset: int
说明:
TODO
public boolean validateStackTrace(StackTraceElement source, StackTraceElement next) @ L149
- 方法名:validateStackTrace
- 源码定位:L149
- 返回类型:boolean
- 修饰符:public
参数:
- source: StackTraceElement
- next: StackTraceElement
说明:
TODO
public void trimStacktrace(int length) @ L172
- 方法名:trimStacktrace
- 源码定位:L172
- 返回类型:void
- 修饰符:public
参数:
- length: int
说明:
TODO
public void getDetails(StringBuilder builder) @ L178
- 方法名:getDetails
- 源码定位:L178
- 返回类型:void
- 修饰符:public
参数:
- builder: StringBuilder
说明:
TODO
public StackTraceElement[] getStacktrace() @ L199
- 方法名:getStacktrace
- 源码定位:L199
- 返回类型:StackTraceElement[]
- 修饰符:public
参数:
- 无
说明:
TODO
public static void populateBlockDetails(CrashReportCategory category, LevelHeightAccessor levelHeightAccessor, BlockPos pos, BlockState state) @ L203
- 方法名:populateBlockDetails
- 源码定位:L203
- 返回类型:void
- 修饰符:public static
参数:
- category: CrashReportCategory
- levelHeightAccessor: LevelHeightAccessor
- pos: BlockPos
- state: BlockState
说明:
TODO
public static CrashReportCategory populateBlockLocationDetails(CrashReportCategory category, LevelHeightAccessor levelHeightAccessor, BlockPos pos) @ L208
- 方法名:populateBlockLocationDetails
- 源码定位:L208
- 返回类型:CrashReportCategory
- 修饰符:public static
参数:
- category: CrashReportCategory
- levelHeightAccessor: LevelHeightAccessor
- pos: BlockPos
说明:
TODO
代码
public class CrashReportCategory {
private final String title;
private final List<CrashReportCategory.Entry> entries = Lists.newArrayList();
private StackTraceElement[] stackTrace = new StackTraceElement[0];
public CrashReportCategory(String title) {
this.title = title;
}
public static String formatLocation(double x, double y, double z) {
return String.format(Locale.ROOT, "%.2f,%.2f,%.2f", x, y, z);
}
public static String formatLocation(LevelHeightAccessor levelHeightAccessor, double x, double y, double z) {
return String.format(Locale.ROOT, "%.2f,%.2f,%.2f - %s", x, y, z, formatLocation(levelHeightAccessor, BlockPos.containing(x, y, z)));
}
public static String formatLocation(LevelHeightAccessor levelHeightAccessor, BlockPos pos) {
return formatLocation(levelHeightAccessor, pos.getX(), pos.getY(), pos.getZ());
}
public static String formatLocation(LevelHeightAccessor levelHeightAccessor, int x, int y, int z) {
StringBuilder result = new StringBuilder();
try {
result.append(String.format(Locale.ROOT, "World: (%d,%d,%d)", x, y, z));
} catch (Throwable var19) {
result.append("(Error finding world loc)");
}
result.append(", ");
try {
int sectionX = SectionPos.blockToSectionCoord(x);
int sectionY = SectionPos.blockToSectionCoord(y);
int sectionZ = SectionPos.blockToSectionCoord(z);
int relativeX = x & 15;
int relativeY = y & 15;
int relativeZ = z & 15;
int minBlockX = SectionPos.sectionToBlockCoord(sectionX);
int minBlockY = levelHeightAccessor.getMinY();
int minBlockZ = SectionPos.sectionToBlockCoord(sectionZ);
int maxBlockX = SectionPos.sectionToBlockCoord(sectionX + 1) - 1;
int maxBlockY = levelHeightAccessor.getMaxY();
int maxBlockZ = SectionPos.sectionToBlockCoord(sectionZ + 1) - 1;
result.append(
String.format(
Locale.ROOT,
"Section: (at %d,%d,%d in %d,%d,%d; chunk contains blocks %d,%d,%d to %d,%d,%d)",
relativeX,
relativeY,
relativeZ,
sectionX,
sectionY,
sectionZ,
minBlockX,
minBlockY,
minBlockZ,
maxBlockX,
maxBlockY,
maxBlockZ
)
);
} catch (Throwable var18) {
result.append("(Error finding chunk loc)");
}
result.append(", ");
try {
int regionX = x >> 9;
int regionZ = z >> 9;
int minChunkX = regionX << 5;
int minChunkZ = regionZ << 5;
int maxChunkX = (regionX + 1 << 5) - 1;
int maxChunkZ = (regionZ + 1 << 5) - 1;
int minBlockX = regionX << 9;
int minBlockY = levelHeightAccessor.getMinY();
int minBlockZ = regionZ << 9;
int maxBlockX = (regionX + 1 << 9) - 1;
int maxBlockY = levelHeightAccessor.getMaxY();
int maxBlockZ = (regionZ + 1 << 9) - 1;
result.append(
String.format(
Locale.ROOT,
"Region: (%d,%d; contains chunks %d,%d to %d,%d, blocks %d,%d,%d to %d,%d,%d)",
regionX,
regionZ,
minChunkX,
minChunkZ,
maxChunkX,
maxChunkZ,
minBlockX,
minBlockY,
minBlockZ,
maxBlockX,
maxBlockY,
maxBlockZ
)
);
} catch (Throwable var17) {
result.append("(Error finding world loc)");
}
return result.toString();
}
public CrashReportCategory setDetail(String key, CrashReportDetail<String> callback) {
try {
this.setDetail(key, callback.call());
} catch (Throwable var4) {
this.setDetailError(key, var4);
}
return this;
}
public CrashReportCategory setDetail(String key, Object value) {
this.entries.add(new CrashReportCategory.Entry(key, value));
return this;
}
public void setDetailError(String key, Throwable t) {
this.setDetail(key, t);
}
public int fillInStackTrace(int nestedOffset) {
StackTraceElement[] full = Thread.currentThread().getStackTrace();
if (full.length <= 0) {
return 0;
} else {
this.stackTrace = new StackTraceElement[full.length - 3 - nestedOffset];
System.arraycopy(full, 3 + nestedOffset, this.stackTrace, 0, this.stackTrace.length);
return this.stackTrace.length;
}
}
public boolean validateStackTrace(StackTraceElement source, StackTraceElement next) {
if (this.stackTrace.length != 0 && source != null) {
StackTraceElement current = this.stackTrace[0];
if (current.isNativeMethod() == source.isNativeMethod()
&& current.getClassName().equals(source.getClassName())
&& current.getFileName().equals(source.getFileName())
&& current.getMethodName().equals(source.getMethodName())) {
if (next != null != this.stackTrace.length > 1) {
return false;
} else if (next != null && !this.stackTrace[1].equals(next)) {
return false;
} else {
this.stackTrace[0] = source;
return true;
}
} else {
return false;
}
} else {
return false;
}
}
public void trimStacktrace(int length) {
StackTraceElement[] swap = new StackTraceElement[this.stackTrace.length - length];
System.arraycopy(this.stackTrace, 0, swap, 0, swap.length);
this.stackTrace = swap;
}
public void getDetails(StringBuilder builder) {
builder.append("-- ").append(this.title).append(" --\n");
builder.append("Details:");
for (CrashReportCategory.Entry entry : this.entries) {
builder.append("\n\t");
builder.append(entry.getKey());
builder.append(": ");
builder.append(entry.getValue());
}
if (this.stackTrace != null && this.stackTrace.length > 0) {
builder.append("\nStacktrace:");
for (StackTraceElement element : this.stackTrace) {
builder.append("\n\tat ");
builder.append(element);
}
}
}
public StackTraceElement[] getStacktrace() {
return this.stackTrace;
}
public static void populateBlockDetails(CrashReportCategory category, LevelHeightAccessor levelHeightAccessor, BlockPos pos, BlockState state) {
category.setDetail("Block", state::toString);
populateBlockLocationDetails(category, levelHeightAccessor, pos);
}
public static CrashReportCategory populateBlockLocationDetails(CrashReportCategory category, LevelHeightAccessor levelHeightAccessor, BlockPos pos) {
return category.setDetail("Block location", () -> formatLocation(levelHeightAccessor, pos));
}
private static class Entry {
private final String key;
private final String value;
public Entry(String key, @Nullable Object value) {
this.key = key;
if (value == null) {
this.value = "~~NULL~~";
} else if (value instanceof Throwable t) {
this.value = "~~ERROR~~ " + t.getClass().getSimpleName() + ": " + t.getMessage();
} else {
this.value = value.toString();
}
}
public String getKey() {
return this.key;
}
public String getValue() {
return this.value;
}
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
System.arraycopy()
- 引用位置:
-
- 引用位置:
参数/方法调用 - 关联成员:
BlockPos.containing()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
SectionPos.blockToSectionCoord(), SectionPos.sectionToBlockCoord()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置: