TerraFirmaCraft

TerraFirmaCraft

2M Downloads

[1.12.2] "skeleton traps” can spawn above world, bypassing the 'preventMobsOnSurface' setting

Charnuz opened this issue · 0 comments

commented

Skeletons riding skeleton horses can still spawn as a result of a thunderstorm, read more here.

this is in net.minecraft.world.WorldServer.updateBlocks():

if (this.getGameRules().getBoolean("doMobSpawning") && this.rand.nextDouble() < (double)difficultyinstance.getAdditionalDifficulty() * 0.01D)
{
    EntitySkeletonHorse entityskeletonhorse = new EntitySkeletonHorse(this);
    entityskeletonhorse.setTrap(true);
    entityskeletonhorse.setGrowingAge(0);
    entityskeletonhorse.setPosition((double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ());
    this.spawnEntity(entityskeletonhorse);
     this.addWeatherEffect(new EntityLightningBolt(this, (double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ(), true));
}
else
{
    this.addWeatherEffect(new EntityLightningBolt(this, (double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ(), false));
}

I don't think this fires a LivingSpawnEvent, so the CommonEventHandler.onLivingSpawnEvent() method will never fire in this case despite that it knows skeleton horses are technically hostile, I believe it will only fire if skeleton horses are spawned in the normal way.

Could make CommonEventHandler.onEntityJoinWorldEvent() handle this like it does with other vanilla mobs, but it should probably check if EntitySkeletonHorse.isTrap() returns true before removing the entity so that skeleton horses are still usable for other things (if necessary).

Meta Info

  • TFC Version: 1.12.2-1.7.11.169
  • Were any other mods included? yes
  • Can you reproduce it without these other mods? yes. this is hard to test for so i recommend adding entity logging to CommonEventHandler.onEntityJoinWorldEvent() for EntitySkeletonHorse, and /weather thunder 100000 in game and going afk for a while