Ok, so I've found out that on servers, it just deletes the saved player data on death. However, if you log out and log back in, then it keeps your data. (Regular log out, not the weird death/logout from above).
Please please please is there any way to fix this
The post just above yours has an idea you could try - forcing the player to write to the dat file when the player dies, rather than just on logout. I don't have time to mess with it myself just now, but it should work fine.
Ok. I tried removing the "!world.isRemote" line where it saves the data in livingDeathEvent, and now it works! Are there horrible side effects to this that I will regret shortly?
I had trouble figuring out a different solution that would work (a lot of what Minecraft does seems terribly irrational and inefficient to me, which really doesn't help). I did have a fiddle with a few persistent world data things and stuff, but I concluded that with my limited knowledge of Forge and MCP inner workings, it was going to be more reliable to simply store the data in my own file in the world folder, and I haven't had a single problem with it since.
Frick. When I first started working on this, I was handling all my player NBT manually - now I've moved it all over to this player extended properties thing, noooo!
It sounds to me like this is a Forge "bug", and by bug I mean a feature lacking i.e. there needs to be a way to manually save extended properties for each player on events world unload and/or player logout; or - probably easier - the relevent extended properties event needs to be fired when the player does this quit-to-title thing.
EDIT: Didn't see your reply coolAlias. How would one manually call this saveNBTData method when LivingDeathEvent is fired? Just, the usual way with nothing special?
I haven't tried this, but you can get the current save handler from the World object, and then save the player data using that; again, this must be on the server side:
ISaveHandler saveHandler = player.worldObj.getSaveHandler();
IPlayerFileData playerSaveHandler = saveHandler.getSaveHandler();
if (playerSaveHandler != null) { // apparently it may be null in SMP, in which case I'm not sure what to do
playerSaveHandler.writePlayerData(player);
}
If you look around in ISaveHandler, World, WorldInfo, and even ServerConfigurationManager, you will find more stuff related to saving the player.
There is probably a simpler and better way of saving data, and the above may not even work, but it may be enough to get you started.
@Nexus - if it's just giving you 'can't keep up' messages, that can happen when first joining the world, even in completely unmodded Minecraft. If you get a crash, then you need to post your crash report.
That is not a crash log... try reading your whole crash log, and I bet you will see something like "Caused by: Null pointer exception at line: xxx" which will point to your "props.getSomething()". That's my guess. But again, what you posted is not a crash log, by any means, and is not very helpful in solving your crash.
I think you missed the spoiler to open cuz that contains the crash log
Derp... yeah, I totally missed it, my bad Well, that tells you what is null; is your Gui an overlay? Because if it is, the player's extended properties can be null when the game is first loading, but the screen still tries to render - you have to null check (which, if you don't know what that is, google 'Null Pointer Exception' and you'll get all the info you'll ever need about it).
Okay, but did you at least search for 'Null Pointer Exception'? You can still null check to prevent the crash, but you need to find out why the fields you are trying to access are null. Remember, you are accessing properties client side, so you need to be sending the data from the server to the client to ensure the fields are set and have the correct values.
So deleting the !isRemote line actually did NOT fix the problem Is there any way to make the IEE data to persist through death on a server? This is the only thing holding my mod back from release
Any help would be awesome, I've tried lots of different things
Yeah but didn't your tutorial fully cover this, all I did again was just adding in those few methods and variables. I added them in to the sync method and into the packet handler in the same order so that shouldn't be the problem. I made it so everyone starts out with 0 of all of the above stats using the constructer... I'm really starting to lose myself, I've been trying to figure out what the problem could be for about a week or so now. I still find it strange that it suddenly broke down on me randomly when I didn't even touch any line of code that uses the event handler, packethandler or extended prop...
Yes, the tutorial covered it, but not in the way you think; just adding all your stuff to the 'sync properties' packet/method is not enough, and certainly isn't the point of that - that was merely a demonstration of how you can go about synchronizing data and an introduction to packets, but you should be making your own packets for each piece or collection of data that you need to send to the client, and then make sure to send those packets whenever needed, because they don't get sent automatically (neither does the 'sync' packet I made).
At any rate, it sounds like you may need to take a break, get some sleep, and try again later when your head is more clear and you may be able to see your code in a different perspective. When you're ready, search for help on using Eclipse's debugging mode (or your whatever IDE you are using), as it allows you to step through your code in real time and see what each variable is.
So deleting the !isRemote line actually did NOT fix the problem Is there any way to make the IEE data to persist through death on a server? This is the only thing holding my mod back from release
Any help would be awesome, I've tried lots of different things
You most certainly don't want to remove that line - '!isRemote' means the code is currently running on the server, which is where you want to be for saving/loading. The tutorial covers how to persist data through death, though apparently it breaks if you die and quit rather than respawning - I posted a possible solution on the previous page.
So you are telling me to create new ExtendedPlayers for each(in this case) player stats?
Take a look at my mod, download the whole source as a ZIP if you like. I have packet sending to and from the server in various places for extended playyer properties working perfectly, with the one IMessage class.
Classes of note are:
medata.player.MinecraftEmpiresPlayer.java (extended player properties)
server.* (packet stuff)
...and do a search for calls to "syncToClient" method and "syncToServer" for places where I send packets to a client or to the server (respectively).
EDIT: Also check my proxies, there is a shared method in both for getting the player instance depending on if the call was client or server side (thanks to... I can't remember who I got that from, sorry! But they're in my credits)
So you are telling me to create new ExtendedPlayers for each(in this case) player stats?
How did you come away from my post with that impression? I told you to take a break and then learn how to use your IDE's debugging capabilities, and that following the tutorial's sync code exactly doesn't make any sense - you have to take some time to understand what the point of sending packets is, why you might want to send one packet with all of your data, and why that's also a terrible idea under most circumstances, all of which I pointed out in the tutorial. Please read it carefully, not just the code, but the explanations, and make sure you understand what each section of code is doing, why I've done it that way, and why that might not be the same way you want to do it.
If you have trouble understanding what the code is doing and why, then please take some time to review Java, client-server communication, and whatever else you need - the whole internet is out there with plenty of resources for you to gain the knowledge you need, but you need to be proactive and do some work yourself; it doesn't do you any good if I or anyone else understand what's going on and you don't.
So again: take a break; get refreshed; learn to use your IDE; use the resources you have (the entire internet!!!) to understand your problem, including learning more Java or logic if that is necessary; solve your problem. Trust me, it may not be easy to do all of those things, but if you put in the time to learn it yourself, it will pay off 100 times over.
why you might want to send one packet with all of your data, and why that's also a terrible idea under most circumstances
This will be a problem in my example, you might see in the IMessage that I convert an entire list to a string and send it, then rebuild as a list when it arrives - it would be far better to send only the relevant string, I've just not gotten to that point yet. But what he means is you should have a seperate IMessage class specific to what data needs updating, but that doesn't apply to me in this particular case, at least not yet - but it probably will later on.
With making the data persistent through deaths.. What would happen if a player died, but didn't click respawn before the server stopped for some reason.
With making the data persistent through deaths.. What would happen if a player died, but didn't click respawn before the server stopped for some reason.
Would the data then be permanently lost?
When the player rejoins the world the next time, they will load the last data saved, so any data that had changed between the last save and the time they died would be lost, yes. On a server, this is usually never more than a few minutes worth of play time due to periodic saving.
So, sorry to keep bringing this back, but my data still won't persist through death on servers I posted my code a while back, but it's basically just the same as yours. No crashes or anything, just everything resets after death. Works fine in single player, just on servers will not save.
Sorry if you've answered this, and I just don't understand for some reason...
You should really update the packet handling information to use SimpleNetworkWrapper and IMessage, they're simpler and recommended by cpw over the way Netty was used in Netty Packet Handling wiki page.
You should really update the packet handling information to use SimpleNetworkWrapper and IMessage, they're simpler and recommended by cpw over the way Netty was used in Netty Packet Handling wiki page.
Of course cpw will recommend his own code over something else, especially now that he finally fixed it (you do realize SimpleNetworkWrapper was broken for a long time, which is why the alternate networking implementations existed in the first place?).
To quote myself from earlier:
Quote from coolAlias
I know, I just haven't had time to update entirely yet. The old Netty tutorial code works just fine for those who are still using it (all my mods still use it...), and now that SimpleNetworkWrapper finally works, using that is a piece of cake (though I'm working on something a bit more interesting, if I can get it to work properly).
So anyway, all the code presented here is still fully functional, including the outdated network code, though you should update that to the SimpleNetworkWrapper if you can. If you can't do that by yourself, then you'll just have to wait until I get time to update the tutorial, sorry.
Btw, there is no "should" involved with me updating this page - I write it in my spare time for free to help other people. Aside from that and real life, every time I edit a page these days, there is no telling what will happen to my formatting, code, etc., so I'm also waiting for the forum's editor to become more stable.
That was kind of a bad worded request, I'm really sorry if it did an offense to you.
I actually really thank you for your tutorials, I don't know how I would've coded without your Extended Properties tutorial, I always over-complicate things
That was kind of a bad worded request, I'm really sorry if it did an offense to you.
I actually really thank you for your tutorials, I don't know how I would've coded without your Extended Properties tutorial, I always over-complicate things
I kind of over-reacted as well, so sorry. I've just been getting lots of update requests for various things from people these days, none of which I really have time for, and, well, I let it get to me when I shouldn't have.
Anyway, the great thing is that the tutorial isn't really about packets, so you can use whatever network/packet system you feel comfortable with while following the tutorial. I may just remove the packet info entirely from the tutorial and make that knowledge a prerequisite so that people don't feel tied to any one implementation - many modders have, for various reasons, written their own network implementations instead of using SimpleNetworkWrapper, many of which are perfectly viable alternatives. Point being: use whatever packet system you feel comfortable with, as the only thing that is relevant to this tutorial is that you can send data from one side and receive it on the other - how you do it doesn't matter
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumThe post just above yours has an idea you could try - forcing the player to write to the dat file when the player dies, rather than just on logout. I don't have time to mess with it myself just now, but it should work fine.
Bleach Mod
Frick. When I first started working on this, I was handling all my player NBT manually - now I've moved it all over to this player extended properties thing, noooo!
It sounds to me like this is a Forge "bug", and by bug I mean a feature lacking i.e. there needs to be a way to manually save extended properties for each player on events world unload and/or player logout; or - probably easier - the relevent extended properties event needs to be fired when the player does this quit-to-title thing.
EDIT: Didn't see your reply coolAlias. How would one manually call this saveNBTData method when LivingDeathEvent is fired? Just, the usual way with nothing special?
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumISaveHandler saveHandler = player.worldObj.getSaveHandler(); IPlayerFileData playerSaveHandler = saveHandler.getSaveHandler(); if (playerSaveHandler != null) { // apparently it may be null in SMP, in which case I'm not sure what to do
playerSaveHandler.writePlayerData(player);
}If you look around in ISaveHandler, World, WorldInfo, and even ServerConfigurationManager, you will find more stuff related to saving the player.
There is probably a simpler and better way of saving data, and the above may not even work, but it may be enough to get you started.
-
View User Profile
-
View Posts
-
Send Message
Curse Premium-
View User Profile
-
View Posts
-
Send Message
Curse Premium-
View User Profile
-
View Posts
-
Send Message
Curse PremiumDerp... yeah, I totally missed it, my bad
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumAny help would be awesome, I've tried lots of different things
Bleach Mod
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumYes, the tutorial covered it, but not in the way you think; just adding all your stuff to the 'sync properties' packet/method is not enough, and certainly isn't the point of that - that was merely a demonstration of how you can go about synchronizing data and an introduction to packets, but you should be making your own packets for each piece or collection of data that you need to send to the client, and then make sure to send those packets whenever needed, because they don't get sent automatically (neither does the 'sync' packet I made).
At any rate, it sounds like you may need to take a break, get some sleep, and try again later when your head is more clear and you may be able to see your code in a different perspective. When you're ready, search for help on using Eclipse's debugging mode (or your whatever IDE you are using), as it allows you to step through your code in real time and see what each variable is.
You most certainly don't want to remove that line - '!isRemote' means the code is currently running on the server, which is where you want to be for saving/loading. The tutorial covers how to persist data through death, though apparently it breaks if you die and quit rather than respawning - I posted a possible solution on the previous page.
Take a look at my mod, download the whole source as a ZIP if you like. I have packet sending to and from the server in various places for extended playyer properties working perfectly, with the one IMessage class.
Classes of note are:
medata.player.MinecraftEmpiresPlayer.java (extended player properties)
server.* (packet stuff)
...and do a search for calls to "syncToClient" method and "syncToServer" for places where I send packets to a client or to the server (respectively).
EDIT: Also check my proxies, there is a shared method in both for getting the player instance depending on if the call was client or server side (thanks to... I can't remember who I got that from, sorry! But they're in my credits)
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumHow did you come away from my post with that impression? I told you to take a break and then learn how to use your IDE's debugging capabilities, and that following the tutorial's sync code exactly doesn't make any sense - you have to take some time to understand what the point of sending packets is, why you might want to send one packet with all of your data, and why that's also a terrible idea under most circumstances, all of which I pointed out in the tutorial. Please read it carefully, not just the code, but the explanations, and make sure you understand what each section of code is doing, why I've done it that way, and why that might not be the same way you want to do it.
If you have trouble understanding what the code is doing and why, then please take some time to review Java, client-server communication, and whatever else you need - the whole internet is out there with plenty of resources for you to gain the knowledge you need, but you need to be proactive and do some work yourself; it doesn't do you any good if I or anyone else understand what's going on and you don't.
So again: take a break; get refreshed; learn to use your IDE; use the resources you have (the entire internet!!!) to understand your problem, including learning more Java or logic if that is necessary; solve your problem. Trust me, it may not be easy to do all of those things, but if you put in the time to learn it yourself, it will pay off 100 times over.
No problem, I had a lot of trouble at first too but after some more help and experimenting it all became clear
EDIT: Also in reference to what coolAlias just said:
This will be a problem in my example, you might see in the IMessage that I convert an entire list to a string and send it, then rebuild as a list when it arrives - it would be far better to send only the relevant string, I've just not gotten to that point yet. But what he means is you should have a seperate IMessage class specific to what data needs updating, but that doesn't apply to me in this particular case, at least not yet - but it probably will later on.
Would the data then be permanently lost?
Continuing Advent of Ascension 2.0
Want to suggest something? Come to the forum thread!
Download the latest version here: http://tslat.net/Hosting/Tslat-AoA/AoA-Tslat-1.1.3.jar
Mirror: http://www.mediafire.com/file/6vldb34u9vg7bou/AoA-Tslat-1.1.3.jar/file
View the changelogs here: https://pastebin.com/L0ThhruE
Want to chat about the mod while I'm updating it?
Join the Discord channel: https://discord.gg/DNYqNNq
Want to support me and the server on Patreon?
https://www.patreon.com/Tslat
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumWhen the player rejoins the world the next time, they will load the last data saved, so any data that had changed between the last save and the time they died would be lost, yes. On a server, this is usually never more than a few minutes worth of play time due to periodic saving.
Sorry if you've answered this, and I just don't understand for some reason...
Bleach Mod
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumOf course cpw will recommend his own code over something else, especially now that he finally fixed it (you do realize SimpleNetworkWrapper was broken for a long time, which is why the alternate networking implementations existed in the first place?).
To quote myself from earlier:
Btw, there is no "should" involved with me updating this page - I write it in my spare time for free to help other people. Aside from that and real life, every time I edit a page these days, there is no telling what will happen to my formatting, code, etc., so I'm also waiting for the forum's editor to become more stable.
I actually really thank you for your tutorials, I don't know how I would've coded without your Extended Properties tutorial, I always over-complicate things
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumI kind of over-reacted as well, so sorry. I've just been getting lots of update requests for various things from people these days, none of which I really have time for, and, well, I let it get to me when I shouldn't have.
Anyway, the great thing is that the tutorial isn't really about packets, so you can use whatever network/packet system you feel comfortable with while following the tutorial. I may just remove the packet info entirely from the tutorial and make that knowledge a prerequisite so that people don't feel tied to any one implementation - many modders have, for various reasons, written their own network implementations instead of using SimpleNetworkWrapper, many of which are perfectly viable alternatives. Point being: use whatever packet system you feel comfortable with, as the only thing that is relevant to this tutorial is that you can send data from one side and receive it on the other - how you do it doesn't matter