Minecraft Wiki

除另有声明,转载时均必须注明出处若簡繁轉換出錯,請以遊戲內為準请勇于扩充与修正内容有兴趣逛逛我们的微博沟通交流,欢迎到社区专页需要协助,请在告示板留言

了解更多

Minecraft Wiki
Advertisement
Ic translate
此条目的(部分)内容需要翻译。

你可以帮助我们来翻译此条目,但请勿使用机器翻译

命令方块可以帮助冒险模式,自动化多人生存以及自定义地图。要了解更多相关的内容,访问命令方块页面。

在单人中的应用 (SSP)

命令方块可以在单人模式中使用,用于更改难度,更改天气状态,或者给你预先设置好的物品。用它使用/weather 和 /time set x这两个命令是很有用的,否则这两个命令只能用在开启作弊指令的情况下.。/time set x 这个命令时很有用的,它允许你在按下一个按钮后改变时间到预定的时间。命令方块也可以用来发送文字到人们的聊天栏中。要做到这点,向地下挖两格,放置一个命令方块到洞的底部, 把这个输入命令方块: tell @p <信息> 或者 tell <玩家ID> <信息>然后在命令方块上面放一个方块,在方块顶上放一个踏板。如果你输入的是@p,那么当有人踩在上面时会收到一个信息,不管是什么人。如果你输入的是<玩家ID>当你或其他人踩在上面时,命令方块中输入的玩家将会收到一条在聊天栏里的信息: @ whispers to you: <信息>。你也可以输入: tell <你的ID> @p 当玩家踩到踏板时你会收到一个信息: ''@ whispers to you: <玩家ID> ',这样就可以得知谁到达了某个位置了。但是如果一个生物踩到了踏板,那么你会收到离命令方块最近的玩家的ID而不是生物名。如果你想改变游戏中的难度那么用 /difficulty x,x是0-3 或者难度名。(例如 /difficulty peaceful)。

电梯

你还可以用它做一个电梯: /tp ~0 ~y ~0,其中y是电梯上升的高度。 电梯也可以直接做成传送玩家到固定的x y z坐标点。当~在命令中时,原来的x y z将都等于0,这些坐标指触发命令方块的压力板的坐标(踩在压力板上玩家的坐标)。如果压力板在x y z坐标分别是-36 96 -12的地方收到命令方块的指令/tp @p 〜3 〜4 〜5 就会传送玩家到坐标-33 100 -7。/tp @p -34 100 -8 可以达到相同的效果,但是注意要加上一个方块以获得正确的坐标。

自动人行道

类似电梯的概念,但是通过让玩家沿x或z坐标移动。 这可以通过下列方式创建:

    1.建立一条黑曜石带道路
    2.在这条黑曜石带半路下放置一个命令方块并输入以下命令:

/tp @a(或者要是你想要指定某个玩家你可以改成/tp 玩家ID) <type ~[1 if you want to move along the x axis] ~0 ~[1 if you want to move along the z axis]> [r=(length of sidewalk / 2)

    3.启动命令方块

这将使它看起来像或者行动上像人是在一个移动的人行道上。 注:建议打开命令方块输出关闭。

永恒的昼/夜

Time reseter

通过使用蜘蛛网和一个矿车,就能使用/time set 0跳过夜晚。矿车需要31秒才能从蜘蛛网上掉下。所以,使用23个堆积起来的蜘蛛网和一个探测铁轨几个充能铁轨将会保持太阳在天上。

你也可以使用木质压力板上物品消失完成。物品5分钟后会消失,这时会触发命令方块重置时间位0,并且触发发射器(或投掷器)丢新物品到木质压力板上。5分钟就是一天,并且是生物生成之前。按这样极限是64x9个物品 = 576 天 = 48 小时当这个区块加载的时间。在快照13w01a或更高版本,漏斗被加入了游戏,那就能够捡起物品并且存放在方块的物品栏中。刷怪塔能使发射器充满火药,箭和腐肉。

这些都要求这个区块被加载时才能工作。

你也可以用循环红石连接命令方块,比如一个five-clock,some type of loop, or a daylight sensor as seen on the right. 为了预防“将时间设置为0”的消息充满整个聊天框,通过/gamerule commandBlockOutput false将游戏规则“commandBlockOutput”设置成否。注:这也可以使用在一些其他的用途上并且使用其他的命令。(即,永恒的晴天可以使用其他的循环红石连接命令方块/weather clear)

使用阳光传感器能更直接产生永恒的白天。

Automatic Time Resster view 1 Automatic Time Reseter view 2

当阳关传感器不发出红石信号时,红石火把将激活命令方块将设置时间为80000。换句话说,当天很黑时命令方块将把时间设置为中午。The light level when the command will be activated varies with the distance of the Redstone wire. The time it sets to varies with the time typed in the Command Block.

Automatic Time Reseter view 3

要制作它,你首先需要将阳关传感器放在露天场地。然后从他开始放一些红石走。红石线的距离取决于你的需要的设置的时间。你最多可以放15格红石。然后,放个方块在红石的另一端,在方块的边上放红石火把然后在红石火把上面放命令方块。鼠标右键单击命令方块然后以"/time set "开头然后在末尾输入一个有效的时间数字。这个数字取决于你想设定的时间。14000是晚上,8000是中午.

Automatic Time Reseter

这样的设计可以用在地图上,以保持它的昼/夜一定的时间。这个简单的玩意儿只能用在创造模式或当你启用作弊。

这里有一个更精简的设计。如果你把阳光传感器连接到红石比较器和一个15强度红石线(1红石旁边放上红石火把)到第二输入端。然后设置红石比较器为减法模式。红石比较器将在中午后激活右侧。

无线红石

Wireless Redstone can be achieved in vanilla Minecraft using 命令方块 and the scoreboard system. The process involves using a scoreboard variable that is searched for by a command block attached to the output of a clock circuit. A comparator is then used on the wireless output command block that will trigger when the variable is found true.

Wireless Redstone can also be achieved by using objectives instead of variables. If the output command block is set to try and remove a non-existent objective, a redstone signal can be created by adding said objective via command block or chat command. The advantage to this method over the variable method is that it is not dependent on players.

初学者工具包

By using m=, you can make a kit on a server/custom map that can only be obtained once! First, dig 3 squares down in the ground, then place a row of command blocks (one for each item in the kit). In the GUI, type "/give[m=<starting gamemode, in number form>] <item id> <amount>". Do this for each item you wish to give. Make an extra command block that has the command "/gamemode <a different gamemode than the starting mode>", then string redstone across all of the command blocks (this can be done easily by squatting and placing). Fill in the hole and place a pressure plate over it. When players walk over it, they will get the desired kit of items and it will change their gamemode so they cannot receive it anymore (unless cheats are used)

非创造模式下使用命令方块 (此方法仅限单人)

By swapping gamemode it is possible to use command blocks in single player outside of creative mode. Simply swap to creative mode with the /gamemode 1 command, set the command block command to whatever you want, then swap back to /gamemode 0. The command block only needs to be set in creative, but will still function once back in normal.

It can also be used to teleport to certain areas (for ex. a far-away Stronghold, a deep mining operation, or a floating island). If it took you a very long time to get there, and if you don't mind sort-of cheating, then you can set up a teleport system. Make sure that you are on Creative mode while setting it (use the command /gamemode 1. If you don't have cheats enabled, open the LAN and set the cheats on), but you can stil activate it in Survival mode. Type this command in when having the Command Block GUI open /tp [@p,r or a] x y z . Then, activate the command block with redstone (including buttons, levers, and pressure plates), and you will be sent to your far-away destination. You can set up multiple different teleports. This can also be used when doing a big project that spans over a very large area or if you are transferring chests to from an old house to a newer house.

冒险地图制作

如果某些人想创作一个单人冒险地图,那么请记住一定要禁止让玩家自定义命令方块和使用指令。

在多人中的应用 (SMP)

这个章节详细介绍了命令方块在多人游戏中的应用。

  • 传送/运输

通过 /tp指令,可以制作一个所有人都可以使用的传送装置。可以在每个地方都使用。 例如,在整个世界里做一个庞大的传送系统,所有的传送点入口都汇集到传送大厅中,而传送大厅可以进入每个传送点入口处进而达到出口。这样就可以建造一个“快速交通中心”了。

  • "定格动画"

通过使用/tp,或者Minecraft地图编辑器,例如MC地图编辑器可以复制一张图片(利用方块做出来的绘画),然后粘贴到一处遥远的地方,并变动绘画的一些方块,利用一些压力板或者绊线钩,在玩家短时间欣赏绘画后,命令方块做出/tp指令,将玩家传送到下一张绘图点. 如果大量的复制粘贴这样的零件,让玩家按顺序的在这些之间传送并稍稍弄出一点点的延迟,那么玩家就会产生幻觉,认为这个绘画是在运动的(甚至认为是某MOD做出来),这就是利用命令方块来实现定格动画技术。

  • 抽奖

/give @r命令,可以创造一个抽奖。但是记住, /give命令是直接把物品放进他们的背包,而不是放在他们面前。

  • 监狱

通过连接高频红石到一个命令方块和用/tp命令,你可以强制玩家留在某个地方。如果你想让这个方法成为可行的,在你的聊天窗内使用指令/gamerule commandBlockOutput false.。使用"Range"(最大范围)和"Minimum Range"(最小范围)两个参数,你可以在玩家离开一定距离后再将他们传送回来。

  • 只针对管理员

如果使用参数[m=1],那么只有创造模式的玩家才会受到这条命令的影响。

  • Fun anti-creative mode trap

If you place a command block connected to a redstone pulse you can set tp @p[m=1] ~0 ~1 ~0 for hilarious results. This could be a way to get creative mode people to change to survival and is also really fun to watch.

  • Announcements

By using /me in a command block one can create announcements that could play even when the admin/owner wasn't there.

  • Security Scan

By using /clear, you can scan people for items. If you want to remove certain items, use /clear @a(or <playername>) <itemid>. For example, on a server that doesn't want griefing you could have a clock connected to a command block set to /clear @a 259.

  • 比赛裁判

使用/say @p,命令方块就能报告最近的玩家。如果命令方块放在终点线后,他会很方便的说出赢家。

  • Creative Area/World Guard

Creating a "Creative Only" zone is possible through command blocks, but it is complex and more of a case-by-case basis. The basic idea would be to create a "fence" of command block affected zones so that, once a player flies in creative through it, they would be changed to survival or adventure mode. A "World Guard" zone would be a lot simpler, just have a command block do /gamemode 2 @a[x y z r m] and when people leave, just have a button to change them to survival.

  • Improving PvP without Plug-Ins

You can use /gamerule keepInventory true so players cannot steal each others items. Also, using /spawnpoint [x y z] and /tp [x y z] to help move players around while in PvP competitions.

  • 新手工具包

你可以很简单的给新手工具包不用任何插件使用命令方块: "/give @p[r=2] 274". 为了防止有人第二次按下按钮得到他们的工具包,您可以设置按钮激活两个命令方块:: 1. "/give @p[r=2 m=2] 274" 2."/gamemode 0 @p[r=2]"

  • 特殊的彩字

虽然你不能够直接输入到命令方块时获得彩色/粗体/斜体文本,但是通过McEdit过滤器可以编辑那些像插件更改服务器的聊天文本属性的文本。 SethBling's McEdit Filter: ColourCommandBlockText

  • 警报系统

当玩家走上踏板时,他能触发命令方块/say @p

  • 删除玩家

Using coordinate and maximum parameters you can teleport everyone within a specific area to another specific area.

  • 奖励屋

If a certain player has been very nice,regular,or helpful to the server but not quite meeting the requirements to be promoted to an admin, you could have a room full of buttons connected to Command Blocks with helpful effects, like giving the helpful player a stack of diamonds or a bedrock block, then have it connected to another command block, sending them to the spawn point. (It is VERY important this room is reinforced with bedrock, hidden, and you can only get in by teleporting to its co-ordinates to avoid abuse).

  • 天气机

(Command: /toggledownfall and /weather thunder (to start or stop a thunderstorm)) Assuming only admins can get to it, a weather machine can be quite useful, you can turn rain on and off at will. One of the more helpful uses of this technique would be to use a combination of villagers and some form of redstone machinery to create and automatic rain disabler, this would allow you to shut off the rain almost immediately without needing to use the command, or to have an admin present. It can also be used to create, and/or end, a scenario where it is more advantageous to have rain as opposed to sunlight, and vice versa; such as during a forest fire, or when a thunderstorm is spawning monsters.

  • Obstacle Course prizes

with tp @p and give @p, you could make an obstacle course or maze that when finished will give a player a prize, and will teleport them back to spawn or some other area.

  • 时间机器

By making two similar places on one map, you can have a button activate a command block to tp you from one to another, while also changing the time of day. This can be used to look like time travel.

  • Proximity Mine

By using a condition such as /testfor @p[r=5,name=!<placing player>] hooked to a short clock and one or more TNT blocks via a comparator, the command block can act as an undetectable proximity mine against all players except the placing player.

  • 安全门

通过使用 /testfor @p[r=5,name=<房主>],命令方块会在一定范围内检测房主并且为他开门,也只会为他开门。

在自定义地图中的应用

This section details the applications of the 命令方块 in custom maps.

One map that takes advantage of a lot of the features of the 命令方块 is SethBling's TF2 Map "Dustbowl" in Minecraft.

http://www.youtube.com/watch?v=_f2brU8hBWc&feature=plcp

Another example is the Hypixel's Gladiator Arena in which the fighting system is almost only based on the 命令方块.

http://www.youtube.com/watch?v=jryJkWcqmzM

  • Silent Command Block

Sometimes it's important in a map to keep the command blocks silent, may it be to keep the magic of the suddenly appearing items in the inventory, or because the channel telling that the player was teleported, it can break the mood of a map. To keep them silent (except when you ask them to speak), just use the /gamerule commandBlockOutput false.

  • Safe Haven/Arena Fight Zone

Using pressure plates or tripwire, make areas (like a castle for instance) a different difficulty (for this instance I will use peaceful). the doors could have tripwire hooked to a command block that changes ones difficulty to peaceful, creating a sort of "Safe Haven". one could also do it the other way around, creating a more dangerous zone, such as arenas having the difficulty of hard, rather than normal or easy.

  • Detecting Cheaters

Using parameter [m=1] , you can affect those who are in Creative, or survival with parameter [m=0].

  • It's bigger on the inside

This is a simple one, just have a system of tp-ing command blocks at the entrance/exit of a place, and you can build the interior somewhere else, allowing you to cheat space restriction. (example of use: you want interior walls to be wool, but exterior walls to be wood (normally 2m thick walls). You can make the outside of the house be 8x10 m, and the inside of the house be 8x10 m.) Or, have the inside of the house 20x20m instead!

  • Save game

By using the /spawnpoint command, one can easily make a button-activated checkpoint.

  • Lava parkours

As said before, there is a command that makes the player able to keep their inventory upon death: /gamerule keepInventory true. Simply connect this to a pressure pad before a parkour level over lava and you don't have to use any kind of chest minecart (especially useful when the player has it's full inventory, which is bigger than a single chest).

  • Still want a bed?

It is true that the /spawnpoint command is really useful because you don't have to wait for the night to create a checkpoint, but what if you want to have a BUD switch connected to the bed or something of the sort? Then, you just need to have a pressure plate (it's more discreet) connected to a block with the /time set 18000 command, and it will set the time to night so the player can sleep.

  • Time and weather following the scenario

Let's say your map starts on a cold stormy night and when the player starts, for some random reason, there's a bright sun outside! Or what if you want to start on a bright day and the rain decides to join along? Fear not, for there is a weather command. Just use the /weather input command with, as input, clear, rain or thunder. Along with this, you can also use /time set input with as input a number: 0 is sunrise, 6000 is noon, 12000 is dusk and 18000 is midnight.

  • Detecting Players who switched to Peaceful

Create a hostile mob (so it disappears when switching to Peaceful) that never despawns if the player is far away (use third-party software to do so or give it some armor) and place it on a pressure plate. Make sure it will keep it pressed infinitely, so make sure it can't jump or walk away. Make a redstone circuit that causes a command block to activate when input from pressure plate ceases to exist. Place a message inside the block that informs the player on chat that the map has been broken and must be redownloaded. This way, switching to Peaceful will cause the mob to vanish and activate the message. You can even make a teleportation command block so that a cheater is banished from the map to a small room without a way out as soon as he switches to Peaceful.

  • Talking Adventure Map(featuring an easy Quest System!)

The /say command is really useful because it makes a text appear into the chat. It's maybe one of the greatest use of the 命令方块 as you don't need silly signs or long books to show the game rules. Just put a bunch of command blocks in lines with repeaters set to two or three ticks (so the player isn't spammed) and you can easily remove a chest of books or a lot of signs.

Another use of the command is talking NPCs and other mobs. Imagine you enter a butchery and you want the butcher to say something. Before, you needed to use signs or books, using some room in a butchery and putting objects that sometimes seemed random, but now... You just have to use the /say command and the butcher will talk. Maybe a pig behind the counter will even beg for mercy! Let's take another example: you are in a factory and an alarm suddenly rings and says that it's going to explode. Having it in the chat, especially if the text is long, keeps the stressfull mood; the same thing works for bomb timers. The player will get more into the map's mood if the chat displays '10...' '9...' '8...' also.

Last but not least, it makes it easier to create a Quest System. Let's say the player gets in a butchery. He activates through a pressure plate connected to a RS NOR Latch (so it can't be activated twice) and a command block with the /say command in which the butcher asks for the player's help: he needs to kill a pig (shame on him). The player gets to the pig that is standing on a stone pressure plate, that turns off when the pig is dead. So, when the player gets back to the butchery, he activates another circuit containing yet another RS NOR Latch and two command blocks with two commands. First, the /say command in which the butcher thanks the player, and other one, the /give command, so the player gets the reward. Along with that, don't forget to use the @p command so the butcher says the player's name. For example, if the command block is set to do this: /say Thanks, @p. You helped me a lot killing that pig., the channel will say: "@]: Thanks, <name of the player>. You helped me a lot killing that pig." This makes the map way cooler and looks like it's made for the player as it says his/her name!

  • Making a Store

By using /give @p[lm=(level)] (item) (amount) and /xp -(level)l @p[lm=(level)] you can make a shop system that trades a certain amount of exp for items. For instance, if you made a command block with /give @p[lm=5] 2 64 and another with /xp -5l @p[lm=5] connected to the same redstone current, it will take 5 levels from the player, and in return, give them 64 grass blocks.

    • Subtracting xp CAN work as a currency, by using the command /xp -3l @p[lm=3] where l (L for level) is subtracted. The minimum xp for the command to work can be listed inside the brackets, where lm is short for minimum level necessary.
    • You can make a Store using xp as a currency. Just place a command block before all the others with the following instructions: /testfor @p[lm=5] with a Comparator in front of the command block. That way you can only do the trade if you're at least at level 5 (in this case, but you can choose what level you want).
        • The last two "updates" are pointless, as the [lm=(level)] in the first post will keep players from getting the item or losing their xp unless they are that level or higher. so if the command says [lm=5], they will NOT be able to use the "store" if they are level 4 or below, but WILL be able to if they are level 5 or above.
        • The blocks must be in order for this to work. If the blocks are powered at the same time, the cost block will subtract as per normal, but the block giving the item will not function unless your level is double or higher what the cost of the block is. (example: item costs 5, you have 7 levels, you will lose the 5 levels, but will not gain the item. You would only receive the item if your starting level is 10 or higher) The fix for this is to power the blocks linearly, give block first followed by xp block.

参考

Template:教程

Advertisement