Random Samples - ProjectZulu/JustAnotherSpawner GitHub Wiki

##Villagers

Villagers by AnvilPuncher

Hi,

I was working on some things with spawning and I thought I would share what I have done. I was interested in making Villagers and VillagerGolems spawn in empty "villages." Some mods such as those that create structures may not be able to spawn a villager without some mob spawner, which is messy. I had to make some definitions such as what would count as a village and where and under what conditions should the denizens spawn in. The VILLAGE spawner was created in CreatureType.cfg:

"VILLAGE": {
"Spawn Rate": 50,
"Spawn Cap": 64,
"Chunk Spawn Chance": 0.0,
"Spawn Medium": "air",
"Iterations Per Chunk": 20,
"Iterations Per Pack": 4,
"Spawn Tag": "posY>180||posY<30||!block({'minecraft:wooden_door'},{16,5,16},{0,0,0})||!solidside(1,{0,0,0},{0,-1,0})||liquid({0,0,0},{0,0,0})||normal({0,0,0},{0,0,0})||normal({0,0,0},{0,1,0})||!opaque({0,0,0},{0,-1,0})||block({'minecraft:air'},{0,0,0},{0,-1,0})",
"Default Biome Cap": -1,
"Biome Caps": {}
},

Most notably, it allows for spawning of this type within the Y levels specified and within 16 meters of a regular wood door.

Next, spawn conditions for the actual Villager is in the Entity Handler folder's file Vanilla.cfg:

"Villager": {
"Type-Enabled": "VILLAGE-true",
"Spawn Operand": "OR",
"Spawn Tag": "!block({'minecraft:bed'},{10,0,10},{0,0,0})||obj.sky()||obj.light<9||!(util.inRange(obj.countJASEntitiesInRange({'Villager'}, 0, 8), 0, 1))||!(util.inRange(obj.countJASEntitiesInRange({'Villager'}, 0, 32), 0, 9))",
"Despawn Tags": "true",
"Contents": [
"Villager"
]
},

These tags make Villagers only spawn close to a bed and inside with a light level 10 or higher. They also constrain Villager generation to a maximum of 2 in a close area and 10 in a larger area. This is because (as far as I can tell) JAS doesn't have a way to actually count the number or doors in an area so this is made to make sure that smaller towns in an area don't create too many villagers. Of course, vanilla villages don't have beds generate within them, so one can make adjustments to these constraints as necessary for their tastes.

Also, I want VillagerGolems to generate. I cooked up these tags to constrain them but also to make villages more defensible. Inside the EntityHandler folder's Vanilla.cfg this was placed:

"VillagerGolem": {
"Type-Enabled": "VILLAGE-true",
"Spawn Operand": "OR",
"Spawn Tag": "!obj.sky||!block({'minecraft:furnace'},{8,3,8},{0,0,0})||!(util.inRange(obj.countJASEntitiesInRange({'Villager'}, 0, 64), (((obj.countJASEntitiesInRange({'VillagerGolem'}, 0, 64))*5)+5), 64))",
"Despawn Tags": "!liquid({0,0,0},{0,1,0})",
"Contents": [
"VillagerGolem"
]
},

This one is a bit hairier and requires there to be a furnace nearby, again adjust to one's taste. The rest of the spawn tag relates to being able to generate if there are at least 5 villagers per golem. Both counts have a maximum of 64, which is the same as the spawn cap in CreatureType. The golem also becomes despawnable if he is immersed in water.

And last, the SpawnListEntries folder's file Vanilla.cfg must be populated with direction for these spawns by biome. Since they are considered under the VILLAGE spawner, they will need their own listing. The entry below will need to be placed in each biome (group) villagers are expected to spawn.

"VILLAGE": {
"Villager": {
"Weight-PassivePackMax-ChunkPackMin-ChunkPackMax": "10-1-0-0"
},
"VillagerGolem": {
"Weight-PassivePackMax-ChunkPackMin-ChunkPackMax": "100-1-0-0"
}
},

The VillagerGolem were made much more likely to spawn because they have a predetermined caps.

Of course now with these guys being able to spawn on their own, placement of vanilla wood doors and beds need to be carefully placed. In the particular games I run, there are many, many doors to choose from and vanilla wood doors are rarely used.

I hope this can help anyone.

##Creating the Same Mob Twice

Yes you can create multiple copies of the same mob, put them in different groups so you can create different spawn tags for them and JAS won't crash!