[命令方块]可以使用在许多事情,改变[[难度],改变[[天气]的状态,或者给你预先指定的物品他们在这些领域特别有用:<代码> / weather </ code>和 / time set x </ code>命令。他们只能在作弊模式之外。 / time set x </ code>命令很有用,它允许你改变当前预定时间再按下一个开关。
传感器将激活红石手电筒,这将激活命令块,当没有足够的光线时,将会将时间设置为8000r为远距离的红石火炬提供动力。换句话说,Command Block将在时间足够暗时将时间设定为中午。命令激活时的光级别随着红石线的距离而变化。它设置的时间随着命令块中键入的时间而变化。 200px首先,将日光传感器放在开放区域。然后你放置一些红石线远离它。红石线的距离取决于你需要宝贵的时间。距离日光传感器只能有最多15块的红石线,将信号发送到目的地。接下来,你把红块放在红石的另一边。把一块红石火炬放在火箭的旁边,在火炬顶上放一个Command Block。右键单击命令块,以“/ time set”开头,输入有效的时间值和结束。该值取决于何时设置时间。 14000是晚上,8000是中午。 200px这个设计可以在地图中使用,以保持一定的日/夜的时间。这个简单的设计只能用于创意模式或启用秘籍。有一个替代,更紧凑的设计。如果将比较器面向远离阳光检测器,并将15强度红石线(一个带有割炬的红石)放入第二个输入。然后将比较器设置为减法模式。比较器将在中午之后激活。 ===轻松设置日/夜===在命令块的顶部放置日光传感器,然后右键单击它将其设置为夜间传感器。将[/ Time set day]添加到Command Block。或者如果您希望它始终为夜晚,请添加日光传感器,不要右键单击,然后在命令块中添加“/ time set night”。 ==无线红石==无线红石可以使用command block和记分板系统来实现。该过程涉及使用附加到时钟电路的输出的命令块搜索的记分板变量。然后在无线输出命令块上使用比较器,当变量被发现为真时将触发。无线红石还可以通过使用目标而不是变量来实现。如果输出命令块设置为尝试删除不存在的目标,则可以通过命令块或聊天命令添加所述目标来创建红石信号。这种方法对于可变方法的优势在于它不依赖于玩家。为此,在输入处放置一个命令块并键入命令:/ scoreboard targets添加<objective name> dummy。在输出位置,放置命令块,键入 /记分板目标删除<客观名称> </ code>,将其挂接到时钟,然后放置一个比较器,然后从指令块中导出中继器。然后只需使用中继器作为输出。 <gallery>文件:无线红石01.png |关闭状态。文件:无线红石02.png |开状态。文件:无线红石03.png |开状态命令。文件:无线红石04.png |关闭状态命令。文件:Signal_catcher.png |无线输出设置。文件:无线红石06.png |无线输出命令。文件:Sigurd4-Wireless Redstone.png |使用“/ summon”命令使用无线红石的另一种方式。这里使用的命令是 / summon FallingSand -118 150 -60.5 {TileID:76,Time:1,DropItem:0} </ code> </ gallery>您也可以使用/setblock命令,而不是记分板系统。所有你需要做的是让命令块将一个redstone_block设置为目标坐标 - 以及与连接到反相信号的命令块设置为相同坐标的空气块(或任何不输出信号的任何物体)。 ==无线按钮==这可以通过任何块,技术上,但按钮,杠杆和其他可互换的块添加一个有趣的效果。令人惊讶的是,尽管在服务器上有神秘感。它使用1.8命令 testforblock </ code>。该设置只是一个命令块,将命令转换为红石信号的比较器,要测试的块,以及重复激活命令块的时钟。这是一个按钮的例子: / testforblock 123 12 123 stone_button 10 </ code>。您可以使用要测试的特定块的坐标和名称,在这种情况下,位于 123 12 123 </ code>的石按钮。对于更改数据值的任何块,这可以互换。坐标后面的数字 10 </ code>对应于我们希望命令块进行测试的按钮的数据值。在这种情况下,我们希望按下面向西的按钮激活命令块,所以我们将值设置为 10 </ code>。注意:该值根据按钮/杆所面向的方向而改变。未按下面向西的按钮的初始值为 2 </ code>。当按下按钮时,它增加一个值 8 </ code> to the initial state, so a button facing west when pressed would then have a data value of 10. Refer to: Button#Data values & Lever#Data values for the data values. == Starter Kits == 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 sneaking 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) (Note: This method can also be done by using the method above only using (First name your kit do /scoreboard objectives add <kitName> dummy <kitName>) scoreboard commands! /give @p[score_<kitName>=0] <item id> <amount> for the row of command blocks giving you the items and /scoreboard players add @p <kitName> <any number greater than 0> to make it a one time use. Also you can make more than one kit if you repeat the steps and use a different <kitName>). == As a replacement for pressure plates == 是不是已经厌烦了压力板只有四种材质可用了呢(石质,橡木质,铁质和金质)?现在你可以不再为这个问题困扰了。你可以使用包含命令/testfor,区域大小的带有时钟电路的命令方块来代替压力板了。命令/testfor @p[r=2]会检测2格内(朝任意方向两个方块加上命令方块本身的区域内)是否有任意玩家。当命令方块在一层地板下面的时候,r=2刚好是希望达到的效果。记住玩家是在一个球形区域内(而不是方形区域)触发这个命令的,所以r=2的区域大约是5*5*5,r=1的区域大约是3*3*3(其实更像是一个+号上下各加一个方块)。你可以用dx,dy,dz这些参数来编辑命令。你也可以在代码里指定xyz坐标(比如/testfor @p[x=50,y=64,z=46,r=1]),但是注意不能把区域缩小到一个方块。因为在不包含坐标的命令中区域大小代表着命令方块本身加上周围r个方块厚的区域,对于命令方块来说比较合理(如果缩小到只有一个中心方块,那就只有你站在命令方块那个位置时才会触发命令了,所以并不合理)。至少来说一个r=1的触发区域(即+号上下各加一个方块)可以被埋在地层下,只露出上表面,前提是你知道玩家不可能在地表下两层的位置行走。如果实现这一效果且不使用xyz坐标则要求命令方块嵌在地表上,可以被玩家看到。 == Using Command Blocks in Single Player Non-Creative Maps == 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 still activate it in Survival mode. Type this command in when having the Command Block GUI open /tp @p 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. == 探险家地图绘制 == 如果一个人希望创造一个单人玩家的探险家地图,做 /publish命令来让其他的命令(见下方)被使用。 == 在多人中的应用 (SMP) == 这个章节详细介绍了命令方块在多人游戏中的应用。 * 传送/运输 通过 /tp命令,可以制作一个所有人都可以使用的传送装置。可以在每个地方都使用。 例如,在整个世界里做一个庞大的传送系统,所有的传送点入口都汇集到传送大厅中,而传送大厅可以进入每个传送点入口处进而达到出口。这样就可以建造一个“快速交通中心”了。 * "定格动画" 通过使用/tp,或者Minecraft地图编辑器,例如MC地图编辑器可以复制一张图片(利用方块做出来的绘画),然后粘贴到一处遥远的地方,并变动绘画的一些方块,利用一些压力板或者绊线钩,在玩家短时间欣赏绘画后,命令方块做出/tp命令,将玩家传送到下一张绘图点. 如果大量的复制粘贴这样的零件,让玩家按顺序的在这些之间传送并稍稍弄出一点点的延迟,那么玩家就会产生幻觉,认为这个绘画是在运动的(甚至认为是某MOD做出来),这就是利用命令方块来实现定格动画技术。 1.7+里可以使用/setblock来直接放置和删除方块,利用/setblock还可以免除传送时不必要的卡顿和一大堆的房间,而1.8+的/fill更是可以极其方便地放置大量的方块。 * 抽奖 用/give @r命令,可以创造一个抽奖。但是记住, /give命令是直接把物品放进他们的背包,而不是放在他们面前。 * 监狱 通过连接高频红石到一个命令方块和用/tp命令,你可以强制玩家留在某个地方。如果你想让这个方法成为可行的,在你的聊天窗内使用命令/gamerule commandBlockOutput false.。使用"Range"(最大范围)和"Minimum Range"(最小范围)两个参数,你可以在玩家离开一定距离后再将他们传送回来。 * 只针对管理员 如果使用参数[m=1],那么只有创造模式的玩家才会受到这条命令的影响,当然输入m=0既只对生存模式的玩家有效。 * 戏弄创造模式玩家 你可以放置一个命令方块,输入“/tp @p[m=1] <坐标>”或者一些整人命令。当创造模式的玩家激活这个命令方块就会被传送到某个地方或者变成生存模式,好无聊的恶作剧! * 公告 注:使用AutoMessage等服务端插件就可以达到自动公告的功能 通过在命令方块中使用 /me,可以创造一个无人自动广播(需要连接循环红石等不断发出激活信号的红石元件),不需要OP,用1.7+的新命令/tellraw {text:"<信息>"}可以免除开头的[@]并且可以做到悬浮事件和点击事件等。 * 安全扫描 注:大部分服务器管理插件支持封禁危险物品。 使用 /clear命令, 你可以清除玩家背包中的某物品。具体步骤是这样的,使用 /clear @a(或者某玩家ID) <清除的物品名>。如果想实现自动清理危险品需要连接循环红石。 * 比赛裁判 使用/say @p,命令方块就能报告最近的玩家。如果命令方块放在终点线后,他会很方便的说出赢家,但是/say会给所有玩家发送信息,为了防止刷屏,建议使用/tell或/tellraw。 * 建立保护区域 注:Residence等服务器领地插件的拓展插件可以实现领地内游戏模式的变化。 你可以通过命令方块创造一个“创造/生存模式区域”,但是很繁琐。可以通过用命令方块的范围限制来制作一个“围栏”,通过围栏的玩家会变成生存或创造模式。在命令方块中输入命令 /gamemode 2 @a[x=<区域中心坐标> y=<区域中心坐标> z=<区域中心坐标> r=<最大的玩家搜索半径> rm=<最小的玩家搜索半径>] 这样放置两个搜索区域不重合的命令方块,就可以将规定半径内的玩家改变模式。 * 无插件PVP 使用命令 /gamerule keepInventory true 来关闭玩家死亡后的物品掉落(同样在重生后会保留物品和经验等,所以需要在玩家重生后清空背包) 。使用 /give @p <物品ID>可以给予玩家武器(可以添加NBT标签),你可以设计一套完善的职业系统,玩家选择不同的职业会有不同的装备。使用 /spawnpoint [x y z坐标] 设置玩家重生地点,使用 /tp [x y z坐标]移动地图中的玩家到指定区域。 * 新手工具包 你可以很简单的给新手工具包不用任何插件使用命令方块: "/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 同时/tellraw可以直接利用color等参数来弄出彩色字体 * 警报系统 当玩家走上踏板时,他能触发命令方块 /say @p <警告内容> * 奖励屋 如果某个玩家在服务器有着过人的贡献或者有元老资历,但却不足给他管理,你可以奖励他一组钻石或者一些奇怪的东西.... 创建一个只有通过传送命令才能进入的房间,将有卓越贡献的玩家传送进去,玩家会激活房间中的命令方块从而获得奖励,而后他又会被另一个命令方块传送回原地,如果服务器允许/back的话,连续2次传送到原点,这样/back就无效了。(可以避免玩家二次领取奖励) * 天气机 使用/toggledownfall和/weather thunder来开始或者结束降雨(雷雨。)合理安排这个命令的权限会十分有用, 你可以顺随自己的意愿开始或停止降雨。这个技术可以用于村民和一些由降水控制的红石机械,不用输入任何命令就可以控制天气(需要管理员激活命令方块自动执行), 合理利用将会十分有效,比如在森林火灾时或者在雨天刷怪 * 有奖竞赛 使用/tp @p 和 /give @p,你可以制作一个障碍赛跑或者奖励迷宫,游戏结束后就将玩家传送汇出生点或其他地方。 * 时间机器 在地图上模拟两个十分相似的环境,通过命令方块将玩家从一个传送到另一个,并且时间也会被设置为开始的时刻,这就好像是时间倒退。 注:可以广泛用于剧情RPG地图。 * 地雷 使用命令/testfor @p[r=<检测范围>,name=<玩家名(如果没有限制可不写)>] 使用红石中继器连接命令方块和TNT,当命令方块检测到有玩家经过就会激活TNT!Boom! 注:命令方块的/testfor命令为一次性命令,命令方块检测到一次就会一直输出信号,如果需要多次性的话,你可以直接使用/summon召唤出TNT。 * 安全门 通过使用 /testfor @p[r=5,name=<房主>],命令方块会在一定范围内检测房主并且为他开门,也只会为他开门。 注:命令方块的/testfor命令为一次性命令,命令方块检测到一次就会一直输出信号。 == 在自定义地图中的应用 == 这一节详细介绍了命令方块在自定义地图的应用。 Minecraft中使用大量命令方块的地图有很多优势。 比如:SethBling's TF2 Map https://www.youtube.com/watch?v=_f2brU8hBWc&feature=plcp 另一个优秀的应用例子是 Hypixel's Gladiator Arena,这个地图中的战斗职业系统完全依赖于命令方块。 https://www.youtube.com/watch?v=jryJkWcqmzM * “沉默的”命令方块 在地图中控制命令方块不输出提示信息很重要,这可以保持玩家对地图的未知性和剧情的隐蔽性,如果玩家看到了各种命令的提示信息,地图将会索然无味。 关闭命令方块输出信息(除非是/say这类的命令)使用/gamerule commandBlockOutput false就可以实现。 * 庇护所/角斗场 使用压力板或者绊线 (以安全城堡为例)设置进入城堡内的玩家为和平模式(对于不同区域视情况而定)。城堡大门可以有连接命令方块的绊线,玩家一旦走过绊线,激活命令方块,就会变为和平模式,这样就可以创造一个“避难所”。反之,你可以用同样的方法创造一个“困难模式区域”,所有玩家进入会变为困难模式。 * 对于不同游戏模式玩家的控制 使用值[m=1]你就可以设置命令只对创造模式的玩家有效,生存模式就是[m=0]。 例:传送所有创造模式的玩家到254,47,-874,使用的命令为 /tp @a[m=1] 254 47 -874 * “联合”住宅 在房间的入口或者出口设置一个 /tp 命令的命令方块,你不必将你的建筑都在同一个地方建设,它们可以在任何地方,只需要入口的命令方块传送过去,玩家会忽然觉得外面感觉很小的建筑内部空间竟如此之大。用这种方法联合多个建筑,可用作与服务器或单人地图中的场景瞬移。 * 出生地 使用 /spawnpoint 可以设定玩家出生地点。(应用十分广泛,PVP地图,RPG地图等等) * 熔岩跑酷 之前的内容提到过,/gamerule keepInventory true可以在玩家死后保存背包物品。 在跑酷地图的出发点设置一个这样的命令方块,就可以使掉落熔岩死亡的玩家不会丢失物品,同时记录点可以用/spawnpoint来做。 * 我要睡觉! 使用 /spawnpoint 可以直接设置出生点,但是要跳过白天就需要 /time set <时间> 命令,18000为夜晚(并非绝对,可以按喜好设置,不要少于12500),这样就可以模拟出睡觉的效果了。(可用/time set 700 直接转为白天,/spawnpoint命令和/time set 700配合不就行了么?) * 时间和天气下的场景 比方说,你的地图开始在一个寒冷的暴风雨之夜,你可以设置突然天晴了,外面有灿烂的阳光(光影mod么?)!或者,如果你想开始一个光明的一天,想让雨突然下起来又没办法?不要怕,有/weather命令。只需使用/weather,输入就行了!你也可以使用/time set输入:0是凌晨,6000是中午,12000是黄昏,18000是午夜(月亮还挂在头上呐!)。 * 检测玩家是否切换到了和平模式 创建一个攻击型生物,把它放在压力板上。(请确保它会保持始终按下状态,所以一定要确保它不能跳或走开)。做一个红石电路,让压力板在没有接收到红石信号的时候激活命令方块。命令方块里设置一个消息,通知玩家的地图由于和平模式了已经损坏,需要的怪物已经消失,必须重新下载这个地图。你甚至可以做一个隐形传输命令方块,把那些故意切换到和平模式的玩家换成冒险模式后传送到一间基岩屋内,并让他不能使用/kill或/tp命令,并把他的重生点设在那个房子里,让他永生见不得光明!(单人的话,可以点“对局域网开放”,或用修改器) * Talking Adventure Map(featuring an easy Quest System!) /say命令非常有用因为它可以直接给玩家发送消息. 用命令方块将会更好,这样你就不需要放很多的告示牌和编页码长到不行的书来告诉玩家游戏规则. 你只需要把命令方块放成一条线然后在中间铺中继器来弄各个语段之间的延迟(so the player isn't spammed)接着你就可以把那堆告示牌和放着书的箱子移走。 有一些是和NPC配合使用的. 想象一下你进了铁匠铺并且你想要让里面的铁匠说些什么。在命令方块出现之前, 你需要一些书和告示牌来充当对话的效果, 然后在铁匠铺里造些房间并放些杂物,这样会让这个铁匠铺看起来变得非常乱,但是现在,你只需要使用/say命令来制造铁匠说话的效果. 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! * 创建商店 使用/give @p[lm=(等级)] (物品) (数量)和/xp -(等级)l @p[lm=(等级)] ,你可以创建一个使用经验交易物品的商店系统。例如,如果你创建了一个使用/give @p[lm=5] 2 64的命令方块以及一个使用/xp -5l @p[lm=5]的命令方块,并把它们连接到同一个红石电路,那么激活时就会从最近的玩家身上扣除5级经验并给他64个草方块。 * * * 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. == 1.7命令的用法 ==
Minecarts over floating rails created with the setblock command.
在1.7版本中, the command block gained an expanded potential. 也就是 /summon and /setblock 命令的添加, and can be used to automatically build structures, 填充箱子, 以及生成以前不能生成的实体。 下面是这些命令的语法: setblock的使用方法:/setblock <x> <y> <z> <方块名> [数据值] [旧方块处理方式] [数据标签] summon的使用方法:/summon <实体名> [x] [y] [z] [数据标签]setblock命令也可以用于做突然消失的地板或突然出现的墙。 setblock命令的例子:* MobSpawners pt 1: The Basics This code will create a zombie spawner 2 blocks from you in the x direction. Note that the name given for mob spawners in this code ("minecraft:mob_spawner") is the long version and you can leave out the "minecraft:" part. /setblock ~2 ~0 ~0 minecraft:mob_spawner 0 replace {EntityId:Zombie} This next code is also pretty basic but it includes the 6 basic parameters that can be set. /setblock ~0 ~-1 ~-3 mob_spawner 0 replace {EntityId:Skeleton,SpawnRange:4,RequiredPlayerRange:16,SpawnCount:4,MaxNearbyEntities:6,MinSpawnDelay:200,MaxSpawnDelay:800} A few things to note: A) All times are in game ticks (20ths of a second). 200-800 is 10-40 seconds. B) Keep in mind that they are in groups of 2 and won't work if their partner is missing. SpawnRange requires RequiredPlayerRange (and vice-versa), MinSpawnDelay requires MaxSpawnDelay, and I assume SpawnCount needs MaxNearbyEntities (although I haven't actually heard confirmation on that last one). C) There is also a parameter called "Delay" which contains the amount of time before next spawn (20 ticks for the first time, whatever random number it picks between MaxSpawnDelay and MinSpawnDelay every other time). D) the coordinates given are ~0 ~-1 ~-3 (so 3 blocks in the negative Z direction from the commandblock's current position and 1 block down). This presumably will imbed it in the surface of the floor. Keep in mind that a spawners "SpawnRange" setting only applies horizontally not vertically. Vertically it will only spawn at the same height or 1 lower or higher, so imbedding it in the surface of the floor cuts the available spawn area by 2/3rds (but can help hide it). Naturally occuring spawners have their height cut by 1/3rd due to appearing 1 block above the floor instead of 2. E) All the values used here are the defaults. * MobSpawners pt 2: Custom monsters Now we get into the SpawnData. That's the stuff that tells the spawner you want a non-standard version of a monster, like a Zombie with a Diamond Sword and a Chainmail Helmet. /setblock ~ ~1 ~ mob_spawner 0 replace {EntityId:Zombie,SpawnData:{Equipment:[{id:276,Count:1},{},{},{},{id:302,Count:1}]}} Using ~ without any number after it in the coordinates counts as zero. Since none of those 6 parameters from last example are used they will all be defaults. Note that the 5 equipment slots are: Hand, Boots, Legs, Chest, Helmet. You must even specify empty slots (the { }, parts) unless they're after the last non-empty slot. So if you want him to have a helmet you have to specify all 5 slots, but if it's just a weapon you can leave off the other 4. Or if you want him to have leg armor you have to specify weapon and boot slots but not chest and helmet slots. By the way, creatures that burn in sunlight are safe if they have a helmet on, although it damages the helmet instead. About the Count tag: most codes can get away with leaving it out, however it is important. An item without a count tag is a stack of zero, better known in the community as a "Ghost Item". A player trying to use a ghost item will have it disappear out of his hands with it's first use (which is a failure). While monsters can use ghost items without problem (hence why codes get away with leaving it out sometimes) if they drop the items the player who picks it up won't be able to use it, SO INCLUDE COUNT! Next up we have a Skeleton with an enchanted bow (Flame), a custom mobhead (Spider, internet connection required or it's just steve) with Protection 2, and riding a Skeletal Horse. /setblock ~2 ~1 ~2 mob_spawner 0 replace {EntityId:Skeleton,SpawnData:{Equipment:[{id:261,Count:1,tag:{ench:[{id:50,lvl:1}]}},{},{},{},{id:397,Count:1,Damage:3,tag:{ench:[{id:0,lvl:2}],SkullOwner:MHF_Spider}}],Riding:{id:"EntityHorse",Type:4,Tame:1,SaddleItem:{id:329,Count:1,Damage:0}}}} Well actually sitting on a Skeletal Horse, since the lower creature controls the movement and the horse isn't hostile. Don't try zombies on horseback, they just sit there ineffectually while the horse eats grass and snorts. Luckily this is a skeleton and can shoot you from wherever the horse decides to wander. As for the horse itself, it's type 4 (skeletal horse), Tame is set to 1 (yes), and it's got a saddle (and the fact that they make us specify which saddle hints that they may eventually have more than one type). Technically you can have multiple levels of riders, although this gets silly quickly. MobSpawners pt 3: SpawnPotentials Using the SpawnPotentials tag lets us create a mobspawner with multiple mobs in it. It will randomly pick one each time it resets the timer (a second after spawning the previous mobs). Since these codes contain multiple mobs they tend to be quite long codes. Thanks to some youtuber whose name escapes me (Dragnoz) the fact that you can "break up" your code is known (command blocks ignore line breaks, so you can start a new line to clarify where one section ends and another begins and it won't ruin your code). Here's a more easy on the eye version of a SpawnPotentials code /setblock ~0 ~1 ~1 mob_spawner 0 replace {EntityId:Zombie,SpawnRange:6,RequiredPlayerRange:12,SpawnCount:1,MaxNearbyEntities:6,MinSpawnDelay:100,MaxSpawnDelay:600,SpawnData:{Equipment:[{id:268,Count:1},{id:301,Count:1},{id:300,Count:1,tag:{display:{color:5013401}}},{id:299,Count:1,tag:{display:{color:6717235}}},{id:397,Count:1,Damage:3,tag:{SkullOwner:Reimac}}]},SpawnPotentials:[ {Type:Zombie,Weight:4,Properties:{Equipment:[{id:268,Count:1,Damage:58},{id:301,Count:1},{id:300,Count:1,tag:{display:{color:5013401}}},{id:299,Count:1,tag:{display:{color:6717235}}},{id:397,Count:1,Damage:3,tag:{SkullOwner:Reimac}}]}}, {Type:Skeleton,Weight:2,Properties:{Equipment:[{id:267},{id:301,Count:1,tag:{display:{color:1644825}}},{id:300,Count:1,tag:{display:{color:1644825}}},{id:299,Count:1,tag:{display:{color:1644825}}},{id:397,Count:1,Damage:3,tag:{SkullOwner:2insanepeople}}]}}, {Type:Zombie,Weight:4,Properties:{Equipment:[{id:272,Count:1},{id:305,Count:1},{id:304,Count:1},{id:303,Count:1},{id:397,Count:1,Damage:3,tag:{ench:[{id:0,lvl:2}],SkullOwner:Flixnore}}]}}, {Type:Zombie,Weight:4,Properties:{Fire:2400,Equipment:[{id:283,Count:1,tag:{ench:[{id:20,lvl:1}]}},{id:317,Count:1},{id:316,Count:1},{id:315,Count:1},{id:86,Count:1,tag:{ench:[{id:0,lvl:2},{id:1,lvl:10}]}}]}}, {Type:Zombie,Weight:4,Properties:{Equipment:[{id:267,Count:1,tag:{ench:[{id:16,lvl:2}]}},{id:309,Count:1},{id:308,Count:1},{id:307,Count:1},{id:397,Count:1,Damage:3,tag:{ench:[{id:0,lvl:2}],SkullOwner:2zqa}}]}}, {Type:Zombie,Weight:1,Properties:{Equipment:[{id:278,Count:1,tag:{ench:[{id:16,lvl:4},{id:17,lvl:4},{id:18,lvl:4},{id:21,lvl:3},{id:34,lvl:3}]}},{id:313,Count:1,tag:{ench:[{id:1,lvl:4},{id:2,lvl:4}]}},{id:312,Count:1,tag:{ench:[{id:3,lvl:4}]}},{id:311,Count:1,tag:{ench:[{id:0,lvl:4}]}},{id:397,Count:1,Damage:3,tag:{SkullOwner:MHF_Herobrine,ench:[{id:0,lvl:4},{id:1,lvl:4},{id:3,lvl:4},{id:5,lvl:3},{id:6,lvl:1}]}}],CustomNameVisible:1,CustomName:Herobrine,PersistenceRequired:1}}, ]} Wow that's a mouthful! But then it is 6 separate mobs. In order we have: 0) Before the "SpawnPotentials" tag: The starter, which will never pop up again after the first time. If we want to see him again we have to include him a second time under SpawnPotentials. He is just some random dude in bluejeans (blue dyed leather leg armor) and a cactus green shirt (green dyed leather tunic) with a wooden sword. He's a zombie under that random-dood-mobhead of his of course. They all are. 1) Same random dood, only this time his wooden sword is 2 hits away from breaking. 2) Hey who let a ninja into the game?!? This one is a skeleton under his mask, but he's been given an iron sword. All his leather armor is dyed ninja-black. Skeletons with swords close the gap quicker than zombies so watch out. 3) Stone Sword and Chain Armor guy. Protection II on his mobhead. 4) One of my favorites. Gold Sword, Golden Armor, Pumpkin Helmet, and ON FIRE!!! Originally I wanted to give him a flaming pumpkin helmet but I realized the Fire tag only applies to entities not armor. The pumpkin is enchanted with Protection II and Fire Resistance X (10!) in a desperate attempt to keep him on his feet and threatening the player for more than 5 seconds. It works but if the player plays keepaway then Mr Pumpkinhead does tend to burn to death. Oh his sword has fire aspect too. 5) Iron Sword and Armor guy. Sharpness II on his Sword, Protection II on his mobhead. 6) Diamond Weapons and Armor guy. Wait who is that. Is...is that...Oh Em Gee it is! Run!...No of course it's not really him. Because he doesn't exist. FakeHB here has highly enchanted Diamond Armor (Boots with Fire Protection IV and Feather Falling IV, Leggings with Blast Protection IV, Chestplate with Protection IV, Mobhead with Protection IV, Fire Protection IV, Blast Protection IV, Respiration III) and a Diamond Pickaxe enchanted with Sharpness IV, Smite IV, Bane of Arthropods IV, Looting III and Unbreaking III. He's also got the previously unseen CustomNameVisible (set to 1 for yes), a CustomName, and PersistenceRequired (set to 1 for yes). That last one will prevent him from ever despawning, although he can be killed normally. If you can get through that Diamond Armor. And level 4 resistances. Luckily he's rarer (see below). Other than the ninja it's a straight tour of the 5 tiers of swords and armor. Note the Weight tag, used right after the mob name in each SpawnPotential. That determines how rarely it's picked. Specific numbers don't mean anything, just the ratios between the numbers. For example if you want all the potentials to have an equal chance just set all the weights to 1. Changing them all to 8 wouldn't do anything different (they're still all the same size as each other), however changing all but one to 8 would make that one 1/8th as likely as the rest. In this code 4 is the default. The ninja only has a weight of 2 (making him half as likely to be picked) and FakeHB has a weight of 1 (making him 1/4th as likely to be picked, and thank god!) * MobSpawners pt 4: Rideable Monsters Mobs can be ridden by using Minecarts or Boats on their heads. The command is fairly simple /setblock ~ ~1 ~ mob_spawner {EntityId:MinecartRideable(or Boat), SpawnData:{Riding:{id:<Entity>}}} Tips: * Some mobs simply can't be spawned with a spawner, sad to say, like bosses and Iron Golems. Adding a Minecart isn't going to change that. * Hostile Mobs with shooting abilities can and will use them against survival players. Watch out. * Ghasts cannot be ridden. The minecart becomes stuck in their head, no use to anyone. * Endermen cannot be walked around, but they can be forced to teleport by shooting a projectile at them (eg; snowball). * Ocelots (Ozelots in the game format) are some of the fastest mobs to ride, seeing they're trying to get away from you. They can also be partially controlled, by pointing away from the place you want to go. * Spiders are the only mobs that slow down when ridden. * Slimes and their cousins, Magma Cubes (game format LavaSlime) cannot have their sizes changed. == 1.8 uses == New commands There are several new commands and tags added in 1.8. One of the most useful being @e. It allows the player to target entities. You can now teleport creepers, or kill a minecart. Others include /fill, /clone, /execute, /worldborder (set|health, etc}, /trigger, /title, /blockdata, /testforblocks, and /stats.. Check out the commands page to see how they work. == Commanding Passwords == You can now create passwords with command blocks, using /testforblock. Place a command block. This will be the one you put input in. Place another command block, and type in the command /testforblock (x,y,z of first command block) command_block 0 {Command:(input)}. Here's an example: /testforblock ~2 ~ ~ command_block 0 {Command:That's Numberwang!}. Place a comparator connected to the second command block, and place a button on or next to it to power the block. Now type "That's Numberwang!" (without quotes). If the second command block properly finds the first, the comparator will activate whatever it's wired to. If you want the first command block to reset so the password isn't used by someone else, also place a command block with /setblock that activates after the /testforblock. If you don't want to let people edit your command block, you can test for a sign instead, but this means having to test for the password separately on each of the sign's 4 lines. To add a touch, you can fill the sign with air, but remember to give it back using /give @p sign == The Destroyer == This allows you to destroy a cube of materials around you as you walk, using /execute. Here's the command: /execute @p ~ ~ ~ fill ~1 ~2 ~1 ~-1 ~0 ~-1 air. Attach a clock or some sort of repeating device to it, and the cube of air will follow you wherever you go. Confused? fill takes out a specified amount of space, similar to setblock, but it uses two xyz's and fills the space in between them with the material you choose. In this case it's air. Now, every time you move, it will fill a 3x3 cube of air around you. Great for enemy bases, or simply being a crazy griefer. * This also deletes water, so you basically become a moving sponge. * This works in any game mode, even spectator. == Landscaper == This is a reversed version of Destroyer. /execute @p ~ ~ ~ fill ~1 ~-1 ~1 ~-1 ~-1 ~-1 grass. This puts a 3x3 grass square under your feet. Only problem: Don't jump. It becomes a mountain of a problem. == Examples == * The player can make a kind of world guard using the command block. (e.g. code: /gamemode <模式:[survival|creative|adventure|spectator]> @a[r=<radius>]) * Using the radius argument with a teleporter hooked up to a clock circuit can be used to create an exclusion zone ("forcefield") around an x y z coordinate (which should not be centered on the command block itself, otherwise it will be difficult to edit or disable it later). Simply program it to teleport any player within a certain range to a further away point, or just back 10 meters using relative coordinates. Note that such a forcefield wouldn't know which direction you were approaching from, and may result in pulling a player in before pushing them back out the other side. * The commands /say Hello, @p, /tell @p Hello, @p, and /me Hello, @p will cause the command block to say user name of the nearest player in the message. * You can also clear players inventories, to prevent griefing and/or cheating: /clear <目标(玩家)> <物品> <数据> <最大量> <数据标签> == Spawners == Command Blocks can create spawners using the setblock command, e.g.: /setblock ~1 ~-1 ~0 mob_spawner 0 replace {EntityId:Zombie,SpawnData:{Equipment:[{id:276,Count:1}]}} Anything that counts as an entity can be spawned (except a player), which includes all hostile, neutral and passive mobs, as well as animals, minecarts, fireballs, arrows, snowballs, ender pearls, custom thrown potions, fireworks, primed TNT, falling sand, red sand, or gravel, paintings and item frames, experience orbs, and even dropped items of any type. Pig/Cow/Chicken spawners can be placed in the butcher's backyard in a village to create a constant meat supply. E.g.: /setblock ~1 ~-1 ~0 mob_spawner 0 replace {EntityId:Chicken,MaxNearbyEntities:10,RequiredPlayerRange:16,SpawnCount:6,SpawnRange:2,MinSpawnDelay:50,MaxSpawnDelay:200,SpawnData:{Riding:{id:"Pig"}}} Note that the spawner in the last code example will spawn a chicken riding a pig. There doesn't seem to be a limit to how many levels of riders you can use (e.g.: a chicken riding a pig riding a cow riding a horse riding a silverfish riding a villager ("Say, that's a mighty odd hat you have on, Farmer Brown")). Please note that if you want to use the RequiredPlayerRange tag you have to use the MaxNearbyEntities tag as well. Same deal with MinSpawnDelay and MaxSpawnDelay. Lastly, note that the y value used in both of those spawner example codes was ~-1, which (assuming you're not flying) will put the spawner in the surface level of the ground at your feet. If you don't want to target a specific player, you can use @a, @p, or @r instead of <player>. Keep in mind that you can use @p (which means "closest player") in player issued commands as an easy to type 2 character replacement for your own name as the closest player to you will always be you. == Booby traps == The most lethal booby trap would be a command block set to teleport someone into the void. As of 1.8 you can do /kill @e[r=2] in a command block below a block with a pressure plate to make a multi-use landmine that kills all nearby entities upon stepping on it (including players, item frames, and paintings) Note that booby traps that use @p can be dangerous due to the fact that non-player entities could trigger them (if something like a pressure plate is used), resulting in the teleportation of the nearest player, no matter how far away they are and regardless of the fact that they haven't actually stepped on the plate. To get around this, you can either use the /testfor command as an invisible pressure plate, or you can do /tp @p[r=radius] x y z. Hook a clock circuit up to a command block programmed with /testfor @p[x=1, y=2, z=3, r=radius], with the coordinates changed as appropriate. Note that as of 1.8 a range of zero can now be specified. == Teleporters == It is possible to make teleporters using the command block. (e.g. code: /tp @p x y z) Taking it one step further, a teleporting station can be made, with multiple button-activated teleporters that each teleport to different locations. Scouting and testing teleportation destinations first is advisable, to make sure players don't end up stuck inside blocks or in other unintended places. If you appear in ground while testing coordinates, use /tp @p ~0 ~8 ~0 to get out (may require multiple uses). If you use the teleport command with the command block, you can use relative coordinates in the destination coordinates by placing an ~ in front of a Coordinate (e.g. code: /tp @p ~0 ~8 ~0 This would teleport the player 8 blocks into the air). Commands that use coordinates (e.g. /tp or /spawnpoint) add 0.5 to whole numbers when no decimal follows. This is so you appear centered over the block you appear on instead of at the edge or corner of it. For example, the number -33 would execute as -32.5, and 187 as 187.5. To prevent this behavior, add .0 (25.3, 90.0) after them, as these values are executed left as-is. With the 1.8 update, you can now also teleport minecarts or boats, with you in them. The command is /tp @e[type=Boat] (coordinates). == More commands in fewer blocks == There are several ways to combine groups of commands into just one command. * /execute will run its command as many times as the number of targets it selects. If it doesn't matter what entity runs a particular command, you can use @e[c=10] to ensure the code always runs 10 times (as long as there are always at least 10 entities in the loaded world). * To run multiple commands, /summon a command-block minecart riding another command-block minecart riding another, with the commands in reverse order, on an activator rail. There are also commands called one-command mods that use this tactic. Mr. Garretto makes one-commands and maps here. == Exp Shop == This will allow server owners to sell effects, items, and more to any player using level ups and exp. All they have to do is press one button === Building The Structure ===
=== Setting The Commands ===
== Using a map item as a scroll == In his recent videos, Sethbling uses a map as a scroll to perform commands (summon creatures, teleport). He has an empty map in his inventory and when he uses it, it becomes a filled map which immediately disappears and a redstone task is done. In this tutorial I will show you how to build a redstone mechanism to detect the use of a map as a scroll and perform a task (give an effect, open a door,...). Pros * Fast redstone interaction. * Compact system. * At-will triggered system, just right-click to activate it. * Single use : the map disappears during the inventory check, but you can give it back through a /give command Cons * There can only be one purpose for the scroll. I.E. you cannot do a scroll of teleporting and a scroll of strength without using complicated data values. * You may see the map animation when activating the map before it gets deleted. * You cannot use the map item during your playthrough (showing a text message, a path, a drawing,...). Building the mechanism You can change the display name of an item to give the player a better understanding of the object and use the tooltip display. Use the following command to give the player a custom named map : /give <player> map 1 0 {display:{Name:"<displayName>",Lore:["<tooltip>"]}} * player : the player you want to reach (@p, @a[arguments],...). * displayName : the name displayed when you scroll in the hotbar or when you hover the item with your mouse. * tooltip : the text below the item name when you hover it. Detecting the activation of the mapFile:Minecraftscroll.jpg * The two hoppers form a redstone clock. You can use other clocks shown here. * The Command block 1 contains the /give command described in the section above. It can be dismissed if you don't want the scroll to come back after being activated. * The Command block 2 contains the inventory check command : /clear <player> filled_map * The Command block 3 is the output in case of success. You can do whatever you want : give an effect to the player, teleport him somewhere,... You can also wire this output to a door, a piston,... Going further The /clear command can check for other interactive items : * check for a glass_bottle if the player just drank a potion. * Sethbling also uses a fishing rod which works when the line is reeled in. The /clear syntax involves another argument, the damage value, after the item name: /clear <player> fishing_rod 2 Note that spamming the reel, or hooking a mob, may damage it more than 2, so make another one of these every 2. == Command-Piston-Repeater Fun == * Command block: /setblock x y z minecraft:sand * 1st Piston Front: Showing to set /setblock x y z to that position === Fast Pusher === * Repeaters are risen by 1 block from 1-3 so you can see them
* 1(Repeater): Set to 1 * 2(Repeater): Set to 3 * 3(2 Repeaters): Set to 4 and 2 * 4(Repeater): Set to 2(Default) * 5(2 Repeaters): Set to 4 and 1 * 6(2 Repeaters): Set to 4 and 4 * 7(Repeater): Set to 2 * 8 and 9(Repeaters): Set to 4 and 4
=== Slow Pusher === * 1(Repeater): Set to 4 * 2(Repeater): Set to 4 * 3(Repeater): Set to 4 * 4(Repeater): Set to 1(Default) * 5(Repeater): Set to 1 * 6(Repeater): Set to 1 * 8(Repeater): Set to 4 * 9(Repeater): Set to 2 * 10(Repeater): Set to 2