Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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.

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]

  • Author

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.

  • Author

The values look a bit low to be game ticks, but you may be right, I should just do some tests.

  • Author

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.