自动创建空岛

By MCSugar_cane    2018/04/14

还记得之前的地皮分配嘛,空岛因为通常在虚空世界中无法用扩散实现随机分配,所以就再做了一个正序列队空岛分配的小玩意。

代码适用版本为1.11.2-1.12,逻辑支持1.8.x以上版本

空岛自创建演示地图下载


我的世界空岛分配系统空岛分配系统命令一览

图片就介绍到这里,下面是详情以及代码部分~


详情:

此系统的空岛分配是以X轴正序列队,如在0 60 0开始,第一次创建在X轴+512格(32个区块),第二次在第一次的基础上X轴+512格,则为1024格。这样依次加下去,即可实现分配,十分简单吧~

逻辑有了,要在MC中实现,对于列队的序号要怎么加以保存呢?在玩家身上肯定是不行的,一旦玩家不在线就玩完了,这里我用盔甲架来做载体,每创建之前给其xBlocks增加1,然后使当前列队中的最前玩家的xBlocks等于其xBlocks分值,每1xBlocks则tp ~512 ~ ~格...

另外为了防止玩家在中途退出,我还在其中加了一个当check玩家意外消失后,重新在列队中选中check玩家的系统。另外利用stat.leaveGame准则重置退出玩家的所有数据,防止其再进来时干扰系统正常运行。


代码:

基础部分:

  1. /summon armor_stand ~ ~1 ~ {CustomName:"iStats",CustomNameVisible:1b}
  2. /summon armor_stand ~ ~1 ~ {CustomName:"cTest",CustomNameVisible:1b}
  3. /scoreboard objectives add xBlocks dummy X轴距离
  4. /scoreboard objectives add xB dummy X轴处理
  5. /scoreboard objectives add xBI dummy X轴信息
  6. /scoreboard objectives add leaveG stat.leaveGame
  7. /scoreboard players set 512 xB 512

创建响应:[高频循环]

  1. /execute @a[x=0,y=60,z=5,r=2,tag=!created] ~ ~ ~ detect ~ ~ ~ minecraft:water -1 scoreboard players tag @p[r=0,tag=!created] add arrays [循环]
  2. /blockdata -1002 60 -1003 {auto:true} [连锁](条件制约)
  3. /execute @a[x=0,y=60,z=5,r=2,tag=created] ~ ~ ~ detect ~ ~ ~ minecraft:water -1 tellraw @p[r=0,tag=created] ["\u00a7a\u00a7l[甘小蔗] \u00a7c\u00a7l你已经拥有空岛啦,给别人留一点吧!"] [连锁]
  4. /tp @a[x=0,y=60,z=5,r=2,tag=created] 0 60 0 [连锁](条件制约)

-1002 60 -1003处脉冲组:

  1. blockdata ~ ~ ~ {auto:false}
  2. gamemode 3 @a[tag=arrays,m=!3]
  3. title @a[tag=arrays] title ["\u00a77\u00a7l正在为您\u00a78\u00a7l创建空岛"]
  4. title @a[tag=arrays] subtitle ["\u00a7a\u00a7lMore on \u00a72\u00a7lGanxiaozhe.com"]
  5. scoreboard players tag @p[tag=arrays] add check
  6. tellraw @a[tag=arrays,m=3,tag=!check] ["\u00a7c\u00a7l[提示] \u00a7e\u00a7l请稍后,当前正在为",{"selector":"@p[tag=check]","color":"gold","bold":"true"},"\u00a7e\u00a7l创建中..."]
  7. scoreboard players add @e[type=armor_stand,name=iStats] xBlocks 1
  8. scoreboard players operation @p[tag=check] xBlocks = @e[type=armor_stand,name=iStats,c=1] xBlocks
  9. scoreboard players operation @p[tag=check] xB = @e[type=armor_stand,name=iStats,c=1] xBlocks
  10. tp @p[tag=check,score_xBlocks_min=1] 0 60 0
  11. blockdata -1002 60 -1005 {auto:true}

-1002 60 -1005处循环组:[高频循环]

  1. tp @a[score_xBlocks_min=1000,score_xBlocks=9999,tag=check] ~512000 ~ ~
  2. scoreboard players remove @a[score_xBlocks_min=1000,score_xBlocks=9999,tag=check] xBlocks 1000
  3. tp @a[score_xBlocks_min=100,score_xBlocks=999,tag=check] ~51200 ~ ~
  4. scoreboard players remove @a[score_xBlocks_min=100,score_xBlocks=999,tag=check] xBlocks 100
  5. tp @a[score_xBlocks_min=10,score_xBlocks=99,tag=check] ~5120 ~ ~
  6. scoreboard players remove @a[score_xBlocks_min=10,score_xBlocks=99,tag=check] xBlocks 10
  7. tp @a[score_xBlocks_min=1,score_xBlocks=9,tag=check] ~512 ~ ~
  8. scoreboard players remove @a[score_xBlocks_min=1,score_xBlocks=9,tag=check] xBlocks 1
  9. execute @a[score_xBlocks=0,tag=check] ~ ~ ~ blockdata -1002 60 -1006 {auto:true}
  10. execute @a[score_xBlocks=0,tag=check] ~ ~ ~ blockdata -1002 60 -1005 {auto:false}
  11. scoreboard players tag @e[type=armor_stand,name=cTest] add nocheck
  12. execute @a[tag=check] ~ ~ ~ scoreboard players tag @e[type=armor_stand,name=cTest,tag=nocheck] remove nocheck
  13. execute @e[type=armor_stand,name=cTest,tag=nocheck] ~ ~ ~ blockdata -1002 60 -1005 {auto:false}
  14. execute @e[type=armor_stand,name=cTest,tag=nocheck] ~ ~ ~ /blockdata -1002 60 -1003 {auto:true}

-1002 60 -1006处脉冲组:

  1. blockdata ~ ~ ~ {auto:false}
  2. execute @a[score_xBlocks=0,tag=check] ~ ~ ~ fill ~-4 ~ ~-4 ~4 ~ ~4 grass
  3. execute @a[score_xBlocks=0,tag=check] ~ ~ ~ fill ~-4 ~-1 ~-4 ~4 ~-5 ~4 stone
  4. execute @a[score_xBlocks=0,tag=check] ~ ~ ~ setblock ~ ~1 ~ minecraft:sapling 0 replace
  5. execute @a[score_xBlocks=0,tag=check] ~ ~ ~ setblock ~-1 ~1 ~ minecraft:chest 4 replace {CustomName:"www.Ganxiaozhe.com",Items:[{id:minecraft:bone,Count:10b,Damage:0s,Slot:0b},{id:minecraft:water_bucket,Count:1b,Damage:0s,Slot:1b},{id:minecraft:lava_bucket,Count:1b,Damage:0s,Slot:2b},{id:minecraft:iron_ingot,Count:8b,Damage:0s,Slot:3b},{id:minecraft:melon,Count:4b,Damage:0s,Slot:4b},{id:minecraft:potato,Count:2b,Damage:0s,Slot:5b},{id:minecraft:reeds,Count:1b,Damage:0s,Slot:6b}]}
  6. execute @a[score_xBlocks=0,tag=check] ~ ~ ~ setblock ~-3 ~ ~ minecraft:obsidian 0 replace
  7. execute @a[score_xBlocks=0,tag=check] ~ ~ ~ spawnpoint @p[r=0,tag=check] ~-3 ~1 ~
  8. execute @a[score_xBlocks=0,tag=check] ~ ~ ~ scoreboard players operation @p[r=0] xBI = @p[r=0] xB
  9. execute @a[score_xBlocks=0,tag=check] ~ ~ ~ scoreboard players operation @p[r=0] xBI *= 512 xB
  10. tellraw @a[score_xBlocks=0,tag=check] ["\u00a76\u00a7l[甘小蔗] \u00a7a\u00a7l空岛创建成功,您的空岛坐标为: ",{"score":{"name":"@p[score_xBlocks=0,tag=check]","objective":"xBI"},"color":"gold","bold":"true"},"\u00a76\u00a7l,60,0"]
  11. tp @a[score_xBlocks=0,tag=check,m=3] ~-3 ~2.2 ~ -90.0 7.0
  12. gamemode 0 @a[score_xBlocks=0,tag=check,m=3]
  13. scoreboard players tag @a[score_xBlocks=0,tag=check] remove arrays
  14. scoreboard players tag @a[score_xBlocks=0,tag=check] add created
  15. scoreboard players tag @a[score_xBlocks=0,tag=check] remove check
  16. execute @a[tag=arrays] ~ ~ ~ blockdata -1002 60 -1003 {auto:true}

arrays玩家退出处理:[高频循环]

  1. scoreboard players tag @a[score_leaveG_min=1,tag=arrays] remove check
  2. scoreboard players reset @a[score_leaveG_min=1,tag=arrays] xBlocks
  3. tellraw @a[score_leaveG_min=1,tag=arrays] ["\u00a7a\u00a7l[甘小蔗] \u00a7c\u00a7l检测到您曾在创建过程中退出游戏,已为您重置您的所有数据"]
  4. scoreboard players tag @a[score_leaveG_min=1,tag=arrays] remove arrays


欢迎加群交流划水:481528679