阻止方块和流体进行随机刻或普通刻
随机刻(Random ticks)
游戏中的大多数方块都会执行 randomTick,这部分本身已经相当优化。然而,你拥有的方块越多,对服务器的压力就越大。甚至楼梯也会出于某些神秘原因执行 randomTick()。
阻止 randomTick() 是一个相对安全的选项。你只是阻止了一些机制的运行,比如铜的氧化、竹子的生长等。至少在原版中,我没有发现任何被禁止后会崩溃游戏的破坏性方块。我随机禁用了游戏中 50% 的所有方块,没有任何问题。
以下是来自性能分析器(profiler)的一些数据:
版本:Minecraft 1.20.1, Forge 4.30.0。
模组:NoRandomTicks 和 WorldEdit
方块:3800 个竹子,5800 个金合欢楼梯,4200 个白桦树叶
如何理解这些数字
原版:
[08] | | | | | | | | tickBlocks(40401/201) - 64.88%/5.94%
[09] | | | | | | | | | randomTick(53667/267) - 72.67%/4.32%
[10] | | | | | | | | | | #getChunkCacheMiss 4309/21
[10] | | | | | | | | | | #getChunk 97830/486
[10] | | | | | | | | | | unspecified(53667/267) - 82.14%/3.55%
[10] | | | | | | | | | | queueCheckLight(4755/24) - 8.67%/0.37%
[10] | | | | | | | | | | updateSkyLightSources(4755/24) - 8.45%/0.37%
[10] | | | | | | | | | | no_random_tick_check_blocks(6428/32) - 0.74%/0.03%
黑名单模式:
[08] | | | | | | | | tickBlocks(40401/201) - 40.26%/1.50%
[09] | | | | | | | | | unspecified(40401/201) - 75.91%/1.14%
[09] | | | | | | | | | randomTick(53064/264) - 24.09%/0.36%
[10] | | | | | | | | | | #getChunkCacheMiss 43/0
[10] | | | | | | | | | | #getChunk 882/4
[10] | | | | | | | | | | unspecified(53064/264) - 92.69%/0.34%
[10] | | | | | | | | | | no_random_tick_check_blocks(5231/26) - 7.31%/0.03%
将 +-1% 视为误差
| 原版 |
模组 |
差异 |
| tickBlocks(40401/201) - 64.88%/5.94% |
tickBlocks(40401/201) - 40.26%/1.50% |
+4.44% |
| randomTick(53667/267) - 72.67%/4.32% |
randomTick(53064/264) - 24.09%/0.36% |
+3.96% |
| no_random_tick_check_blocks(6428/32) - 0.74%/0.03% |
no_random_tick_check_blocks(5231/26) - 7.31%/0.03% |
无变化 |
普通刻(Ticks)
这个领域充满了惊喜。有些方块可能完全不受影响,而另一些方块可能会停止工作,或者只有一半的功能消失。例如 minecraft:fire,如果你禁止它进行刻更新,唯一会发生的事情是它不会销毁方块(如果设置在木头上为例)并熄灭。所以,基本上表现得像下界岩一样。
熔炉则毫不在意。因此,除非你了解某个方块的运作机制,或者准备好经历漫长的试错过程,否则我建议避免使用此功能。
流体
从版本 0.3 (1.21.1) 或 0.4 (1.20.1) 开始,你可以防止流体进行刻更新和随机刻更新。请谨慎使用该选项。没有刻更新的流体会永远保持为液体方块的状态,但它们会与周围环境和邻居交互。原版只有两种液体:水和岩浆,所以我的测试 somewhat 有限。只有岩浆具有随机刻方法,而它所做的就是点燃物体。你可以在游戏规则(gamerules)中切换这种行为,因此随机刻预防可能仅对其他模组的液体有用。还要记住,流体至少有两种类型:流动的和普通的。
调试
从版本 0.3 (1.21.1) 或 0.4 (1.20.1) 开始,我添加了在加载和重新加载配置时显示哪些被阻止以及哪些失败的功能。
正则表达式
从版本 0.4 开始
@pigporker (curseforge) 建议添加正则表达式支持,所以现在有了。正则表达式与每个方块的数组一起工作,在配置加载/重新加载时,它们会被合并为一个黑名单。你可以编写庞大的模式,也可以将它们划分为较小的模式数组,这取决于你。正则表达式非常有用但用户体验不佳,因此错误不受配置的 DEBUG 选项影响。它们始终处于开启状态。我试图使它们有用且详细,以帮助你调试。例如,一个混乱的模式会提示你问题所在:
[02:12:20] [modloading-worker-0/WARN] [NoRandomticksMod/]: Rejected invalid regex pattern '^[minecraft:.*': Unclosed character class near index 13
^[minecraft:.*
^
用法
在我看来,这个模组可以帮助你:
- 如果你在极其紧张的情况下,榨取一些性能。这是针对服务器的;请记住,这个模组对服务器的帮助远大于客户端。
- 在保留方块或流体的同时,阻止某些机制的发生。
- 调试
如果你想查看性能对比,请参阅模组 GitHub 页面上的 readme.md。
Stop blocks and fluids from random ticks or ticks
Random ticks
Most blocks in the game perform randomTicks and this part is quiet optimized in itself. Yet, the more blocks you have the bigger the strain on a server. Even stairs do randomTick() for some mysterious reason.
Preventing randomTick() is a somewhat safe option. You just prevent some mechanics from running, like copper weathering, bamboo growing. At least in vanilla I haven't found any breaking blocks that crash the game if they are banned. I have randomly selected 50% of all the blocks in the game and banned them. No issues.
Here is some data from profiler:
Versions: Minecraft 1.20.1, Forge 4.30.0.
Mods: NoRandomTicks and WorldEdit
Blocks: 3800 bamboo, 5800 acacia stairs, 4200 birch leaves
How to understand this numbers
Vanilla:
[08] | | | | | | | | tickBlocks(40401/201) - 64.88%/5.94%
[09] | | | | | | | | | randomTick(53667/267) - 72.67%/4.32%
[10] | | | | | | | | | | #getChunkCacheMiss 4309/21
[10] | | | | | | | | | | #getChunk 97830/486
[10] | | | | | | | | | | unspecified(53667/267) - 82.14%/3.55%
[10] | | | | | | | | | | queueCheckLight(4755/24) - 8.67%/0.37%
[10] | | | | | | | | | | updateSkyLightSources(4755/24) - 8.45%/0.37%
[10] | | | | | | | | | | no_random_tick_check_blocks(6428/32) - 0.74%/0.03%
Blacklisted:
[08] | | | | | | | | tickBlocks(40401/201) - 40.26%/1.50%
[09] | | | | | | | | | unspecified(40401/201) - 75.91%/1.14%
[09] | | | | | | | | | randomTick(53064/264) - 24.09%/0.36%
[10] | | | | | | | | | | #getChunkCacheMiss 43/0
[10] | | | | | | | | | | #getChunk 882/4
[10] | | | | | | | | | | unspecified(53064/264) - 92.69%/0.34%
[10] | | | | | | | | | | no_random_tick_check_blocks(5231/26) - 7.31%/0.03%
Consider +-1% as error
| Vanilla |
Mod |
Difference |
| tickBlocks(40401/201) - 64.88%/5.94% |
tickBlocks(40401/201) - 40.26%/1.50% |
+4.44% |
| randomTick(53667/267) - 72.67%/4.32% |
randomTick(53064/264) - 24.09%/0.36% |
+3.96% |
| no_random_tick_check_blocks(6428/32) - 0.74%/0.03% |
no_random_tick_check_blocks(5231/26) - 7.31%/0.03% |
no change |
Ticks
This territory is full of surprizes. Some blocks may be unaffected at all while others may stop working or only half of the functionality may be gone. E.g. minecraft:fire, if you ban it from ticking the only thing that will happen is it won't destroy block (if set on wood for example) and extinguish. So, basically behaves like on netherrack.
Furnaces don't give a shit. So, unless you know how a block works or ready for a long process of trail & error, I recommend to avoid this feature.
Fluids
Since version 0.3 (1.21.1) or 0.4 (1.20.1), you are able to prevent fluids from ticking and random ticking. Be careful with that option. Fluids without ticks just stay like a liquid block forever, but they will interact with the world and neighbors. Vanilla has only two liquids, water and lava, so my tests are somewhat limited. Only lava has a random tick method, and all that it does is set things on fire. You can toggle that behavior in the gamerules, so random tick prevention may be useful only for liquids from other mods. Also remember that fluids have at least two types: flowing and normal.
Debug
Since version 0.3 (1.21.1) or 0.4 (1.20.1), I've added the option to display on load and reload of the config what was blocked and what failed.
Regex
Since version 0.4
@pigporker (curseforge) suggested to add a regex support, so here it is. Regex works together with per block arrays, on config load/reload they are combined in one blacklist. You can write huge-ass patterns or divide them into an array of smaller patterns, it's up to you. Regex is super useful but not very user-friendly, so errors aren't affected by DEBUG option of the config. They are always ON. I tried to make them useful and verbose to help you debug. For example a messed up pattern hints you to a problem:
[02:12:20] [modloading-worker-0/WARN] [NoRandomticksMod/]: Rejected invalid regex pattern '^[minecraft:.*': Unclosed character class near index 13
^[minecraft:.*
^
Usage
The way I see it, this mod may help you:
- Squeeze some performance if you are in a really tight spot. This is for a server, remember; this mod helps the server way more than the client.
- Prevent some mechanics from happening while leaving the block or fluid.
- Debugging
If you want to see a performance comparison, see readme.md on the mod's GitHub page.
评论 0
登录后参与评分
还没有评论,来抢沙发吧