McJtyMods / InControl

Be In Control of Mob Spawns and others
MIT License
44 stars 16 forks source link

[1.18.2] InControl does not fire LivingSpawnEvent.SpecialSpawn for entities it spawns #355

Closed Shadows-of-Fire closed 1 year ago

Shadows-of-Fire commented 1 year ago

Per the title, InC is not firing the SpecialSpawn event, so other mods cannot react to InC-spawned mobs. Offending code is here https://github.com/McJtyMods/InControl/blob/1.18/src/main/java/mcjty/incontrol/spawner/SpawnerSystem.java#L170

The relevant vanilla code is (from NaturalSpawner L183-190 with some parts omitted)

int canSpawn = net.minecraftforge.common.ForgeHooks.canEntitySpawn(mob, pLevel, d0, i, d1, null, MobSpawnType.NATURAL);
if (canSpawn != -1 && (canSpawn == 1 || isValidPositionForMob(pLevel, mob, d2))) {
if (!net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn(mob, (LevelAccessor) pLevel, (float)d0, (float)i, (float)d1, null, MobSpawnType.NATURAL))
spawngroupdata = mob.finalizeSpawn(pLevel, pLevel.getCurrentDifficultyAt(mob.blockPosition()), MobSpawnType.NATURAL, spawngroupdata, (CompoundTag)null);
pLevel.addFreshEntityWithPassengers(mob);
Shadows-of-Fire commented 1 year ago

This issue is also present in 1.19 (and likely others) https://github.com/McJtyMods/InControl/blob/1.19/src/main/java/mcjty/incontrol/spawner/SpawnerSystem.java#L170

McJty commented 1 year ago

Should be fixed now