Fix entity id remapping

The old system only worked in ints and 1.7 changed some to varints. Since the length of the varint is variable more work is needed to remap ids