Weird issue with mob despawning

Issue description

I was trying to make a Werewolf mob in my mod, that is a villager during the day, turns into a wolf during the night and becomes a villager again when the sun rises.

Then I found a weird bug with it.

I tried spawning some werewolf villagers during the day.

werewolfvillager

Then I set the time to night to check if they trasformed into wolves.

They didn't. They just disappeared.

werewolves

But this isn't the weird thing.

They just reappeared when I set the time back to day:

magicreappear

I used no procedure blocks that turn entities invisible. I've just used spawn and despawn entity blocks.

The procedure of the villager:

villagerp

The procedure of the wolf:wolfp

These procedures are called via the "on mob tick update". These also are the only procedures bound to the mobs.

I also tried spawning the transformed version of the villager during the day, and it transformed into the villager (as designed). I tried during the night and I saw it disappearing, until I set the time to day and found a villager there...

Since it seems the problem is the wolf, I later tried unbinding the procedure from it. By removing the procedure, I was able to see it and everything worked fine, except it obviously didn't transform back into a villager during the day (because there was no procedure bound to it).

I really don't know what happened and why one mob works while the other is "invisible" :/

Issue comments

This is rather strange. One of the things I would suggest you to try is to check if the provided world is not remote, so your procedure only happens on the server side.

How could I check? I was playing in a normal singleplayer world in Mcreator runclient

Even in singleplayer, there is a server and client running. There is a is provided world remote (client side) procedure block in World data. And negate it so it is true when it is NOT the client side.

It works now! Thank you :D

I've only added the procedure block to the wolf procedure, do you think I should add it to the villager too to prevent further issues?

Also (I'm sorry if I'm asking too many questions), what does it exactly do? Just to prevent future issues

Some triggers are triggered on both server and client side of the Minecraft. The client-side only happens for the player that started the action or for all of them if it is global action, but the server is not aware of the procedure that happens on the client only. If you check that you are on the server side, the procedure will only happen on the server and the server will notify the clients of the change properly.

This coding doesnt seem to work in 2021.1 if anyone could help me on this, basically it just infinitely does the tick update making the werewolf spam particles and be unable to do any time of AI movement. same with the Human