自动创建空岛v1.2

Ganxiaozhe
2019/08/04

未经作者授权,禁止转载

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

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

v1.2利用marker创建空岛而非玩家,并将标签check修改为了gxz-is-creating
v1.1将创建中玩家模式改为了冒险,通过漂浮255防止下坠,防止玩家在创建过程中使用中键tp。
v1.0优化代码,将领取空岛与返回空岛结合在了一起,改用虚拟分数储存信息。
v0.6新增空岛保护
v0.5修复关于创建途中退出的处理模块
v0.4新增空岛返回系统

空岛自创建演示地图下载


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

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


详情

此系统的空岛分配是以X轴正序列队,如在0 60 0开始,第一次创建在X轴+3000格,第二次在第一次的基础上X轴+3000格,则为6000格。这样依次递增,即可实现分配,十分简单吧~

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

此外,当玩家被tp后还不能立马exe执行指令,因为当前区块还没被完全加载,所以会导致指令无法被执行的情况,加一个延迟就可以很好地解决。

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

空岛保护这里则是利用了流动uid分配来实现,而非使用xBStorage进行对比,目的是为了方便后期维护或加新功能。比如和好友系统联用,使好友间互相共享空岛使用权限。


代码

初始化:

  1. /scoreboard objectives add uid dummy 流动uid
  2. /scoreboard objectives add xBlocks dummy X轴信息
  3. /scoreboard objectives add cLTimer dummy 空岛创建延迟
  4. /scoreboard objectives add leaveG stat.leaveGame 检测玩家退出游戏
  5. /scoreboard objectives add xBStorage dummy 玩家空岛X轴记录
  6. /scoreboard objectives add uidStorage dummy 玩家空岛储存玩家id
  7. /scoreboard objectives add IPro_temp dummy 空岛保护temp

流动uid分配:

  1. scoreboard players add @a uid 0
  2. execute @p[score_uid_min=0,score_uid=0] ~ ~ ~ scoreboard players add UIDStats uid 1
  3. execute @p[score_uid_min=0,score_uid=0] ~ ~ ~ scoreboard players operation @s uid = UIDStats uid

创建响应:[高频循环]

  1. /execute @a[x=66,y=112,z=-59,r=2,tag=!created,m=!3] ~ ~ ~ detect ~ ~ ~ minecraft:water -1 scoreboard players tag @s[tag=!created] add arrays
  2. cond:/scoreboard players reset @a[tag=arrays] leaveG
  3. cond:/blockdata 65 100 -42 {auto:true}
  4. /execute @a[x=66,y=112,z=-59,r=2,tag=created] ~ ~ ~ detect ~ ~ ~ minecraft:water -1 scoreboard players tag @s add backIsland
  5. cond:title @a[tag=backIsland] title ["\u00a77\u00a7l正在为您\u00a7e\u00a7l返回空岛"]
  6. cond:/execute @a[tag=backIsland] ~ ~ ~ scoreboard players operation @s xBlocks = @s xBStorage
  7. cond:/tp @p[tag=backIsland] 0 80 0
  8. cond:/blockdata 69 100 -42 {auto:true}

65 100 -42处脉冲组:

  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 gxz-is-creating
  6. tellraw @a[tag=arrays,m=3,tag=!gxz-is-creating] ["\u00a7c\u00a7l[提示] \u00a7e\u00a7l请稍后,当前正在为",{"selector":"@p[tag=gxz-is-creating]","color":"gold","bold":"true"},"\u00a7e\u00a7l创建中..."]
  7. execute @p[tag=gxz-is-creating] ~ ~ ~ scoreboard players add iStats xBlocks 1
  8. scoreboard players operation @p[tag=gxz-is-creating] xBStorage = iStats xBlocks
  9. summon minecraft:area_effect_cloud 0 80 0 {CustomName:"islandCreater",Tags:["gxz-island-creater"],PersistenceRequired:true,Duration:2147483647}
  10. scoreboard players operation @e[tag=gxz-island-creater] xBlocks = iStats xBlocks
  11. execute @p[tag=gxz-is-creating] ~ ~ ~ blockdata 66 100 -42 {auto:true}

66 100 -42处循环组:[高频循环][红石激活]

  1. tp @e[score_xBlocks_min=1000,score_xBlocks=9999,tag=gxz-island-creater] ~3000000 ~ ~
  2. scoreboard players remove @e[score_xBlocks_min=1000,score_xBlocks=9999,tag=gxz-island-creater] xBlocks 1000
  3. tp @e[score_xBlocks_min=100,score_xBlocks=999,tag=gxz-island-creater] ~300000 ~ ~
  4. scoreboard players remove @e[score_xBlocks_min=100,score_xBlocks=999,tag=gxz-island-creater] xBlocks 100
  5. tp @e[score_xBlocks_min=10,score_xBlocks=99,tag=gxz-island-creater] ~30000 ~ ~
  6. scoreboard players remove @e[score_xBlocks_min=10,score_xBlocks=99,tag=gxz-island-creater] xBlocks 10
  7. tp @e[score_xBlocks_min=1,score_xBlocks=9,tag=gxz-island-creater] ~3000 ~ ~
  8. scoreboard players remove @e[score_xBlocks_min=1,score_xBlocks=9,tag=gxz-island-creater] xBlocks 1
  9. scoreboard players add @e[score_xBlocks=0,tag=gxz-island-creater] cLTimer 0
  10. scoreboard players set @e[score_xBlocks=0,score_cLTimer=0,score_cLTimer_min=0,tag=gxz-island-creater] cLTimer 40
  11. scoreboard players remove @e[score_xBlocks=0,score_cLTimer=60,score_cLTimer_min=2,tag=gxz-island-creater] cLTimer 1
  12. tp @p[tag=gxz-is-creating] @e[score_xBlocks=0,score_cLTimer=60,score_cLTimer_min=2,tag=gxz-island-creater]
  13. execute @e[score_xBlocks=0,score_cLTimer=1,score_cLTimer_min=1,tag=gxz-island-creater] ~ ~ ~ blockdata 67 100 -42 {auto:true}
  14. execute @e[score_xBlocks=0,score_cLTimer=1,score_cLTimer_min=1,tag=gxz-island-creater] ~ ~ ~ blockdata 66 100 -42 {auto:false}
  15. scoreboard players set quitCreate xBlocks 1
  16. execute @a[tag=gxz-is-creating] ~ ~ ~ scoreboard players set quitCreate xBlocks 0
  17. scoreboard players test quitCreate xBlocks 0 0
  18. cond:blockdata 66 100 -42 {auto:false}
  19. cond:blockdata 65 100 -42 {auto:true}

67 100 -42处脉冲组:

  1. blockdata ~ ~ ~ {auto:false}
  2. execute @e[score_xBlocks=0,tag=gxz-island-creater] ~ ~ ~ clone 16 35 -85 9 43 -67 ~-4 ~-1 ~-7
  3. execute @e[score_xBlocks=0,tag=gxz-island-creater] ~ ~ ~ spawnpoint @p[r=6,tag=gxz-is-creating] ~ ~1 ~
  4. execute @e[score_xBlocks=0,tag=gxz-island-creater] ~ ~ ~ summon minecraft:area_effect_cloud ~ ~1 ~ {CustomName:"islandMarker",PersistenceRequired:true,Duration:2147483647}
  5. execute @e[score_xBlocks=0,tag=gxz-island-creater] ~ ~ ~ execute @p[tag=gxz-is-creating,r=6] ~ ~ ~ scoreboard players operation @e[type=area_effect_cloud,name=islandMarker,r=6,c=1] uidStorage = @s uid
  6. execute @e[score_xBlocks=0,tag=gxz-island-creater] ~ ~ ~ execute @p[tag=gxz-is-creating,r=6] ~ ~ ~ scoreboard players operation @e[type=area_effect_cloud,name=islandMarker,r=6,c=1] xBStorage = @s xBStorage
  7. execute @e[score_xBlocks=0,tag=gxz-island-creater] ~ ~ ~ gamemode 0 @a[tag=gxz-is-creating,m=3]
  8. execute @e[score_xBlocks=0,tag=gxz-island-creater] ~ ~ ~ scoreboard players tag @a[tag=gxz-is-creating] remove arrays
  9. execute @e[score_xBlocks=0,tag=gxz-island-creater] ~ ~ ~ scoreboard players tag @a[tag=gxz-is-creating] add created
  10. execute @e[score_xBlocks=0,tag=gxz-island-creater] ~ ~ ~ scoreboard players tag @a[tag=gxz-is-creating] remove gxz-is-creating
  11. kill @e[score_xBlocks=0,tag=gxz-island-creater]
  12. execute @a[tag=arrays] ~ ~ ~ blockdata 65 100 -42 {auto:true}


返回空岛,69 100 -42处循环组:[高频循环][红石激活]

  1. tp @a[score_xBlocks_min=1000,score_xBlocks=9999,tag=backIsland] ~3000000 ~ ~
  2. scoreboard players remove @a[score_xBlocks_min=1000,score_xBlocks=9999,tag=backIsland] xBlocks 1000
  3. tp @a[score_xBlocks_min=100,score_xBlocks=999,tag=backIsland] ~300000 ~ ~
  4. scoreboard players remove @a[score_xBlocks_min=100,score_xBlocks=999,tag=backIsland] xBlocks 100
  5. tp @a[score_xBlocks_min=10,score_xBlocks=99,tag=backIsland] ~30000 ~ ~
  6. scoreboard players remove @a[score_xBlocks_min=10,score_xBlocks=99,tag=backIsland] xBlocks 10
  7. tp @a[score_xBlocks_min=1,score_xBlocks=9,tag=backIsland] ~3000 ~ ~
  8. scoreboard players remove @a[score_xBlocks_min=1,score_xBlocks=9,tag=backIsland] xBlocks 1
  9. execute @a[score_xBlocks=0,tag=backIsland] ~ ~ ~ /spreadplayers ~ ~ 0 2 false @s
  10. gamemode 0 @a[score_xBlocks=0,tag=backIsland]
  11. execute @a[score_xBlocks=0,tag=backIsland] ~ ~ ~ blockdata 69 100 -42 {auto:false}
  12. scoreboard players tag @a[score_xBlocks=0,tag=backIsland] remove backIsland
  13. scoreboard players reset @a[score_xBlocks=0] xBlocks


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

  1. scoreboard players tag @a[score_leaveG_min=1,tag=arrays] remove gxz-is-creating
  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. gamemode 2 @a[score_leaveG_min=1,tag=arrays]
  5. scoreboard players tag @a[score_leaveG_min=1,tag=arrays] remove arrays
  6. scoreboard players reset @a[score_leaveG_min=1] leaveG


空岛保护:[高频循环]

  1. scoreboard players reset @a IPro_temp
  2. scoreboard players add @a IPro_temp 0
  3. execute @e[type=area_effect_cloud,name=islandMarker] ~ ~ ~ scoreboard players operation @a[r=2000] IPro_temp = @s uidStorage
  4. execute @a[score_IPro_temp_min=1] ~ ~ ~ scoreboard players operation @s IPro_temp -= @p[r=0] uid
  5. scoreboard players tag @a[score_IPro_temp_min=0,score_IPro_temp=0] add notOIsland
  6. execute @e[type=area_effect_cloud,name=islandMarker] ~ ~ ~ execute @a[tag=!notOIsland,r=2000] ~ ~ ~ title @s actionbar [{"text":"[空岛保护] ","color":"green","bold":true},{"selector":"@s"},{"text":" 您正在编号为","color":"yellow","bold":true},{"score":{"name":"@e[type=area_effect_cloud,name=islandMarker,c=1]","objective":"uidStorage"},"color":"gold","bold":"true"},{"text":"的地皮上","color":"yellow","bold":true}]
  7. execute @e[type=area_effect_cloud,name=islandMarker] ~ ~ ~ execute @a[tag=notOIsland,r=2000] ~ ~ ~ title @s actionbar [{"text":"[空岛保护] ","color":"green","bold":true},{"selector":"@s"},{"text":" 您正在自己或好友的空岛上 [编号#","color":"yellow","bold":true},{"score":{"name":"@e[type=area_effect_cloud,name=islandMarker,c=1]","objective":"uidStorage"},"color":"gold","bold":"true"},{"text":"]","color":"yellow","bold":true}]
  8. execute @e[type=area_effect_cloud,name=islandMarker] ~ ~ ~ gamemode 2 @a[tag=!notOIsland,m=0,r=2000]
  9. execute @e[type=area_effect_cloud,name=islandMarker] ~ ~ ~ gamemode 0 @a[tag=notOIsland,m=2,r=2000]
  10. scoreboard players tag @a[tag=notOIsland] remove notOIsland




LOADING | 此框架正在加载中
QQ群:771363745