Closed xymb-endcrystalme closed 2 years ago
It would... And yet, there are tons of helper functions for various entity types, including IsLocalPlayer()
.
Since even IsAbstractGolem()
exists, it's only a matter of time before someone else comes in, asks Where is IsExternalPlayer() ?
and implements one.
And also e->IsExternalPlayer()
beats e->GetType() == EntityType::Player && !e->IsLocalPlayer()
in readability.
I get your point. Actually, IsLocalPlayer()
is the only exception in the Entity
class, because of how it's treated separately from the other entities in the manager. The other functions simply exist because I decided to follow the same entity hierarchy than Mojang in their code. So there is exactly one IsAbstractXXX
function for each abstract class in the hierarchy. Without them you wouldn't be able to simply test if an entity is an hostile mob for example. IsAbstractGolem
only exists because the matching abstract class exists in the hierarchy, even if it's not the most useful one.
Now I didn't add exceptions to the rule (except IsLocalPlayer
which is the exception to the exception) because it's very hard to draw a line: having some sort of quick IsClericVillager
or IsPillagerWithBanner
functions could also be useful.
That being said, the IsRemotePlayer
seems indeed to be a logical counterpart to IsLocalPlayer
.
I didn't watch your code yet, but wouldn't a
e->GetType() == EntityType::Player && !e->IsLocalPlayer()
would do the job?