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

I thought hasKey would work, but apparently not. I have my code setup inside of a player tick handler, and it constantly spams "HI1" in the console.

 

public static void playerTick(EntityPlayer player)
{

	String playerName = player.username;
	NBTTagCompound worldNBT = player.worldObj.getWorldInfo().getNBTTagCompound();

	if(!worldNBT.hasKey(playerName + "Gold"))
	{

		GloriaRPG.print("HI1");

		worldNBT.setInteger(playerName + "Gold", 0);

	}

Kain

These values are only saved on the server. The console chat is sent from the client. what if you added !player.worldObj.isRemote to your if() statement? Would it stop then?

Author of PneumaticCraft, MineChess, Minesweeper Mod and Sokoban Mod. Visit www.minemaarten.com to take a look at them.

  • Author

Nope.  :(

 

Also tried surrounding the if() with another one with the !world.isRemote.

Kain

Hi

 

I had a quick look into getNBTTagCompound, which calls updateTagCompound, and it looks to me like it creates it a new one each time and fills it with values stored in WorldInfo.  So you can add a key but it just gets thrown away at the end of your PlayerTick.

 

Why do you want to store something in WorldInfo?

Depending on what you want to do, .getAdditionalProperty and .setAdditionalProperty might be what you're looking for?

 

-TGG

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.