Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

  • 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.

  • Author

I did that before reading you reply. :P

It works, thank you!

(I have to learn how that threads stuff works.) ;D

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.