Jump to content

Recommended Posts

Posted

So i was having this issue, when a player dies and completing our quest system his savestate becomes the null making him spawn on void. So my hypothesis to fix this problem is looking up for some forge hooks regarding the "Respawn" Button

Posted

If your quest-system makes use of the Capability System, you need to transfer the data to the "new" player, as mentioned in Forge's documentation.

https://mcforge.readthedocs.io/en/latest/datastorage/capabilities/#persisting-across-player-deaths

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Posted
  On 11/15/2017 at 2:31 PM, Matryoshika said:

If your quest-system makes use of the Capability System, you need to transfer the data to the "new" player, as mentioned in Forge's documentation.

https://mcforge.readthedocs.io/en/latest/datastorage/capabilities/#persisting-across-player-deaths

Expand  

I hope i can make my english more understandble.

 

Sorry for my late reply, but apparently we didnt use capablity for the quest system.. What we did is we use JsonElement for our save data and just define it in the class (urghhh how can i explain it )

 

anyways here is our Mission Class

 

  Reveal hidden contents

 

Posted (edited)

When a player dies (and during dimension travel) the player instance is removed, and a new instance is made. This is likely why the "save-state" is null.

You will need to transfer the data just like with Capabilities.

Oh, and you should not store the EntityPlayer (or derivatives like EntityPlayerMP) directly. You should be using a WeakReference<EntityPlayerMP> instead.
Storing an EntityPlayer can cause memory leaks. What if the player dies repeatedly? A new savestate would exist for each player instances, and the old player instances would not be garbagecollected because they're still being referenced.
A WeakReference allows the garbagecollector to remove the player from memory in case of death/log outs etc.

 

Alternatively use the UUID instead, and get the EntityPlayer from that.

Edited by Matryoshika

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.