Skip to content

[1.16.4 Forge] 如何用配置文件控制指令的注册与否? #96

Answered by 3TUSK
ScottCTD asked this question in Q&A
Discussion options

You must be logged in to vote

@ScottCTD

命令的注册不仅仅可以在 RegisterCommandsEvent 中注册,也可以在其他事件注册

不行的,这个事件存在的原因是 /reload 命令执行后会「刷新」命令;在原来的设计中(FMLServerStartingEvent.getCommandDispatcher),注册的命令会因为 FMLServerStartingEvent 并没有再次发布而全部失效。

因此才会多出来一个专门的注册命令的事件,从而正确实现 /reload 的行为。命令只有在这里注册才能避免 /reload 时被刷掉。关于这个原版命令的用途可参考中文 MinecraftWiki 上的说明

正如我一开始说的那样,「这里面有一些意想不到的坑」。我还是建议你不要这么做。

参考来源:Forge Issue Ticket #6968

Replies: 5 comments 6 replies

Comment options

You must be logged in to vote
1 reply
@ScottCTD
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@ScottCTD
Comment options

Answer selected by ScottCTD
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@ScottCTD
Comment options

@3TUSK
Comment options

@ScottCTD
Comment options

@SeraphJACK
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants