jabelar Posted June 11, 2014 Posted June 11, 2014 The IAnimal interface is kind of wierdly used. Or maybe more likely it is weirdly named by MCP. Normally an interface is used to define the common public methods for a set of classes. It can also be used as a "grouping" mechanism for classes that aren't otherwise in common inheritance -- in other words you can use instanceof to check for implementation of an interface. It seems that IAnimal is empty (no methods) so is used simply for grouping (I'll get to that in a sec). A true "IAnimal" would be expected to define those methods actually used by EntityAnimal, like for mating. However it doesn't so is really just a grouping interface. Now EntityAnimal does in fact implement IAnimal. However, IMob extends IAnimal so that means that all EntityMob subclasses are also instanceof IAnimal, as are boss entities. And EntityAmbientCreature also implements IAnimal. So that is fine, but this is so broad that it doesn't have that much in common, and it doesn't enforce an actual animal-like interface -- i.e. Zombies implement IAnimal (through extension by IMob) but don't mate like EntityAnimal does. As far as I can tell, the only real use of IAnimal is in EntityTracker where it checks for instanceof IAnimal and considers it something that should be tracked. So it seems that IAnimal was really misnamed. It should just be called ITrackable or similar. It has nothing to do specifically with "animals" except for fact that EntityAnimal is one of many classes that implement it. Any thoughts? Do others agree? Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/
sequituri Posted June 11, 2014 Posted June 11, 2014 What you say is another of the many unfortunate name snafus in the codebase. It is likely to stay that way, so get used to it. Quote -S- (if I helped, please click Thank and applaud) http://6upnqa.dm2301.livefilestore.com/y2mtf-vG7Tqq1TiiVpIm53KWj7294NDPoHfSHHb4PzZiMAUfRCfK0UY0MwOu7Q3zTBNVTKqWjr2-xgBfFRpQT5p-QivtvknPpoABMNUw9br9WuZcBFkjePhnAbW500gVm-P/sequiturian.png[/img]
Kwibble Posted June 11, 2014 Posted June 11, 2014 Moral of the story: Always name things appropriately... And make sure it is actually useful. Quote We all stuff up sometimes... But I seem to be at the bottom of that pot.
jabelar Posted June 11, 2014 Author Posted June 11, 2014 Well, the people doing the naming are working hard so I won't be too critical. And I can see why whoever was figuring out the deobfuscation might have thought IAnimal was a suitable name if the first entity they saw extend it was EntityAnimal. The rest of the entities mostly inherit it from IMob so not as clear that the interface was implemented by classes beyond EntityAnimal. So if you were working on MCP and trying to figure out what the interface did it would be easy to start with assumption that it was related to animals. But yeah this is second questionable naming I've found. One I mentioned before is flat-out wrong -- the isClientWorld() method in EntityLivingBase has the logic backwards (it returns true if on server world). Similarly, block method names related to "solid", "collidable", "normalCube", "opaque" and stuff are all probably slightly misnamed because everyone assumes they have to do with pathfinding or colliding with blocks when instead they can be related to other more nuanced meaning. Anyway, I'm definitely getting more cautious about using any field or method without inspecting the implementation carefully. I was surprised by some modders who don't use decomp workspace and instead use dev workspace (without source attached). Seems a little risky to trust the methods functionality based on their deobfuscated names... Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/
Kwibble Posted June 11, 2014 Posted June 11, 2014 Yeah. I don't mean to point and yell at people. But that is still the moral of the story... Name things appropriately. I, for one, use the decomp workspace too. Quote We all stuff up sometimes... But I seem to be at the bottom of that pot.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.