RunasSudo-AWOLindefinitely, on 12 January 2013 - 01:15 PM, said:
ChunLing, on 12 January 2013 - 04:03 AM, said:
why the heck can't I get/set this value?
If something is set as "private" or "protected", there's usually a good reason for it (validation, need to keep track of stuff, etc) and you can usually get it in some form or another through some method. But, if you reealllly want to...
If his experience is mainly coding minecraft mods, I could understand frustration with what variables are set private or protected. Notch's code is largely irrational, and seems to have had little thought put into what might need to be accessed externally (External to the class/object, not necessarily the net.minecraft.* package, but that too). Forge helps significantly, but yeah... Reflection is something you're going to probably need to become friends with if you want to mod minecraft in significant ways.
Orwell, on 12 January 2013 - 02:12 PM, said:
Not that many languages support something like reflection. I sure as hell know that C++ doesn't.

But well, you just make a getter and/or a setter where needed and only where needed.

It depends on your definition of reflection. Technically, Java's access control manipulation isn't reflection per-se. It
uses reflection, but it's a separate subject. Reflection is simply accessing classes/functions based on mapping string data to code names, which both C and C++ can do, though you don't see it that often.
But if in C I were to, say, create an enum storing a set of functions as pointers, and then read a string from a user's input and pull a matching entry from the enum, and call the pointer as a function, this would technically be reflection.