Jump to content

Recommended Posts

Posted

Hi !

I'm trying to access the time since the last death of the player. I know it's somewhere with StatList.timeSinceDeathStat but I don't see any method that could indicate in which variables the time is stored.

There isn't a lot of documentation about using the ingame stats for modding.

 

If anyone knows how they work, I would be glad to learn.

Posted

I would increment a ticker right after subscribing to the LivingDeathEvent. Check the instance of the entity in the LivingDeathEvent against the EntityPlayer, then increment your counter in ticks (use another event, such as the ClientTickEvent - remember to check the player instance and event.phase == Phase.Start or Phase.END, otherwise your code runs twice per tick). This way, you have complete control of when your counter increments and when it stops.

 

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

Posted

I would increment a ticker right after subscribing to the LivingDeathEvent. Check the instance of the entity in the LivingDeathEvent against the EntityPlayer, then increment your counter in ticks (use another event, such as the ClientTickEvent - remember to check the player instance and event.phase == Phase.Start or Phase.END, otherwise your code runs twice per tick). This way, you have complete control of when your counter increments and when it stops.

 

Clever, but if the game already does that for us I suppose it's better to use it.

 

EntityPlayerMP#getStatFile().readStat(StatList.deathsStat)

 

Worked perfectly, thank you. I don't know what is the time unit of this value, but I'll figure out by testing.

Posted

Don't worry I knew you wanted to write this one, I was already using the good statistic ;)

I don't know if there is a way to make reliable measurements but it looks like the time is in seconds (the ticks are probably divided when added to the stats, maybe to get lower numbers ?) but checking the source would be the only way to know for sure of course.

Thanks a lot ! My problems are now solved.

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.