17173有料社区

查看: 1461|回复: 0

[互助技巧] 装装装!用命令方块做个随身背包+OOC

[复制链接]

457

主题

1388

帖子

4504

积分

正式版主

Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15

绝地求生版面勋章

发表于 2017-12-20 15:29:51 | 显示全部楼层 |阅读模式
效果图

205819ymnk11bizdo1x4py.gif



undefinedIDEAundefined

  首先我们来看单人里面的随身背包,无非就是用箱子或箱子矿车来实现,但箱子有个不好的地方就是它不是实体而无法被选择器选中。只能获取它的绝对位置进行clone才行,而不像箱子矿车可以被选择器选中。在单人中,我们只需要召唤一个箱子矿车,当玩家丢出掉落物后tp至掉落物,不要的时候再tp回来,十分简单。 有关检测指定掉落物可以查看此教程: 检测掉落物


  按照单人的雏形,在多人中只需要一人有一个箱子矿车就可以了,难点就在于如何区分谁是谁的矿车,在这里我引用了之前做箱子商店区分主人的逻辑,为每一个矿车分配ID,并令其所有者ID=矿车ID,判定主人只需要令所有矿车ID减去玩家其ID,若差值等于0也就是两ID相同则为其所有者。




OOC

  为保证指令正确性,OOC请下载附件 随身背包OOC (可将后缀改为txt).log (7.8 KB, 下载次数: 2) *附件仅在网页上可见*
  • /summon falling_block ~ ~1.5 ~ {Time:1,Block:minecraft:redstone_block,Motion:[0d,-1d,0d],Passengers:[{id:falling_block,Time:1,Block:minecraft:activator_rail,Passengers:[{id:commandblock_minecart,Command:blockdata ~ ~-2 ~ {auto:0b,Command:""}},{id:commandblock_minecart,Command:setblock ~37 ~-2 ~0 chain_command_block 5 replace {Command:"/kill @e[type=Item,tag=nobag]",auto:1b}},{id:commandblock_minecart,Command:setblock ~36 ~-2 ~0 chain_command_block 5 replace {Command:"/execute @e[type=Item,tag=nobag] ~ ~ ~ scoreboard players set @p[score_gbag_min=2,score_gbag=2] gbag -1",auto:1b}},{id:commandblock_minecart,Command:setblock ~35 ~-2 ~0 chain_command_block 5 replace {Command:"/execute @e[type=Item,tag=nobag] ~ ~ ~ scoreboard players set @e[tag=bag,score_gbag_min=2,score_gbag=2,c=1,r=2] gbag -1",auto:1b}},{id:commandblock_minecart,Command:setblock ~34 ~-2 ~0 chain_command_block 5 replace {Command:"/execute @e[type=Item,tag=nobag] ~ ~ ~ scoreboard players reset @e[tag=bag,score_gbag_min=2,score_gbag=2,c=1,r=2] gtemp",auto:1b}},{id:commandblock_minecart,Command:"setblock ~33 ~-2 ~0 chain_command_block 5 replace {Command:"/scoreboard players tag @e[type=Item] add nobag {Item:{id:\\"minecraft:barrier\\",Damage:0s,tag:{nobag:1}},OnGround:1b}",auto:1b}"},{id:commandblock_minecart,Command:"setblock ~32 ~-2 ~0 chain_command_block 5 replace {Command:"/replaceitem entity @a[score_gbag_min=1] slot.hotbar.8 barrier 1 0 {display:{Name:\\"回收箱子(按Q使用)\\"},nobag:1,HideFlags:127,ench:[{id:34,lvl:10}]}",auto:1b}"},{id:commandblock_minecart,Command:"setblock ~31 ~-2 ~0 chain_command_block 5 replace {Command:"/clear @a[score_gbag_min=1] barrier 0 64 {display:{Name:\\"回收箱子(按Q使用)\\"}}",auto:1b}"},{id:commandblock_minecart,Command:setblock ~30 ~-2 ~0 chain_command_block 5 replace {Command:"/scoreboard players set @a[score_gbag_min=1,score_gbag=1] gbag 2",auto:1b}},{id:commandblock_minecart,Command:setblock ~29 ~-2 ~0 chain_command_block 5 replace {Command:"/execute @e[tag=bag,score_gtemp_min=0,score_gtemp=0] ~ ~ ~ kill @e[type=Item,tag=isbag,r=1]",auto:1b}},{id:commandblock_minecart,Command:setblock ~28 ~-2 ~0 chain_command_block 5 replace {Command:"scoreboard players set @e[tag=bag,score_gtemp_min=0,score_gtemp=0] gbag 2",auto:1b}},{id:commandblock_minecart,Command:setblock ~27 ~-2 ~0 chain_command_block 5 replace {Command:"/tp @e[type=chest_minecart,tag=bag,score_gtemp_min=0,score_gtemp=0] @e[type=item,tag=isbag]",auto:1b}},{id:commandblock_minecart,Command:setblock ~26 ~-2 ~0 chain_command_block 5 replace {Command:"/execute @p[score_gbag=1,score_gbag_min=1] ~ ~ ~ execute @e[tag=bag,score_gbag_min=1,score_gbag=1] ~ ~ ~ scoreboard players operation @e[c=1,r=0] gtemp -= @p[score_gbag=1,score_gbag_min=1] bagID",auto:1b}},{id:commandblock_minecart,Command:setblock ~25 ~-2 ~0 chain_command_block 5 replace {Command:"/execute @p[score_gbag=1,score_gbag_min=1] ~ ~ ~ /execute @e[tag=bag,score_gbag_min=1,score_gbag=1] ~ ~ ~ /scoreboard players operation @e[c=1,r=0] gtemp = @e[c=1,r=0] bagID",auto:1b}},{id:commandblock_minecart,Command:setblock ~24 ~-2 ~0 chain_command_block 5 replace {Command:"/execute @a[score_gbag=1,score_gbag_min=1] ~ ~ ~ /scoreboard players operation @p[r=0] gtemp = @p[r=0] bagID",auto:1b}},{id:commandblock_minecart,Command:setblock ~23 ~-2 ~0 chain_command_block 5 replace {Command:"/execute @e[type=Item,tag=isbag] ~ ~ ~ scoreboard players set @p[r=6] gbag 1",auto:1b}},{id:commandblock_minecart,Command:"setblock ~22 ~-2 ~0 chain_command_block 5 replace {Command:"/scoreboard players tag @e[type=Item] add isbag {Item:{id:\\"minecraft:chest_minecart\\",Damage:0s,tag:{isbag:1}},OnGround:1b}",auto:1b}"},{id:commandblock_minecart,Command:setblock ~21 ~-2 ~0 chain_command_block 5 replace {Command:"/execute @e[tag=newbag,score_bagID_min=0,score_bagID=0] ~ ~ ~ scoreboard players operation @e[r=0,c=1] bagID = @e[type=armor_stand,name=bagIDStats] bagID",auto:1b}},{id:commandblock_minecart,Command:setblock ~20 ~-2 ~0 chain_command_block 5 replace {Command:"/execute @e[tag=newbag,score_bagID_min=0,score_bagID=0] ~ ~ ~ scoreboard players add @e[type=armor_stand,name=bagIDStats] bagID 1",auto:1b}},{id:commandblock_minecart,Command:setblock ~19 ~-2 ~0 chain_command_block 5 replace {Command:"/scoreboard players add @e[tag=newbag] bagID 0",auto:1b}},{id:commandblock_minecart,Command:setblock ~18 ~-2 ~0 chain_command_block 5 replace {Command:"/scoreboard players set @e[tag=bag,score_gbag=-1] gbag 1",auto:1b}},{id:commandblock_minecart,Command:setblock ~17 ~-2 ~0 chain_command_block 5 replace {Command:"/teleport @e[tag=bag,score_gbag=-1,score_gbag_min=-1] ~ ~1 ~",auto:1b}},{id:commandblock_minecart,Command:setblock ~16 ~-2 ~0 chain_command_block 5 replace {Command:"/scoreboard players tag @e[tag=newbag,score_bagID_min=1] remove newbag",auto:1b}},{id:commandblock_minecart,Command:setblock ~15 ~-2 ~0 chain_command_block 5 replace {Command:"/scoreboard players set @e[tag=newbag,score_bagID_min=1] gbag -1",auto:1b}},{id:commandblock_minecart,Command:setblock ~14 ~-2 ~0 chain_command_block 5 replace {Command:"/execute @e[tag=newbag,score_bagID_min=1] ~ ~ ~ scoreboard players operation @p[r=2] bagID = @e[r=0,c=1] bagID",auto:1b}},{id:commandblock_minecart,Command:"setblock ~13 ~-2 ~0 chain_command_block 5 replace {Command:"/replaceitem entity @a[score_gbag=-1,score_gbag_min=-1] slot.hotbar.8 chest_minecart 1 0 {display:{Name:\\"随身箱子(按Q使用)\\"},isbag:1,HideFlags:127,ench:[{id:34,lvl:10}]}",auto:1b}"},{id:commandblock_minecart,Command:"setblock ~12 ~-2 ~0 chain_command_block 5 replace {Command:"/clear @a[score_gbag=-1,score_gbag_min=-1] chest_minecart 0 64 {display:{Name:\\"随身箱子(按Q使用)\\"}}",auto:1b}"},{id:commandblock_minecart,Command:setblock ~11 ~-2 ~0 chain_command_block 5 replace {Command:"/scoreboard players set @a[score_gbag=0,score_gbag_min=0] gbag -1",auto:1b}},{id:commandblock_minecart,Command:"setblock ~10 ~-2 ~0 chain_command_block 5 replace {Command:"/tellraw @a[score_gbag=0,score_gbag_min=0] [{\\"text\\":\\"\\\\n[随身背包] \\",\\"color\\":\\"dark_green\\",\\"bold\\":\\"true\\"},{\\"text\\":\\"已为您配置您的随身背包。\\",\\"color\\":\\"green\\",\\"bold\\":\\"true\\"},{\\"text\\":\\"      [\\\\u00a7l了解更多\\\\u00a78]\\\\n\\",\\"color\\":\\"dark_gray\\",\\"clickEvent\\":{\\"action\\":\\"open_url\\",\\"value\\":\\"https://www.ganxiaozhe.com/mc/?from=map\\"},\\"bold\\":\\"false\\"}]",auto:1b}"},{id:commandblock_minecart,Command:"setblock ~9 ~-2 ~0 chain_command_block 5 replace {Command:"/execute @a[score_gbag=0,score_gbag_min=0] ~ ~ ~ /summon minecraft:chest_minecart ~ ~-.6 ~ {CustomName:\\"随身背包 - www.Ganxiaozhe.com\\",NoGravity:1b,Invulnerable:1b,Tags:[\\"newbag\\",\\"bag\\"]}",auto:1b}"},{id:commandblock_minecart,Command:setblock ~7 ~-2 ~0 chain_command_block 5 replace {Command:/fill ~ ~ ~ ~-5 ~ ~ air 0,auto:1b}},{id:commandblock_minecart,Command:setblock ~6 ~-2 ~0 chain_command_block 5 replace {Command:/gamerule commandBlockOutput false,auto:1b}},{id:commandblock_minecart,Command:setblock ~5 ~-2 ~0 chain_command_block 5 replace {Command:/scoreboard objectives add bagID dummy 背包ID,auto:1b}},{id:commandblock_minecart,Command:setblock ~4 ~-2 ~0 chain_command_block 5 replace {Command:/scoreboard objectives add gtemp dummy 信息匹配,auto:1b}},{id:commandblock_minecart,Command:setblock ~3 ~-2 ~0 chain_command_block 5 replace {Command:/scoreboard objectives add gbag dummy,auto:1b}},{id:commandblock_minecart,Command:setblock ~8 ~-2 ~0 repeating_command_block 5 replace {Command:/scoreboard players add @a gbag 0,auto:1b}},{id:commandblock_minecart,Command:setblock ~2 ~-2 ~0 repeating_command_block 5 replace {Command:/summon armor_stand ~ ~ ~ {CustomName:"bagIDStats"},auto:1b}},{id:commandblock_minecart,Command:setblock ~ ~1 ~ command_block 0 replace {auto:1b,Command:fill ~ ~ ~ ~ ~-2 ~ air}},{id:commandblock_minecart,Command:kill @e[type=commandblock_minecart,r=1]}]}]}



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

点击这里给我发消息 点击链接加入【17173社区玩家群1】