I working with minecraft mod and i need to save some player specific custom data. Best way to do that is using NBT of EntityPlayer but looks thats impossible without MC source change. So possibly it's better to create own NBT file. I even found great article about that: http://www.minecraft...s-july-11-2012/. Problem that code in the acticle uses modloader and i don't know how to do the same with Forge. There is no method like getMinecraftDir() in server-side Forge.
Actually i can think up some workarounds but i prefer to use some "right way" to do that. So question is : "Is there any easy way to save player specific custom data or if not how to get minecraft save folder in Forge mod on server side?"
There is great thing called getEntityData. Looks Forge allow to add any custom data to any Entity object. getEntityData return NBTTagCompound where we can create mod specific section and save all required data.
Here is an example in case someone need to do the same:
NBTTagCompound tag = entityPlayer.getEntityData();
NBTBase modeTag = tag.getTag("MyInteger");
if (modeTag != null) {
entityPlayer.addChatMessage("Current int:" + ((NBTTagInt)modeTag).data);
}
tag.setInteger("MyInteger", 150);
On first start code create an integer value in player Entity. On second (even after MC restart) it show this value as chat message.
may be a stupid question but is this data persistent across server access? meaning if Player A starts a server which Player B connects to and the server sets EntityData for Player B, will this data be the same the next time Player B connects to Player A's server?
IExtendedEntityProperties is a very good way to add custom variables to players. Check this tutorial for how to use it. And yes, you will be able to keep the data through save and reload by default, and even player death if you follow the entire tutorial.
IExtendedEntityProperties is a very good way to add custom variables to players. Check this tutorial for how to use it. And yes, you will be able to keep the data through save and reload by default, and even player death if you follow the entire tutorial.
I used your tutorial, it works great. DotCreeper, you should use it.
I working with minecraft mod and i need to save some player specific custom data. Best way to do that is using NBT of EntityPlayer but looks thats impossible without MC source change. So possibly it's better to create own NBT file. I even found great article about that: http://www.minecraft...s-july-11-2012/. Problem that code in the acticle uses modloader and i don't know how to do the same with Forge. There is no method like getMinecraftDir() in server-side Forge.
Actually i can think up some workarounds but i prefer to use some "right way" to do that. So question is : "Is there any easy way to save player specific custom data or if not how to get minecraft save folder in Forge mod on server side?"
There is great thing called getEntityData. Looks Forge allow to add any custom data to any Entity object. getEntityData return NBTTagCompound where we can create mod specific section and save all required data.
Here is an example in case someone need to do the same:
On first start code create an integer value in player Entity. On second (even after MC restart) it show this value as chat message.
I used your tutorial, it works great.
DotCreeper, you should use it.EDIT: derp. very old post. ignore that last part.
Be sure to quote my post if you want a reply.
lol @ Cameronazzi copy-pasting my sig into his