How to replicate Player:GetShootPos() function

So im developing a custom wep base which does not use the default viewmodel entities (the predicted ones) it rather uses custom clientside entities combined together (arms and weapon) so i can have a better control over each ones animations, particles, sounds and stuff. The thing is since im not using those default entities, when i call GetShootPos() clientside it returns the center of the player’s view since there is no viewmodel with a muzzle attachment to look for. Does anybody know how exactly GetShootPos() works? I did try to find it on the SDK source files but i didnt find anything to replicate the code using my own clientside entities on it.

pic of the bullet trail coming from the middle of the screen:

GetShootPos() is always supposed to return the actual position the bullet is spawned/traced from.

This is the same as calling Entity:EyePos on the player.

Oh that i know very well, the problem is that clientside it uses the default viewmodel entity as a reference for the muzzle position so what im missing is the way it calculates each vector to get the correct positions, if there is a way to get this function’s source code somewhere or have some similar exemple i could do what i need using any other entity as reference.

Is the goal to get the muzzle position? Trying to understand the exact issue

The muzzle position is simple, the problem is fixing it when it gets obstruct by other things like walls or objects, the idea i had is first get the muzzle pos and then adjust it to the eye position based on how clear the traced line is from the shoot pos itself and the shoot direction, i just dont know how to properly make those calcs in the code.