TLHPoE Posted September 9, 2013 Posted September 9, 2013 I'm using WorldSavedData to store a player's stat for a world, but I have no clue how to get/load to the world's NBTTagCompound. PlayerStatsUtil: package terramagna.utils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.*; import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.event.entity.EntityJoinWorldEvent; public class PlayerStatsUtil extends WorldSavedData { public PlayerStatsUtil(String par1Str){super(par1Str);} private static int gold; private static String playerN; @ForgeSubscribe public void onEntityJoinWorld(EntityJoinWorldEvent event) { if (!event.entity.worldObj.isRemote && event.entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.entity; World world = player.getEntityWorld(); } } @Override public void readFromNBT(NBTTagCompound nbttagcompound) { } @Override public void writeToNBT(NBTTagCompound nbttagcompound) { } } Quote Kain
GotoLink Posted September 9, 2013 Posted September 9, 2013 Exactly like you would for a TileEntity. Quote
TLHPoE Posted September 9, 2013 Author Posted September 9, 2013 Sorry to sound dumb but, I've never really touched on Entities or TileEntities. I'm confused on the 2 read/write NBT methods. Do I do something like this: NBTTagCompound nbt = new NBTTagCompoind(); readFromNBT(nbt); I don't know how I would store any data in that. Quote Kain
Mazetar Posted September 9, 2013 Posted September 9, 2013 check how he stores and retrives data here from NBT: www.minecraftforge.net/wiki/Item_nbt Quote If you guys dont get it.. then well ya.. try harder...
TLHPoE Posted September 10, 2013 Author Posted September 10, 2013 I have no idea where to go from here: http://pastebin.com/YuR3FJHB How would I write to the NBTTagCompound? I know how to get the world from the player, but no clue how to get the NBTTagCompound from the world. Quote Kain
Mazetar Posted September 10, 2013 Posted September 10, 2013 world.getworldinfo().X, check what cool stuff X could be ^^ Quote If you guys dont get it.. then well ya.. try harder...
TLHPoE Posted September 10, 2013 Author Posted September 10, 2013 Thanks, it's working now. Quote Kain
Recommended Posts
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.