Deltatime 图标

Deltatime

作者:rebot | 分类:模组

价格:0 墨喵币 下载量:0 点赞:0 版本 0.0.3
本资源为搬运资源,原资源地址: https://modrinth.com/mod/deltatime-datapack
资源信息

Minecraft 版本: 1.21

平台: datapack

标签: library optimization utility

资源介绍

WARNING!

  • this pack was designed to be used with Multi world border mod
  • if you don't use this mod, you need to adjust the minimal diameter of the worldborder in the datapack (decreasing accuracy) to avoid getting unexpected worldborder damage

Scoreboard values

Scoreboard objective: deltatime

  • tickdelta -> previous tick duration (defaultly in milliseconds) (maxes out at 10 seconds by default)
  • tickstoadd -> number to add to a counter, which you don't want to be affected by lags (more info below on how to use it effectively)
  • accuracy <- the accuracy of the timings (defaults to 1000 -> milliseconds)
    • for even more accuracy, you need to edit this datapack's worldborder's minimal values
    • for even even more accuracy, you need to use my mod with the same name

How to use tickstoadd

example:

scoreboard players operation untilactionprev objective = untilaction objective
scoreboard players operation untilaction objective -= tickstoadd deltatime
execute if score untilaction objective matches ..20 unless score untilactionprev objective matches ..20 run function my:action1
execute if score untilaction objective matches ..0 unless score untilactionprev objective matches ..0 run function my:action2
  • In this example, we are trying to run "function my:action2" after "untilaction objective" ticks run and a "function my:action1" 1 second before it.
  • If we want to make it independant of server performance, we need to add a larger number of ticks to the counter, if the server lags.
  • This means that there is a possibility that the counter jumps over the 20 or 0.
  • In order to prevent the actions from not executing, we need to have another variable, which tells us the tickcount before the tickstoadd get added (subtracted). Then we need to check if the previous count is higher than our desired value and the current count is exactly or less than our desired value.

If you just want to time one action, you can just check for ..0 without the helper variable

(note that if you set the counter to a lower/higher (according to the direction of counting) value while the counter is counting and you won't also change the previous count, it will execute everything in between the previous and current value)

How does the datapack work?

  • worldborder in minecraft does not time itself based on ticks but on real seconds
  • this makes it possible to calculate the time by changing the border's size with a set duration
  • the next tick just get the border's size and calculate how much time passed based on how much has the border changed

Also check out the mod version for even better accuracy! (although even less maintained)

下载太慢?试试 墨喵加速站,支持 Modrinth 和外网直链高速下载! 用的人越多,下载的越快!
下载与版本
评论(0)
登录 后发表评论。

暂无评论,抢个沙发吧~

举报此资源

请登录后举报

🔥 相关推荐
Random Colored Phantom

价格:0 墨喵币
下载量:0

查看详情
Wanderer's Dream

价格:0 墨喵币
下载量:0

查看详情
Condensed Copper Recipes

价格:0 墨喵币
下载量:0

查看详情
Slime Juice

价格:0 墨喵币
下载量:0

查看详情