Randomly Spawning Structures
In this tutorial, I will be showing you the basics to spawning structures randomly. For spawning things randomly every method is quite advanced but this is the simplest one. If you are here for the commands rather than learning they are all at the bottom of the page.
The commands I will be using to achieve this are:
• Scoreboard
• Clone
• Execute
• Tp
• Tag
Method / Explanation:
Firstly we need a structure to have in our world. I am going to quickly make a random structure.
The commands I will be using to achieve this are:
• Scoreboard
• Clone
• Execute
• Tp
• Tag
Method / Explanation:
Firstly we need a structure to have in our world. I am going to quickly make a random structure.
Then we need to decide how we are going to have our structure spawning, I am going to use a system which involves checking for how many of a certain mob are in the world as I think this is the easiest method.
To do this method, we will first need to create a scoreboard objective. If you do not know much about the /scoreboard command a tutorial can be found here.
To do this method, we will first need to create a scoreboard objective. If you do not know much about the /scoreboard command a tutorial can be found here.
Now we are set up we can start working on the commands that go in a repeating clock. We need to choose an animal to test and how many we are searching for. This system will increase a score by one for every mob you specified that spawns and then when the score reaches a number of your choose, it will spawn a structure at one of the mobs randomly.
I want my structure to spawn on the surface level and be quite common so I am going to have my mob as a cow and it will search for 15 before spawning the structure.
/scoreboard players set @a MobCheck 0
/execute as @e[type=cow,tag=!Checked] run scoreboard players add @p MobCheck 1
We reset the MobCheck score every tick so the score doesn't stack and it is correct for that tick alone. Also we are testing for cows without a tag because after we reach 15 we will tag them all in order to prevent the score just staying at 15 constantly.
Our next command will check for a player with a score of 15 and if it finds one, it will tag a random cow with the tag structure:
/execute as @a if score @s MobCheck matches 15.. run tag @e[type=cow,tag=!Checked,limit=1,sort=random] add Structure
And after that we will add a conditional command that has
/tag @e[type=cow] add Checked
So that it tags the old cows with the tag.
Now we have the system all set up! However it will not spawn our structure...
To do this we need to execute from the 'Structure' tagged cow and clone the build we made to the same place the cow is. To do this we just do a clone like normal but the destination will just be relative coordinates:
/execute at @e[tag=Structure,type=cow] run clone <x1> <y1> <z1> <x2> <y2> <z2> ~ ~ ~
Pictures above were for the 1.12 page so ignore the different execute format and the 'c=1' as in 1.13 it was replaced to 'limit=1' but you get the idea!
Then finally we need to kill the 'Structure' tagged cow (or whatever your mob is) in order to prevent it constantly cloning the structure to its location.
/tp @e[tag=Structure] ~ ~-999 ~
We use the tp command to make it not have death animation or mob drops.
I hope you learned something! ~Blue :)
Then finally we need to kill the 'Structure' tagged cow (or whatever your mob is) in order to prevent it constantly cloning the structure to its location.
/tp @e[tag=Structure] ~ ~-999 ~
We use the tp command to make it not have death animation or mob drops.
I hope you learned something! ~Blue :)
Your commands should look like this: