Posted September 18, 201411 yr Hi all, I have a problem with a TileEntity on World load. I save the dimensionId, xCoord, yCoord, zCoord of the TileEntity in a global variable every time the method readFromNBT is called. The problems come if there are no player around and it seems that the world of the TileEntity is set to null. @Override public void readFromNBT(NBTTagCompound par1NBTTagCompound) { super.readFromNBT(par1NBTTagCompound); this.isLocked = par1NBTTagCompound.getBoolean("isLocked"); this.isPrivate = par1NBTTagCompound.getBoolean("isPrivate"); this.isGlobal = par1NBTTagCompound.getBoolean("isGlobal"); String owner = par1NBTTagCompound.getString("Owner"); this.ownerUsername =owner.equals("undef")?"":owner; String privName = par1NBTTagCompound.getString("privateName"); this.privateName = privName.equals("undef")?"":privName; String globName = par1NBTTagCompound.getString("globalName"); this.globalName = globName.equals("undef")?"":globName; if(worldObj != null) { if(isPrivate) FastTravelHandler.addPrivatePoint(ownerUsername, worldObj.provider.dimensionId, xCoord, yCoord, zCoord, privateName); if(isGlobal) FastTravelHandler.addGlobalPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, globalName); } else LogHelper.error("The world is null"); The TileEntity is Chunkloaded and it works for sure.(if I put a print inside the updateEntity() method I get the message in the console) Unfortunately I get the "The world is null" message from the TileEntity that is far away from the player every time I load the world. I've tried to save the dimensionId in the NBTTag and use it instead of worldObj.provider.dimensionId but I get this crashlog that looks like a strange loop: http://pastebin.com/2wAVQwiH
September 18, 201411 yr Author You can't get the World in readFromNBT. You need to do it later. So when? I don't like to do that every tick or every 'n' tick.
September 18, 201411 yr Author I did that before reading you reply. It works, thank you! (I have to learn how that threads stuff works.)
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.