That doesn't make sense. Entity ID is an index number given to keep track of the entity in the world.
Normally when you create a new entity, this number is incremented (so all entries are unique)
I think this is the filed that MC uses to synchronize objects between server and client side.
Using ClientWorld#addEntity(id, entity) adds the entity to the [client] world using the provided ID instead of the ID from the entity you just created
public void addEntity(int p_217411_1_, Entity p_217411_2_) {
this.addEntityImpl(p_217411_1_, p_217411_2_);
}
private void addEntityImpl(int p_217424_1_, Entity p_217424_2_) {
if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityJoinWorldEvent(p_217424_2_, this))) return;
this.removeEntityFromWorld(p_217424_1_);
this.entitiesById.put(p_217424_1_, p_217424_2_);
this.getChunkProvider().getChunk(MathHelper.floor(p_217424_2_.posX / 16.0D), MathHelper.floor(p_217424_2_.posZ / 16.0D), ChunkStatus.FULL, true).addEntity(p_217424_2_);
p_217424_2_.onAddedToWorld();
}
using addEntity(entity.getEntityID(),entity) copies the ID from the entity you just created, which is the next sequential ID, that's why I pull the ID from the spawn packet (which has the original ID).
I resolved the cross-side [thread] issue by creating a separate client-only Class [ClientWork] and putting the spawn code there as a static method. It works now, but the client rendered entity disappears almost immediately. If I increment the ID, it spawns an unsynchronized client entity that just drops to the ground (can't even kill it with '/kill @e' .
Updated Code
...so close