This is a pretty old bug actually (This happens to me since aquatic update). Ever since pufferfish player detection contraptions were a thing, this always happened to me:
The contraption worked pefectly, until suddenly, my pufferfish died for no reason. I finally know why.
When I exit the world and reload it, there's a chance that the pufferfish phases through blocks. Making it suffocate (by block or by air).
There's also some redstone contraptions that break if the world is shut down and then reloaded, but I don't have evidence of that.
Bug Recreation video: https://www.youtube.com/watch?v=RMcs6v4pw3o
Comments 2
Created a new thread without OptiFine. https://bugs.mojang.com/browse/MC-198432
Thank you for your report!
However, this issue is Invalid.
Your game, launcher and/or server is modified.
If you can reproduce the issue in a vanilla environment, please create a new ticket - this is a bug tracker for the game, and not a support website.
Any non-standard client/server/launcher build needs to be taken up with the appropriate team, not Mojang Studios or the Bugtracker.
Any plugin or resource pack issues need to be addressed to the creator of the plugin or resource pack.
If you have problems on large servers, such as The Hive and Hypixel, please contact them first as they run extensively modified server software.
Quick Links:
📓 Issue Guidelines – 🛠 Community Support – 📧 Customer Support – ✍️ Feedback and Suggestions – 📖 Game Wiki
💬 Mojira Subreddit – 💬 Mojira Discord