ruhuasiyu
本帖最后由 ruhuasiyu 于 2018-8-19 09:42 编辑

版本是18w32a+ (1.13-18w30b记分板操作略有不同),思路基于pineapple的帖子并做了较多的变动和改进。

首先弄一个进度,用于判断生物群系
cpp/advancements/generate/root.json
  1. {
  2.     "criteria":{
  3.         "desert":{"trigger":"minecraft:location","conditions": {"biome": "desert"}},
  4.         "desert_hills":{"trigger":"minecraft:location","conditions": {"biome": "desert_hills"}},
  5.         "mutated_desert":{"trigger":"minecraft:location","conditions": {"biome": "mutated_desert"}},
  6.         "mesa":{"trigger":"minecraft:location","conditions": {"biome": "mesa"}},
  7.         "mesa_rock":{"trigger":"minecraft:location","conditions": {"biome": "mesa_rock"}},
  8.         "mesa_clear_rock":{"trigger":"minecraft:location","conditions": {"biome": "mesa_clear_rock"}},
  9.         "mutated_mesa":{"trigger":"minecraft:location","conditions": {"biome": "mutated_mesa"}},
  10.         "mutated_mesa_rock":{"trigger":"minecraft:location","conditions": {"biome": "mutated_mesa_rock"}},
  11.         "mutated_mesa_clear_rock":{"trigger":"minecraft:location","conditions": {"biome": "mutated_mesa_clear_rock"}},
  12.         "roofed_forest":{"trigger":"minecraft:location","conditions": {"biome": "roofed_forest"}}
  13.     },
  14.         "requirements":[[
  15.                 "desert",
  16.                 "desert_hills",
  17.                 "mutated_desert",
  18.                 "mesa",
  19.                 "mesa_rock",
  20.                 "mesa_clear_rock",
  21.                 "mutated_mesa",
  22.                 "mutated_mesa_rock",
  23.                 "mutated_mesa_clear_rock",
  24.                 "roofed_forest"
  25.         ]],
  26.     "rewards":{
  27.         "function":"cpp:generate/creeper_dungeon"
  28.     }
  29. }
复制代码
我这里设定的结构只能在沙漠、平顶山和黑森林生成。

玩家进入指定群系后,执行剥夺进度,检测玩家是否在区域药水云标记的东南32*32区域内
cpp/functions/generate/generate.mcfunction
  1. advancement revoke @s only cpp:generate/root
  2. execute at @s positioned ~-33 -2 ~-33 unless entity @e[tag=cpp_chunk,dx=34,dy=256,dz=34] run function cpp:generate/mark
复制代码
若不在,则将玩家坐标对齐到32的倍数处,并放置药水云,并生成用于随机结构的蝙蝠,spread之后杀死之。
cpp/functions/generate/generate.mcfunction
  1. summon armor_stand ~ -1 ~ {Tags:["cpp_chunk","cpp_undet"],Invulnerable:1b,Invisible:1b,Marker:1b,NoGravity:1b,Small:1b,DisabledSlots:7967}
  2. scoreboard players set #32 cppValue 32
  3. execute store result score @s cppValue run data get entity @s Pos[0]
  4. scoreboard players operation @s cppValue /= #32 cppValue
  5. execute store result entity @e[tag=cpp_undet,sort=nearest,limit=1] Pos[0] double 1 run scoreboard players operation @s cppValue *= #32 cppValue
  6. execute store result score @s cppValue run data get entity @s Pos[2]
  7. scoreboard players operation @s cppValue /= #32 cppValue
  8. execute store result entity @e[tag=cpp_undet,sort=nearest,limit=1] Pos[2] double 1 run scoreboard players operation @s cppValue *= #32 cppValue

  9. summon bat ~ ~ ~ {Silent:1b,NoAI:1,DeathLootTable:"cpp:generate/bat",Tags:["cpp_generate"]}
  10. execute at @e[tag=cpp_undet,sort=nearest,limit=1] run spreadplayers ~ ~ 7 13 false @e[tag=cpp_generate]
  11. tag @e[tag=cpp_undet] remove cpp_undet
  12. kill @e[tag=cpp_generate]
复制代码
然后弄一个loot_table

cpp/loot_tables/generate/bat.json
  1. {
  2.     "pools": [
  3.         {
  4.             "rolls": 1,
  5.             "entries": [
  6.                 {
  7.                     "type": "item",
  8.                     "name": "minecraft:wheat_seeds",
  9.                     "weight": 50,
  10.                     "functions": [
  11.                         {
  12.                             "function": "set_nbt",
  13.                             "tag": "{Tags:["cpp_dead"]}"
  14.                         }
  15.                     ]
  16.                 },
  17.                 {
  18.                     "type": "item",
  19.                     "name": "minecraft:wheat_seeds",
  20.                     "weight": 25,
  21.                     "functions": [
  22.                         {
  23.                             "function": "set_nbt",
  24.                             "tag": "{Tags:["cpp_dead","cpp_wool_tree"]}"
  25.                         }
  26.                     ]
  27.                 },
  28.                 {
  29.                     "type": "item",
  30.                     "name": "minecraft:wheat_seeds",
  31.                     "weight": 1,
  32.                     "functions": [
  33.                         {
  34.                             "function": "set_nbt",
  35.                             "tag": "{Tags:["cpp_dead","cpp_creeper_dungeon"]}"
  36.                         }
  37.                     ]
  38.                 },
  39.                 {
  40.                     "type": "item",
  41.                     "name": "minecraft:wheat_seeds",
  42.                     "weight": 1,
  43.                     "functions": [
  44.                         {
  45.                             "function": "set_nbt",
  46.                             "tag": "{Tags:["cpp_dead","cpp_enchanting_room"]}"
  47.                         }
  48.                     ]
  49.                 },
  50.                 {
  51.                     "type": "item",
  52.                     "name": "minecraft:wheat_seeds",
  53.                     "weight": 1,
  54.                     "functions": [
  55.                         {
  56.                             "function": "set_nbt",
  57.                             "tag": "{Tags:["cpp_dead","cpp_totem_pillar"]}"
  58.                         }
  59.                     ]
  60.                 }
  61.             ]
  62.         }
  63.     ]
  64. }

复制代码
在主循环中,检测蝙蝠的掉落物
cpp/functions/tick.mcfunction (在minecraft:tick函数标签中添加该函数)
  1. execute as @e[type=item,nbt={Item:{tag:{Tags:["cpp_dead"]}}}] at @s run function cpp:generate/build
复制代码
根据掉落物的不同,构建相应的建筑
cpp:generate/build.mcfunction
  1. execute as @s[nbt={Item:{tag:{Tags:["cpp_creeper_dungeon"]}}}] if block ~ 15 ~ cave_air run function cpp:generate/structures/creeper_dungeon
  2. execute as @s[nbt={Item:{tag:{Tags:["cpp_enchanting_room"]}}}] unless block ~ 62 ~ water run function cpp:generate/structures/enchanting_room
  3. execute as @s[nbt={Item:{tag:{Tags:["cpp_totem_pillar"]}}}] unless block ~ 62 ~ water run function cpp:generate/structures/totem_pillar
  4. execute as @s[nbt={Item:{tag:{Tags:["cpp_totem_pillar"]}}}] unless block ~ 62 ~ water positioned ~ ~32 ~ run function cpp:generate/structures/totem_pillar
  5. execute as @s[nbt={Item:{tag:{Tags:["cpp_totem_pillar"]}}}] unless block ~ 62 ~ water positioned ~ ~64 ~ run function cpp:generate/structures/totem_pillar
  6. execute as @s[nbt={Item:{tag:{Tags:["cpp_totem_pillar"]}}}] unless block ~ 62 ~ water positioned ~ ~96 ~ run function cpp:generate/structures/totem_pillar
  7. execute as @s[nbt={Item:{tag:{Tags:["cpp_totem_pillar"]}}}] unless block ~ 62 ~ water positioned ~ ~128 ~ run function cpp:generate/structures/totem_pillar
  8. execute as @s[nbt={Item:{tag:{Tags:["cpp_totem_pillar"]}}}] unless block ~ 62 ~ water positioned ~ ~160 ~ run function cpp:generate/structures/totem_pillar
  9. execute as @s[nbt={Item:{tag:{Tags:["cpp_totem_pillar"]}}}] unless block ~ 62 ~ water positioned ~ ~192 ~ run function cpp:generate/structures/totem_pillar

  10. execute as @s[nbt={Item:{tag:{Tags:["cpp_wool_tree"]}}}] if block ~ ~-1 ~ grass_block run function cpp:plants/trees/wool_sapling

  11. kill @s
复制代码
例如爬行者地牢
cpp/functions/generate/structures/creeper_dungeon.mcfunction
  1. fill ~ 13 ~ ~6 19 ~6 minecraft:air
  2. setblock ~2 14 ~1 minecraft:structure_block{posX:-2,posY:-1,posZ:-1,name:"cpp:build/mossybox",mode:"LOAD",integrity:0.5f}
  3. setblock ~1 14 ~1 minecraft:redstone_block
  4. fill ~ 13 ~ ~6 19 ~6 minecraft:cobblestone keep
  5. fill ~1 14 ~1 ~5 18 ~5 minecraft:air
  6. setblock ~3 14 ~3 minecraft:spawner{MaxNearbyEntities:6s,RequiredPlayerRange:16s,SpawnCount:4s,SpawnData:{id:"minecraft:creeper"},MaxSpawnDelay:800s,MaxSpawnDelay:200s,SpawnRange:4s}
  7. setblock ~3 14 ~5 minecraft:chest{LootTable:"minecraft:chests/simple_dungeon"}
  8. setblock ~3 14 ~1 minecraft:chest[facing=south]{LootTable:"minecraft:chests/simple_dungeon"}
复制代码
这个方法也适用于生成于同生物群系的多种建筑,只需添加多种掉落物并分配权重即可。



2759159258
已阅 不过好像没@   到pineapple......(然而是什么高级的补充?看不懂)
@pineapple

zy934210292
6666666666666666

qq2679415013

很棒的作品!

ruhuasiyu
把计分板操作修改了一下,满足18w32a+版本。

1756746217
哇,,真的好乱,看不懂

ruhuasiyu
1756746217 发表于 2018-8-19 22:46
哇,,真的好乱,看不懂

好乱??