Custom Spawner - P3pp3rF1y/AncientWarfare2 GitHub Wiki
The AW Mob Spawner block – how to use it in structure building!
Understanding Mob Spawners – background info – The Vanilla mob spawner vs the AW Mob spawner
The vanilla mob spawner has a default first spawn delay of 20 ticks.
But this delay will only start ticking away, if a player (creative included) is within a 16 blocks range.
Its minimum spawn delay is 200. Its maximum spawn delay is 800. Its maximum entities is 6. Its spawn range is 4 blocks.
All vanilla mob spawners simply check each tick on the entire player list to see if any is within activation range. Then they wait the delay, then they do other checks to spawn groups of mobs. Which means that the more players, the more spawners, the more server cpu time is spent on trying to activate mob spawners, multiplicatively.
The AW "Advanced spawners" wait the delay, then check players within range (if any is set), then do the other checks to spawn a group of mobs. Since a delay is much faster to process than player and other checks, it is much more optimized. And with a randomized delay, the load of the other checks are diluted over the blocks, making a much smoother game. Most checks are also optional, to further improve the efficiency of each spawner.
Knowing these values, you can make good estimates on what changing those values in the AW Mob Spawner will do.
Notes on AW Mob spawning
Once an AW Mob Spawner has spawned all of the mobs it contains, it will disappear.
Most entities have a final say in whether they can spawn or not, no matter whether you have set them to spawn in the spawner. For example, a "Pig" requires grass blocks and a clear area, or it simply will not spawn.
Many creatures, including AW NPCs, will not spawn in any liquid, such as water or lava.
Some mobs will not spawn on wooden planks, or slabs, and others have difficulty on BOP terrain blocks.
There are conditions set by the modders whose mods the mobs are coming from. When creating mob spawners inside structures you must bear in mind the possible “conditions” a modder has set for his mobs to spawn – for example some mobs will only spawn in the Nether. The AW mob spawner block does not override these conditions.
It is advised to set both a big "spawnRange" value, and have a clear space, for big mobs (such as the ender dragon).
Similarly, even small mobs need a clear area to spawn in, relevant to their size – so for example, a mob spawner set in a 1 block wide x 2 block high tunnel will have difficulty spawning a LOTR Troll for example, but could spawn a LOTR Orc.
So, how do you use the AW Spawner Block?
First place your spawner – When you right click on the block in creative mode, you access the blocks GUI.
This main GUI menu screen lists all the essential attributes of the Spawner you have just placed. Lets look in detail at what each of those GUI properties does:
Physical properties of the spawner blocks
debugMode
Whether creative players are "visible" for player checking by the spawner. This means that if you want to watch your players getting slaughtered by your spawner block creations, your presence in Creative Mode, whilst they are battling in survival mode, will not contribute to their misery by spawning more monsters because of your presence.
lightSensitive
If this box is ticked, spawns are cancelled from this spawner if the light level is 8 or more. This ensures that some spawners will only operate at night.
xpToDrop
You can assign an amount of xp orbs to drop when the block breaks after its last spawn. This is good for rewarding players after any difficult spawner groups you may have put together. Also useful for rewarding them when you’ve used Mobs whose creators have neglected to assign them any experience drops.
block hardness
Makes the block harder to destroy, and can be made invulnerable.
transparent
This tick box determines whether the spawner block will be “invisible” (it has no texture but can still be made out by faint black bounding lines, and it is still solid) to players. Good for concealing spawners to prevent players pick axing them before they can spawn anything.
Redstone activated spawner settings
respondToRedstone
If box ticked, redstone power matters in spawner operation
redstoneMode
If redstone matters, whether spawning is redstone-toggled (still delayed) or redstone-pulsed (not delayed)
Detection properties of the spawner blocks
mobRange
This is the entity detection range, which only triggers on living entities. This is the range at which the spawner will check for the maximum number of mobs in play, before it spawns more. For example, if mob range is set to 12, it will only check for maximum mobs in a 12 block area around the spawner.
maxNearbyMonsters
This is the maximum number of living entities within the mobRange, (see above) over which the spawn is cancelled. This prevents too many mobs from being spawned in the given area.
playerRange
The Spawner looks for players within this number of blocks from the spawner. If this is a positive number, it checks for players within this range, and spawns mobs if it can. It will cancel spawning if there are no players within this range.
spawnRange
This is the area within which the spawner will try to spawn its mobs, centered around the spawner. Setting it to 0 means the spawned mob will replace the spawner block in its position – so it may only really works for single mob spawns. So for example, set to 6, the spawner could spawn mobs from 1 to 6 blocks away from the spawner block.
Spawning properties of the spawner blocks
minDelay (number) -> if delay matters, the min amount
maxDelay (number) -> if delay matters, the max amount
spawnDelay (number) -> if delay matters, the delay before next spawn attempt, picked at random between min and max each time it runs out. Begins at 200 on first cycle, right after placing the block.
So, for example, say you want a spawner block to spawn its contents instantly when a player comes within range, you would set minDelay to 0 and maxDelay and spawnDelay to 20.
Spawn Groups
The AW mob spawners are capable of spawning different groups of mobs, and randomizing, by a weight given to each group, which group it spawns.
spawnGroups (custom data) -> the list of spawn groups, within which a group is picked according to its relative weight, if empty, spawner block will disappear
Internal Spawn group NBT:
entityId -> the name of the entity to spawn
customTag -> optional data added to each entity spawned
minToSpawn -> the min number of entities to spawn per attempt
maxToSpawn -> the max number of entities to spawn per attempt
remainingSpawnCount -> if positive, the total number of entities to spawn, after which this group will be removed from the list, if negative, spawns are infinite
Each spawn attempt will make a number of entities spawn between "minToSpawn" and "maxToSpawn", one by one trying to spawn within "spawnRange" blocks range, for a "spawnRange"+5 number of tries each. Only when a spawn is successful will the "remainingSpawnCount" be decreased (if it is positive, of course).
Setting Up
So, now that you know what everything does, or is supposed to do. How do you use it?
First, scroll down to the bottom of the first GUI screen and find the default mob entry for “pig”
At the end of the pig line click on the “-“ symbol to remove that entry.
Now click on “Add Entry” to bring up the selection GUI:
Change Min / Max / Total / to whatever you want for the entity you wish to spawn. For example, I’m going to have this spawner create some Primitive Mobs Haunted Tools, so I set Min to 2, Max to 4 and Total to 8 – which means the spawner can spawn between 2 to 8 Haunted tools, but never more than 4 at a time. And when it reaches 8 it will disappear.
Now to select what Mob to use, press “Pig” opposite “Selected Entry” to bring up the mobs GUI:
This GUi lists every Mob that is available to you, from every mod that puts mobs, creatures or NPC’s into the game. Either scroll and click one; the name will appear under “selected Entity” in the top left, or type into the black box to find the desired mob.
Clicking "done" takes back to the next GUI.
Then click "done" once again, and the spawner is set, or keep adding more entities, from different mods, the same mod, vanilla etc as you want, to spawn in the same group, or into newly added Groups, by using "Add Entity"/"Add Group" buttons.
So in the example above, there is an Attack Group, consisting of 8 x Rabid Bats from Project Zulu, 1 x Flesh Liche, 1 x Vampire and 4 x Butlers for Grimoire of Gaia. Assigned 100 experience orbs for the spawner to drop, and made it invisible.
Of course, the spawner can be scanned separately or in a structure by the AW Scanner, and it retains its info and spawns when the structure spawns.
What happens if you’ve created a structure and for some reason the game playing doesn’t have the mod that the mobs you specified came from? Well, the structure will still spawn, but the mob will be replaced by a default zombie.