nextLocalEntityId

fun Level.nextLocalEntityId(): Int

Allocates a unique negative entity ID for a locally spawned entity.

Server entity IDs are always positive, and Level.getNextEntityId returns 0 on the client, which net.minecraft.client.multiplayer.ClientLevel.addEntity rejects by throwing Tried to access entity ID before ID assignment.