Jump to content

[Solved]TileEntity with world set to null


DjGiannuzz

Recommended Posts

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

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.