Mega Torch not blocking Phantoms
Xalcon opened this issue ยท 10 comments
Due to the way phantoms work, they are currently not blocked by the mega torch.
Phantoms don't use the WorldSpawner
but the PhantomSpawner
instead. This spawner doesn't have any forge provided hooks, so a more manual solution is required for now.
Option 1 - Extend Phantom Spawner and inject into overworld class
The idea is to extend the spawner class by literally copying its logic and adding additional events to it. Afterwards the field phantomSpawner
inside the OverworldChunkGenerator
needs to be replaced with this new class. This might be incompatible with other world generation mods like Biomes o Plenty.
Option 2 - Bytecode Manipulation
The more aggressive solution - and as long as no other mod is also modifying the class in this way, fairly compatible with other mods. This should be controllable via config options in case of compatibility issues with other mods.
Option 3 - Forge Pull Request
This is obviously the longterm goal.
I made a PR to forge to get this added.
MinecraftForge/MinecraftForge#7569
Hopefully it gets accepted. :D
The PR got pulled. it should just work, but I've noticed in my testing that Phantoms still spawn despite the torch being in the world. The mod is seeing the new phantoms though.
[17:42:53] [Server thread/DEBUG] [ne.xa.to.Torchmaster/]: LivingSpawnEvent.CheckSpawn - IsSpawner: false, Reason: NATURAL, Type: minecraft:phantom
[17:42:53] [Server thread/DEBUG] [ne.xa.to.Torchmaster/]: Allowed spawn of minecraft:phantom
I'll look into it. Which Version of forge contains this change? There might be an issue with the block-list
Is there a way to convince phantoms to spawn? I've created a new world and stood on a beach for 6h straight, no blocks above me and didnt get any phantom spawns.
Edit <world_dir>/stats/<your_uuid>.json
and set "minecraft:time_since_rest"
to an insane number. Mine is at 100000000
and I basically get swarmed with them.
Okay, I set the spawn radius to 256 just to see if I could reproduce my original claim and I saw this in my log
[25Feb2021 16:46:43.519] [Server thread/DEBUG] [net.xalcon.torchmaster.Torchmaster/]: CheckSpawn - IsSpawner: false, Reason: NATURAL, Type: minecraft:phantom
[25Feb2021 16:46:43.519] [Server thread/DEBUG] [net.xalcon.torchmaster.Torchmaster/]: Blocking spawn of minecraft:phantom
[25Feb2021 16:50:57.517] [Server thread/DEBUG] [net.xalcon.torchmaster.Torchmaster/]: CheckSpawn - IsSpawner: false, Reason: NATURAL, Type: minecraft:phantom
[25Feb2021 16:50:57.517] [Server thread/DEBUG] [net.xalcon.torchmaster.Torchmaster/]: Blocking spawn of minecraft:phantom
So yeah, guess I'll just have to have players spam torches in the sky if they want to block phantoms. Thanks for looking into it though.
So yeah, guess I'll just have to have players spam torches in the sky if they want to block phantoms. Thanks for looking into it though.
Thats one way to do it. One alternative would be to change how the torch works, i.e. only check x + z and ignore height during volume checks. Alternatively a different block that has a bigger range but only handles phantoms? If someone has an idea, we can discuss it in a different issue.
Since this feature is implemented in forge and working in torchmaster, I'll close this now. Thank you for contributing to forge and indirectly to torchmaster :)
I just want to say that I was technically correct with my original message.
The way that I wrote this patch, it ended up being BEFORE the phantom is moved to the real location. That is what func_174828_a
is doing, moving the phantom to the correct location. That is done AFTER the event is posted to the event bus. When the phantom was originally created, it was set at the origin of 0, 0, 0.
So this is actually weird behavior that I defined with my forge PR. That is why setting the value to 256 works, because at a random spawn between 256 of the world origin, it's now technically "in range" of the 0, 0, 0, and thus able to block the phantom.
MY BAD.