Mega Torch blocks spawning from vanilla spawners.
Xalcon opened this issue ยท 6 comments
Minecraft Forge added a hook into the vanilla spawning mechanik of spawners which produces the same event as spawning from low light levels. This causes the spawner to not work while a mega torch is active nearby.
Spawners from other mods (like EnderIO) seem to work without issues.
The mobspawner uses MobSpawnerBaseLogic class to spawn mobs while the low light level spawning mechanik is handled by the WorldEntitySpawner. Both post a CheckSpawn event on the forge event bus which is currently used to determine if an entity is allowed to spawn at a certain position. Sadly, there is no easy way to check if an entity is spawned from a spawner or from the WorldEntitySpawner.
Ways to fix this:
-
Scan for mob spawners in the working radius of all torches and create a bounding box to check against.
Advantage: Least intrusive, fairly easy to implement
Disadvantage: Can be unreliable since we need to scan the world for certain blocks (which can cause chunkloading if not done properly); Impact on performance need to be checked. -
Add a mechanic (item?) to define negative regions inside a torch region. (Similar to 1.)
Advantage: Least intrusive, fairly easy to implement. More reliable than 1.
Disadvantage: Not really transparent to the user, mobspawners still dont work by default, since it needs user interaction. -
Modify list of PotentialSpawns
Advantage: Not used by mob spawner
Disadvantage: Higher impact on performance since this is being called for each block, not just the spawn itself. -
Modify MobSpawnerBaseLogic class
Advantage: Changes the logic at its core, most reliable, low to no impact on performance
Disadvantage: Can cause incompatibilies with other mods, harder to implement (coremod?) -
Add a mechanic that transforms the vanilla MobSpawner into a custom mob spawner provided by TorchMaster
Advantage: Similar performance to 4.
Disadvantage: Same issue as 2; Would cause the mobspawner to disappear if the mod gets removed
There are some other hackish solutions which I didnt inlcude here (like doing a stackwalk, etc)
I've experimented with another idea, which at least work in my dev environment - pretty much a combination of 1 and 5:
Minecraft entities have an general purpose NBT Tag called "tags". When placing down the torch, it scans for nearby mob spawners. Any spawners in range are then modified to spawn entities with an additional NBT Tag ("IsSpawnerMob") which I can check in the CheckSpawn event. I have some minor issues with this atm, but I think I can fix that. I will also add a config option to disable this feature.
Just a headsup on how it works now:
When a mega torch is placed in the world, the torch will iterate through the list of ticking tile entities in the current world. (Which is much faster than scanning for blocks in a bounding box)
Every vanilla spawner in this range will then be modified (each entity spawns with an additional tag "IsSpawnerMob" which is checked in the CheckSpawn event). The overhead is really low and as long as there arent +250k ticking tileentities in your world, there should be no measureable impact - and even if you have that much ticking tileentities, the torch only scans once when its getting placed.
TL;DR: If a vanilla spawner does not work, pick up any nearby mega torch and put it back down.
I'm using version 1.1.0.11 and the torch is still preventing vanilla mob spawner to function. And the config is set to allow this.
Oh, I didn't know that. I placed the torch before the spawner - I moved the spawner with an item from Botania, but replacing the torch solved the problem.
Thank you!