Some user have found this issue before and mentioned that the PR has not been merged yet. Is there any update now?
code:
EnderDragon dragon= (EnderDragon) world.createEntity(EntityTypes.ENDER_DRAGON,start_pos);
try (CauseStackManager.StackFrame frame = Sponge.getCauseStackManager().pushCauseFrame()) {
frame.addContext(EventContextKeys.SPAWN_TYPE, SpawnTypes.PLUGIN);
world.spawnEntity(dragon);
dragon.offer(Keys.PERSISTS, true);
dragon.offer(Keys.AI_ENABLED, true);
dragon.offer(Keys.KNOCKBACK_STRENGTH, 0);
dragon.offer(Keys.INVULNERABLE, true);
} catch (Exception e) {
e.printStackTrace();
}