[Bug]: MCA Zombie Villagers still spawn within megatorch radius
doctordrogon opened this issue · 8 comments
Torchmaster Version
20.1.6
Mod Loader
Neoforge
Mod Loader Version
47.1.106
What happened?
While I was in my survival world with numerous other mods in a custom modpack including MCA: reborn, come night MCA zombie villagers still spawned within the megatorch radius. Of course, when the light level was above 0, no zombie villagers spawned as per vanilla minecraft mechanics. Reply if you need additional details.
Relevant log output
No response
Thank you, I'm able to replicate the issue. It's a bit weired to see. According to their meta data, they are allegedly spawning via natural means, but I'm monitoring all spawn attempts and nothing is spawning at all - yet there they are. This might be some sort of manual forced spawn that just appears to be natural, but I'll need to investigate this. Thank you for reporting this issue.
I love your mod btw. In all my playthroughs of modpacks, if torchmaster was in it, I used it.
They do spawn inside of the range. To replicate this, go to a random dark oak forest in a regular minecraft world with mca reborn (version 7.5.19) and torchmaster installed (version 20.1.6). If you want the exact forest, my world seed is -7886149205501029867, and go to coordinates 725 147 488. After that, place a couple megatorches around the forest and ensure no hostile mobs spawn when it is night. MCA reborn zombie villagers should spawn in the mega torch radius with the default config. There is a setting in the MCA config that just converts mca zombie villager spawning into regular zombie villager spawning, but I'd like to see if there is anything that can be done within the torchmaster mod before that.
I'm unable to replicate this. Are you sure these zombies arent spawning outside the Torch Volume and just walked in? Zombies have a huge tracking range (35 blocks) compared to other mobs like creepers (16 blocks). In version 20.1.7+ you can view the effective range of each torch by right clicking it in the world (Shift+Right click with an empty hand to disable it again)
If it turns out they really spawn inside the volume, then I need to have a reliable way to replicate this.
I think I found whats going on. The problem is, Minecrafts NaturalSpawner determines a spawning location and then prepares the entity for spawning. Forge hooks into that and fires an event (FinalizeSpawn
) which I'm listening for. This event allows me to cancel the spawn by indirectly setting a property in the entity (Mob#spawnCancelled
) - so far, this works fine.
The problem is, the spawn isnt directly blocked after the event was handled. Instead forge blocks the spawn when its trying to enter the world.
Now, MCA hooks into the part just before Forge can check for the property. MCA checks if the entity is a (Villager)Zombie - if yes, prevents the spawn (thats fine!) and then creates its own copy of the zombie but doesnt check for the spawn cancelled property (not good!).
MCA could technically see that the spawn isn't supposed to happen, but they copy the entity anyway and spawn it. This is because the spawn cancelling is a forge specific feature that doesnt exist in fabric, so in their common code its not directly obvious this is happening. They could still have platform specific code (I'm doing that myself in Torchmaster for 1.21), but it can be annoying to setup.
I'd say this is more a bug on MCAs side, rather than Torchmaster, but I still added some compat code that seem to be working. The only issue is, it will block all MCA Zombie Villager Spawns inside Torch volumes. That includes Spawners. It's a special edge case and I'll keep it as a known issue, as long as nobody is complaining.
The issue will be fixed in Torchmaster 20.1.9, the build should be available later today on Github Release, Curseforge and modrinth.
There is no MDK for Neoforge 1.20.1 but I've build it against Forge 47.0.14, which should be binary compatible to neoforge in 1.20.1
// Edit: I just realized I didn't tag the previous releases as neoforge compatible. I've udpated it as well, the new builds should show up for neoforge users as well.