0
无法创建块装载票我试图用一种门票:在锻造
Ticket ticket = ForgeChunkManager.requestTicket(this, this.minecraftServer.entityWorld, ForgeChunkManager.Type.NORMAL);
上面的代码是在我的主模类。当我尝试运行我的mod时,我得到一个NullPointerException。
无法创建块装载票我试图用一种门票:在锻造
Ticket ticket = ForgeChunkManager.requestTicket(this, this.minecraftServer.entityWorld, ForgeChunkManager.Type.NORMAL);
上面的代码是在我的主模类。当我尝试运行我的mod时,我得到一个NullPointerException。
在这种情况下,this.minecraftServer
或this.minecraftServer.entityWorld
是null。
尝试用if语句包围它。
if (this.minecraftServer != null && this.minecraftServer.entityWorld != null){
Ticket ticket = ForgeChunkManager.requestTicket(this,
this.minecraftServer.entityWorld,
ForgeChunkManager.Type.NORMAL);
}
和调试的目的,我建议你在两个条件分开吧:
if (this.minecraftServer == null) {
System.out.println("minecraftServer is null");
//or do anything can to warn you
} else if(this.minecraftServer.entityWorld == null) {
System.out.println("entityWorld is null");
//or do anything can to warn you
} else {
Ticket ticket = ForgeChunkManager.requestTicket(this,
this.minecraftServer.entityWorld,
ForgeChunkManager.Type.NORMAL);
}
除非你能使用调试器来检查值。
但是没有完整的代码,就不可能知道是否有其他错误。