Select Page

/scoreboard objectives add dungeon dummy

Adds a score called dungeon

/execute @a[score_dungeon_min=20000] ~ ~ ~ execute @r[type=Bat] ~ ~ ~ clone x y z x y z ~ ~-1 ~

Executes a player with the score setted at 20000 (change the number to change the frequency of dungeon's spawning) the action to execute a bat the action to clone the structure block.
If you want to spawn a structure on the surface, just use a surface mob instead of a bat (for example a Pig, ...)

/execute @e[type=Bat] ~ ~ ~ detect ~ ~-1 ~ minecraft:structure_block 1 setblock ~ ~-1 ~1 redstone_block

When the block is cloned, all the bats detect a structure block, and if they find it, they place a redstone block, to power the structure block

/execute @e[type=Bat] ~ ~ ~ detect ~ ~-1 ~ minecraft:structure_block 1 fill ~ ~-1 ~1 ~ ~-1 ~ air

When the redstone block is placed, all the bats detect a structure block, and if they find it, they remove the two blocks

/tp @e[type=Bat] ~ 0 ~

Teleports all the bats at bedrock level, so they die. This is used to be sure you don't find two dungeons too near.

/scoreboard players add @a dungeon 1

Adds one to the score of each player

/scoreboard players set @a[score_dungeon_min=20001] dungeon 0

Resets the score of all the players with the score of 20001 or more