Is there a way to make cave spiders passive in minecraft?

According to the Wiki "Cave Spiders, like regular spiders, are pacified (made neutral) by bright light." But, in my cave spider spawner area, I am lighting regions with redstone lanterns and the cave spiders are definitely not getting passified...enter image description here

Is the wiki just wrong?


Solution 1:

The wiki is technically correct: cave spiders can be pacified by light, just like regular spiders.

If you decompile Minecraft and deobfuscate its source code using Minecraft Coder Pack (MCP), there are two classes, EntitySpider and EntityCaveSpider, which govern the behavior of spiders and cave spiders, respectively.

EntityCaveSpider is subclass of EntitySpider: in layman's terms, this means that unless otherwise specified, cave spiders inherit all the behaviors and properties of regular spiders.

EntitySpider has a method called findPlayerToAttack(): in it, there's a conditional that checks the light level of the area to determine whether it should be hostile:

float f = getBrightness(1.0F);

if (f < 0.5F) {
  double d = 16D;
  return worldObj.getClosestVulnerablePlayerToEntity(this, d);
}
else {
  return null;
}

This method is not overridden in EntityCaveSpider, meaning cave spiders use the same conditional and thus, can be pacified by light like regular spiders can be.

To confirm that cave spiders are indeed passive at high light levels, you can do the following:

  1. Create a new world. Set the Game Mode to Creative and under More world options..., set the World Type to Superflat.
  2. Open the inventory, and add the Spawn Cave Spider egg to your hot bar.
  3. Use the egg to create a bunch of cave spiders.
  4. Open the chat bar by pressing T.
  5. Type the following and press enter:

    /gamemode 0
    

This will set your game to survival mode: if cave spiders weren't pacified, they'd attack you on sight. However, they shouldn't do that:

Cave spiders being all passive and whatnot

The issue is likely that once a mob has found a player to attack, it does not give up the target until it's either killed, the target has left its aggro radius, or it fails a 1:100 roll to drop aggro when light levels are high enough.