NoBadBooms!
一个面向服务器的 NeoForge 1.21.1 模组,新增了一个名为 tntExplodes 的游戏规则(gamerule),类似于基岩版的行为,允许你阻止 TNT 破坏方块。
用法
/gamerule tntExplodes false
当设置为 false 时,TNT 方块和 TNT 矿车仍然会被点燃并爆炸(引信燃烧、音效、粒子效果、击退以及实体伤害均正常触发),但不会破坏任何方块。默认值为 true(原版行为)。
该规则基于世界保存,与原版其他游戏规则一样。
注意:这与基岩版略有不同,在基岩版中 tntExplodes false 会完全阻止 TNT 被点燃。在此模组中,爆炸仍然会发生——仅禁用了地形破坏。其他爆炸源(苦力怕、恶魂、床、末影水晶)不受影响;苦力怕的破坏行为已由原版的 mobGriefing 规则控制。
仅限服务器端
将 jar 文件安装到服务器的 mods 文件夹中。原版/未加载模组的客户端可以正常加入。如果在客户端安装了此模组,也可以在单人游戏中使用。
工作原理
- 在模组类初始化期间,通过
GameRules.register("tntExplodes", Category.MISC, BooleanValue.create(true)) 注册游戏规则(NeoForge 的访问转换器使这些方法变为公开)。
- 监听
ExplosionEvent.Detonate 事件,该事件在爆炸计算出受影响的方块之后、但在任何方块被破坏之前触发。如果爆炸的直接来源实体是 PrimedTnt 或 MinecartTNT,且游戏规则为 false,则清空受影响的方块列表。
注:开发此模组是为了解决我服务器上某个小游戏遇到的问题。我不确定是否还会继续更新。我相信更新并不会太难,因此欢迎从源代码编译并根据需要自行修改。这是一个工具,按需取用即可。
NoBadBooms!
A server-side NeoForge 1.21.1 mod that adds a tntExplodes gamerule, similar to
Bedrock Edition, letting you stop TNT from destroying blocks.
Usage
/gamerule tntExplodes false
When false, TNT blocks and TNT minecarts still ignite and detonate (fuse, sound,
particles, knockback, and entity damage all still happen), but no blocks are
destroyed. Default is true (vanilla behavior).
The rule is per-world and saved like any vanilla gamerule.
Note: this differs slightly from Bedrock, where tntExplodes false prevents TNT
from igniting at all. Here the explosion still occurs - only terrain damage is
disabled. Other explosion sources (creepers, ghasts, beds, end crystals) are
unaffected; creepers are already covered by vanilla's mobGriefing.
Server-side only
Install the jar in the server's mods folder. Vanilla / unmodded clients can
join normally. It also works in single-player if installed on a client.
How it works
- Registers the gamerule with
GameRules.register("tntExplodes", Category.MISC, BooleanValue.create(true))
during mod class initialization (NeoForge's access transformers make these public).
- Listens to
ExplosionEvent.Detonate, which fires after the explosion has computed
its affected blocks but before anything is destroyed. If the explosion's direct
source entity is a PrimedTnt or MinecartTNT and the gamerule is false, the
affected-block list is cleared.
Note: This was to solve an issue with a minigame on my server. I don't know if I will ever update it. I don't imagine it will be hard to update, so, feel free to compile from source and change however you want. It's a tool, use it if you need.
评论 0
登录后参与评分
还没有评论,来抢沙发吧