简体   繁体   English

如何在我的世界 mod 中强制使用游戏模式?

[英]How to force a gamemode in minecraft mod?

I am making this private modpack in Minecraft.我正在 Minecraft 中制作这个私人模组包。 It's all ready, but I need help with making a mod that forces all players to be in gamemode 2 (adventure mode), or just make players unable to place/destroy blocks.一切就绪,但我需要帮助制作一个强制所有玩家进入游戏模式 2(冒险模式)的 mod,或者只是让玩家无法放置/破坏方块。 How can I make a mod like that?我怎样才能制作这样的模组?

This is no online server, it is just meant to be in my mod pack in singleplayer.这不是在线服务器,它只是为了在我的单人游戏中出现在我的模组中。 (modpack is a collection of several mods). (modpack 是几个 mod 的集合)。 It is an apocalypse modpack, where players must raid houses, kill NPC players, hide during night etc. This is why I want the player who creates the world, automatically gets set to gamemode 2 (or atleast isn't able to build/destroy).这是一个启示录模组,玩家必须在其中突袭房屋、杀死 NPC 玩家、在夜间躲藏等等。这就是为什么我希望创造世界的玩家自动设置为游戏模式 2(或者至少无法建造/摧毁)。 NOTE: I have not created a single mod before, I did not make the mods in my modpack.注意:我之前没有创建过一个模组,我没有在我的模组包中制作模组。

Solution 1:解决方案1:

In your server.properties file, there are two options that can do this for you (you don't need a mod).在您的server.properties文件中,有两个选项可以为您执行此操作(您不需要 mod)。 This is also a vanilla thing so even if you switch to a server like spigot/bukkit, canary or plain vanilla, it will still work.这也是一个普通的东西,所以即使你切换到像 spigot/bukkit、canary 或普通香草这样的服务器,它仍然可以工作。

force-gamemode=true
gamemode=2

Solution 2:解决方案2:

You can also use a command block to force all players into a gamemode.您还可以使用命令方块强制所有玩家进入游戏模式。 If you have this command block going on a clock, all players will change gamemodes instantly apart from you (you must put in your name).如果你让这个命令方块在时钟上运行,除了你之外,所有玩家都会立即改变游戏模式(你必须输入你的名字)。

gamemode 2 @a[name=!<insert_your_username_here>]

If you use this method, you must remember to to enable command blocks on your server.如果您使用此方法,您必须记住在您的服务器上启用命令块。 This can also be done in the server.properties file by changing enable-command-blocks=true这也可以通过更改enable-command-blocks=trueserver.properties文件中完成

Edit:编辑:

Since you have said it isn't a server, look up some forge mod making tutorials.既然你说它不是服务器,那就找一些锻造模组制作教程。 Wuppy has some good tutorials so check them out: http://www.wuppy29.com/minecraft/modding-tutorials/forge-modding-1-8/ Wuppy 有一些很好的教程,请查看: http ://www.wuppy29.com/minecraft/modding-tutorials/forge-modding-1-8/

Futhermore: Once you have got the basic mod set up, you will want a player login event that sets a player's gamemode to gamemode 2. The other method would be to deny all block placement and break events.此外:一旦您设置了基本模组,您将需要一个玩家登录事件,将玩家的游戏模式设置为游戏模式 2。另一种方法是拒绝所有方块放置和中断事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM