Posted November 2, 201311 yr 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
November 2, 201311 yr 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.
November 2, 201311 yr Author Nope. Also tried surrounding the if() with another one with the !world.isRemote. Kain
November 3, 201311 yr 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.