RAT's Mischief

RAT's Mischief

3M Downloads

Rats spawning outside of villages

TheGreatCatAdorer opened this issue ยท 2 comments

commented

Rats were shown to spawn outside of villages on the attached world (requires: Rat's Mischief, Eldritch Mobs) in the latest version (checked today). From a cursory look at your code, it checks that it is in a village, then that a villager is not nearby, but does not query the output of these checks.
Rats also seem to only spawn on the y-level of the player. As this impedes my ability to farm eldritch rats, I wish to have this fixed.
Eldritch Rat Farm Superflat.zip

commented

From a cursory look at your code, it checks that it is in a village, then that a villager is not nearby, but does not query the output of these checks.

There is literally a big if (world.locateStructure(StructureFeature.VILLAGE, blockPos, 5, false) != null), with locateStructure returning null if it can't find the requested structure. After that, there is literally a return villagersNearby.isEmpty() which makes it so canSpawn returns true if there are no Villagers nearby. So I'm not sure what you mean.

To be clear, the nearest village is around 300 blocks away from the rat farm. Your code should only allow them to spawn within five blocks.

No, find structure uses chunks not blocks. That would therefore be 80 blocks, which is still a problem.

Rats also seem to only spawn on the y-level of the player. As this impedes my ability to farm eldritch rats, I wish to have this fixed.

To be fair, most villages are flat, so I guess I could add a random y variation to the value, but even then, it wouldn't be high enough for rats to spawn in your tower.

After testing your world, I don't see an issue? Rats are not spawning for me, even with many players.

commented

To be clear, the nearest village is around 300 blocks away from the rat farm. Your code should only allow them to spawn within five blocks.