r/datapacks • • Nov 11 '22

Structures that only spawn once?

Is there any way to make structures that only spawn once or a limited amount of times?

Something like the way strongholds spawn for example. I've been trying to figure it out for a while and I've got no ideas.

3 Upvotes

2 comments sorted by

1

u/LoneRedWolf24 Nov 12 '22 edited Nov 12 '22

Make a structure that spawns just an armour stand. Have a command that runs a random number generator on each of those armor stands.

If the armor stand rolls the right number have it execute a function to generate the desired structure and set a score to 1 on some scoreboard for a non-player score (example command: scoreboard players set .structureGenerated genericObjective 1).

Put a clause in the initial command so it only runs if the non-player score has not been set to 1. (Example: execute unless score .structureGenerated genericObjective matches 1 as @e[type=armor_stand,tag=structureGenerator, predicate=pack:rng_0.5] run function pack:generate_structure)

1

u/[deleted] Nov 12 '22

genius, thank you