Exciting! 发表于 2018-8-22 12:01:30

[新人贴][命令方块]无需op权限也能用的原版木牌商店!

本帖最后由 Exciting! 于 2018-8-30 19:20 编辑

发现重大问题!请各位服主最好不要在服务器里做,这样做会大量消耗服务器资源!
未来将把修改后的教程放出,这里向大家说一声抱歉!
感谢@Roach_123 大佬的指正!


当然,如果你是局域网玩家或者maper,那么下面的教程或许暂时可以凑合着看一下:

=======================================================

今天给大家带来原版实现木牌商店教程
在教程开始之前我们先来看一个小故事:
一天,史蒂夫像往常一样出门探险,突然,他发现了一个木牌

史蒂夫心想:既然我有10个硬币,那就来买买看吧
当史蒂夫右键木牌时,神奇的事情发生了:

当史蒂夫再次右键时,却因为硬币不够而被阻止了:

那么究竟是怎么做到的呢?让我们进入教程:
准备材料:
①一台能玩mc的电脑
②n个命令方块
③一个脑子
原理:
原理很简单,即木牌执行命令+trigger+乱七八糟
没人看的步骤:
①根据原理,我们需要先创建一个可以使用trigger指令修改的计分板:
/scoreboard objectives add shop trigger
但我们还得给玩家使用trigger修改的权限:
/scoreboard players enable @a shop
②创建货币计分板,这里使用的是击杀生物判据,可以根据需要自行修改:
/scoreboard objectives add coin totalKillCount
我们需要判断购买商品的玩家是否符合购买该物品的条件,则需要再创建一个计分板:
/scoreboard objectives add sp dummy
③核心部分,创建一个右键触发trigger的告示牌:
/setblock ~ ~1 ~ minecraft:wall_sign 3 replace {Text1:"{\"text\":\"\",\"extra\":[{\"text\":\"[商店]\",\"color\":\"green\",\"bold\":true}]}",Text2:"{\"text\":\"\",\"extra\":[{\"text\":\"神奇的木剑\",\"color\":\"red\",\"bold\":true}]}",Text3:"{\"text\":\"\",\"extra\":[{\"text\":\"价格:8硬币\",\"color\":\"aqua\",\"bold\":true}]}",Text4:"{\"text\":\"\",\"extra\":[{\"text\":\"<右键购买>\",\"color\":\"white\",\"bold\":true}],\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/trigger shop set 1\"}}"}
④这时玩家右键牌子就会发现你的shop计分板分数变成了1,我们需要判断玩家是否符合购买的条件(即硬币>8且shop分数为1),若符合将该玩家sp计分板分数设置为1
/scoreboard players set @a sp 1
⑤这时我们需要将物品给予该玩家并给玩家一个title提示:
/give @a minecraft:wooden_sword 1 0 {display:{Name:"神奇的木剑"},Unbreakable:1}
/title @a title {"text":"","extra":[{"text":"购买成功","color":"green","bold":true}]}
/title @a subtitle {"text":"","extra":[{"text":"神奇的木剑","color":"red","bold":true},{"text":" 已发送到背包","color":"yellow"}]}
⑥若玩家不符合购买条件(即硬币≤7且shop分数为1)则直接给一个title提示:
/title @a title {"text":"","extra":[{"text":"购买失败","color":"red","bold":true}]}
/title @a subtitle {"text":"","extra":[{"text":"请检查硬币是否充足","color":"gray","bold":true}]}
⑦当玩家购买成功时,我们需要清空该玩家的sp积分并且扣除硬币防止无限给物品:
/scoreboard players set @a sp 0
/scoreboard players remove @a coin 8
不管有没有购买成功,我们都需要清除玩家的shop积分防止出现各种奇怪的问题:
/scoreboard players set @a shop 0
至此,一个木牌商店就做好了。
纯命令懒人教程(回复可见):**** Hidden Message *****
拓展:
本教程set而不是add计分板shop和sp分数的目的是判断购买的商品,将shop和sp都改为其他数字可以做多个木牌商店
因为trigger可以通过指令修改的关系,所以会出现随时随地输入/trigger shop set 1指令就能购买的bug,解决办法就是将shop分数自定义为一个麻烦的数字,比如2001,不易被发现即可


以上就是本次教程全部内容,祝大家游戏愉快









Exciting! 发表于 2018-8-22 13:02:46

没人看吗

luobojun 发表于 2018-8-22 13:06:05

木牌的JSON可以讲解一下会很充实

Exciting! 发表于 2018-8-22 15:55:31

luobojun 发表于 2018-8-22 13:06
木牌的JSON可以讲解一下会很充实

这种东西讲解起来才是真正麻烦的#03

Dnir 发表于 2018-8-22 19:37:25

来来来来看一看

Roach_123 发表于 2018-8-23 09:21:00

木牌的执行者是木牌,所以不需要用到trigger,建议在木牌里写3条命令,第一条给点击者(@p就行)添加一个tag,第二条第三条用blockdata来开关下面的命令方块,命令方块最后记得去掉tag,网易的服务器能少一个循环就少一个,对不

路人甲0813号 发表于 2018-8-23 10:05:13

为了看懒人教程而回复!!!

1787620685 发表于 2018-8-23 15:08:09

虽然我不用,但是看着不错诶

天源小陌 发表于 2018-8-23 15:39:17

很不错谢谢楼楼

红石”凶“ 发表于 2018-8-24 12:13:08

路过支持~

幻韵星辰qwq 发表于 2018-8-24 16:22:25

海星

大侠崔 发表于 2018-8-24 19:34:06

http://jump2.bdimg.com/safecheck/index?url=x+Z5mMbGPAvVIlwZePSt0B3tEqEFWbC4tOatFxkC6cK9/Y1shet8ALGTOmg2RBKhAGxU9iRl3l5DvNNuDO4/ORGq31hJ6acaUOwIWOUAkgyRMuzicz0Orng57JjKWJ/Udj2oeHoEzTI=http://jump2.bdimg.com/safecheck/index?url=x+Z5mMbGPAvVIlwZePSt0B3tEqEFWbC4tOatFxkC6cK9/Y1shet8ALGTOmg2RBKhAGxU9iRl3l5DvNNuDO4/ORGq31hJ6acaUOwIWOUAkgyRMuzicz0Orng57JjKWJ/Udj2oeHoEzTI=http://jump2.bdimg.com/safecheck/index?url=x+Z5mMbGPAvVIlwZePSt0B3tEqEFWbC4tOatFxkC6cK9/Y1shet8ALGTOmg2RBKhAGxU9iRl3l5DvNNuDO4/ORGq31hJ6acaUOwIWOUAkgyRMuzicz0Orng57JjKWJ/Udj2oeHoEzTI=http://jump2.bdimg.com/safecheck/index?url=x+Z5mMbGPAvVIlwZePSt0B3tEqEFWbC4tOatFxkC6cK9/Y1shet8ALGTOmg2RBKhAGxU9iRl3l5DvNNuDO4/ORGq31hJ6acaUOwIWOUAkgyRMuzicz0Orng57JjKWJ/Udj2oeHoEzTI=http://jump2.bdimg.com/safecheck/index?url=x+Z5mMbGPAvVIlwZePSt0B3tEqEFWbC4tOatFxkC6cK9/Y1shet8ALGTOmg2RBKhAGxU9iRl3l5DvNNuDO4/ORGq31hJ6acaUOwIWOUAkgyRMuzicz0Orng57JjKWJ/Udj2oeHoEzTI=http://jump2.bdimg.com/safecheck/index?url=x+Z5mMbGPAvVIlwZePSt0B3tEqEFWbC4tOatFxkC6cK9/Y1shet8ALGTOmg2RBKhAGxU9iRl3l5DvNNuDO4/ORGq31hJ6acaUOwIWOUAkgyRMuzicz0Orng57JjKWJ/Udj2oeHoEzTI=http://jump2.bdimg.com/safecheck/index?url=x+Z5mMbGPAvVIlwZePSt0B3tEqEFWbC4tOatFxkC6cK9/Y1shet8ALGTOmg2RBKhAGxU9iRl3l5DvNNuDO4/ORGq31hJ6acaUOwIWOUAkgyRMuzicz0Orng57JjKWJ/Udj2oeHoEzTI=http://jump2.bdimg.com/safecheck/index?url=x+Z5mMbGPAvVIlwZePSt0B3tEqEFWbC4tOatFxkC6cK9/Y1shet8ALGTOmg2RBKhAGxU9iRl3l5DvNNuDO4/ORGq31hJ6acaUOwIWOUAkgyRMuzicz0Orng57JjKWJ/Udj2oeHoEzTI=http://jump2.bdimg.com/safecheck/index?url=x+Z5mMbGPAvVIlwZePSt0B3tEqEFWbC4tOatFxkC6cK9/Y1shet8ALGTOmg2RBKhAGxU9iRl3l5DvNNuDO4/ORGq31hJ6acaUOwIWOUAkgyRMuzicz0Orng57JjKWJ/Udj2oeHoEzTI=http://jump2.bdimg.com/safecheck/index?url=x+Z5mMbGPAvVIlwZePSt0B3tEqEFWbC4tOatFxkC6cK9/Y1shet8ALGTOmg2RBKhAGxU9iRl3l5DvNNuDO4/ORGq31hJ6acaUOwIWOUAkgyRMuzicz0Orng57JjKWJ/Udj2oeHoEzTI=http://jump2.bdimg.com/safecheck/index?url=x+Z5mMbGPAvVIlwZePSt0B3tEqEFWbC4tOatFxkC6cK9/Y1shet8ALGTOmg2RBKhAGxU9iRl3l5DvNNuDO4/ORGq31hJ6acaUOwIWOUAkgyRMuzicz0Orng57JjKWJ/Udj2oeHoEzTI=http://jump2.bdimg.com/safecheck/index?url=x+Z5mMbGPAvVIlwZePSt0B3tEqEFWbC4tOatFxkC6cK9/Y1shet8ALGTOmg2RBKhAGxU9iRl3l5DvNNuDO4/ORGq31hJ6acaUOwIWOUAkgyRMuzicz0Orng57JjKWJ/Udj2oeHoEzTI=http://jump2.bdimg.com/safecheck/index?url=x+Z5mMbGPAvVIlwZePSt0B3tEqEFWbC4tOatFxkC6cK9/Y1shet8ALGTOmg2RBKhAGxU9iRl3l5DvNNuDO4/ORGq31hJ6acaUOwIWOUAkgyRMuzicz0Orng57JjKWJ/Udj2oeHoEzTI=http://jump2.bdimg.com/safecheck/index?url=x+Z5mMbGPAvVIlwZePSt0B3tEqEFWbC4tOatFxkC6cK9/Y1shet8ALGTOmg2RBKhAGxU9iRl3l5DvNNuDO4/ORGq31hJ6acaUOwIWOUAkgyRMuzicz0Orng57JjKWJ/Udj2oeHoEzTI=http://jump2.bdimg.com/safecheck/index?url=x+Z5mMbGPAvVIlwZePSt0B3tEqEFWbC4tOatFxkC6cK9/Y1shet8ALGTOmg2RBKhAGxU9iRl3l5DvNNuDO4/ORGq31hJ6acaUOwIWOUAkgyRMuzicz0Orng57JjKWJ/Udj2oeHoEzTI=http://jump2.bdimg.com/safecheck/index?url=x+Z5mMbGPAvVIlwZePSt0B3tEqEFWbC4tOatFxkC6cK9/Y1shet8ALGTOmg2RBKhAGxU9iRl3l5DvNNuDO4/ORGq31hJ6acaUOwIWOUAkgyRMuzicz0Orng57JjKWJ/Udj2oeHoEzTI=http://jump2.bdimg.com/safecheck/index?url=x+Z5mMbGPAvVIlwZePSt0B3tEqEFWbC4tOatFxkC6cK9/Y1shet8ALGTOmg2RBKhAGxU9iRl3l5DvNNuDO4/ORGq31hJ6acaUOwIWOUAkgyRMuzicz0Orng57JjKWJ/Udj2oeHoEzTI=http://jump2.bdimg.com/safecheck/index?url=x+Z5mMbGPAvVIlwZePSt0B3tEqEFWbC4tOatFxkC6cK9/Y1shet8ALGTOmg2RBKhAGxU9iRl3l5DvNNuDO4/ORGq31hJ6acaUOwIWOUAkgyRMuzicz0Orng57JjKWJ/Udj2oeHoEzTI=http://jump2.bdimg.com/safecheck/index?url=x+Z5mMbGPAvVIlwZePSt0B3tEqEFWbC4tOatFxkC6cK9/Y1shet8ALGTOmg2RBKhAGxU9iRl3l5DvNNuDO4/ORGq31hJ6acaUOwIWOUAkgyRMuzicz0Orng57JjKWJ/Udj2oeHoEzTI=http://jump2.bdimg.com/safecheck/index?url=x+Z5mMbGPAvVIlwZePSt0B3tEqEFWbC4tOatFxkC6cK9/Y1shet8ALGTOmg2RBKhAGxU9iRl3l5DvNNuDO4/ORGq31hJ6acaUOwIWOUAkgyRMuzicz0Orng57JjKWJ/Udj2oeHoEzTI=http://jump2.bdimg.com/safecheck/index?url=x+Z5mMbGPAvVIlwZePSt0B3tEqEFWbC4tOatFxkC6cK9/Y1shet8ALGTOmg2RBKhAGxU9iRl3l5DvNNuDO4/ORGq31hJ6acaUOwIWOUAkgyRMuzicz0Orng57JjKWJ/Udj2oeHoEzTI=http://jump2.bdimg.com/safecheck/index?url=x+Z5mMbGPAvVIlwZePSt0B3tEqEFWbC4tOatFxkC6cK9/Y1shet8ALGTOmg2RBKhAGxU9iRl3l5DvNNuDO4/ORGq31hJ6acaUOwIWOUAkgyRMuzicz0Orng57JjKWJ/Udj2oeHoEzTI=http://jump2.bdimg.com/safecheck/index?url=x+Z5mMbGPAvVIlwZePSt0B3tEqEFWbC4tOatFxkC6cK9/Y1shet8ALGTOmg2RBKhAGxU9iRl3l5DvNNuDO4/ORGq31hJ6acaUOwIWOUAkgyRMuzicz0Orng57JjKWJ/Udj2oeHoEzTI=http://jump2.bdimg.com/safecheck/index?url=x+Z5mMbGPAvVIlwZePSt0B3tEqEFWbC4tOatFxkC6cK9/Y1shet8ALGTOmg2RBKhAGxU9iRl3l5DvNNuDO4/ORGq31hJ6acaUOwIWOUAkgyRMuzicz0Orng57JjKWJ/Udj2oeHoEzTI=http://jump2.bdimg.com/safecheck/index?url=x+Z5mMbGPAvVIlwZePSt0B3tEqEFWbC4tOatFxkC6cK9/Y1shet8ALGTOmg2RBKhAGxU9iRl3l5DvNNuDO4/ORGq31hJ6acaUOwIWOUAkgyRMuzicz0Orng57JjKWJ/Udj2oeHoEzTI=http://jump2.bdimg.com/safecheck/index?url=x+Z5mMbGPAvVIlwZePSt0B3tEqEFWbC4tOatFxkC6cK9/Y1shet8ALGTOmg2RBKhAGxU9iRl3l5DvNNuDO4/ORGq31hJ6acaUOwIWOUAkgyRMuzicz0Orng57JjKWJ/Udj2oeHoEzTI=http://jump2.bdimg.com/safecheck/index?url=x+Z5mMbGPAvVIlwZePSt0B3tEqEFWbC4tOatFxkC6cK9/Y1shet8ALGTOmg2RBKhAGxU9iRl3l5DvNNuDO4/ORGq31hJ6acaUOwIWOUAkgyRMuzicz0Orng57JjKWJ/Udj2oeHoEzTI=http://jump2.bdimg.com/safecheck/index?url=x+Z5mMbGPAvVIlwZePSt0B3tEqEFWbC4tOatFxkC6cK9/Y1shet8ALGTOmg2RBKhAGxU9iRl3l5DvNNuDO4/ORGq31hJ6acaUOwIWOUAkgyRMuzicz0Orng57JjKWJ/Udj2oeHoEzTI=http://jump2.bdimg.com/safecheck/index?url=x+Z5mMbGPAvVIlwZePSt0B3tEqEFWbC4tOatFxkC6cK9/Y1shet8ALGTOmg2RBKhAGxU9iRl3l5DvNNuDO4/ORGq31hJ6acaUOwIWOUAkgyRMuzicz0Orng57JjKWJ/Udj2oeHoEzTI=http://jump2.bdimg.com/safecheck/index?url=x+Z5mMbGPAvVIlwZePSt0B3tEqEFWbC4tOatFxkC6cK9/Y1shet8ALGTOmg2RBKhAGxU9iRl3l5DvNNuDO4/ORGq31hJ6acaUOwIWOUAkgyRMuzicz0Orng57JjKWJ/Udj2oeHoEzTI=
(占楼)

huxiaozxc 发表于 2018-8-24 19:37:57

用村民的自定义交易内容我觉得就够了

大侠崔 发表于 2018-8-24 19:38:43


(占楼)

无锡亮哥 发表于 2018-8-24 20:00:17

Exciting! 发表于 2018-8-22 13:02
没人看吗

..我杂么了

页: [1] 2 3 4 5 6 7 8 9 10
查看完整版本: [新人贴][命令方块]无需op权限也能用的原版木牌商店!