Reflection
(really it's introspection because I am not changing anything, and it actually requires a core mod as well)
As an example, here is how to get (as an Item) a Buildcraft gold power pipe.
Code:
Class.forName("buildcraft.BuildCraftTransport").getField("pipePowerGold").get(null)
Coremods (asm code)
The code above is compiled down to bytecode. Here is the result (well, turned into a readable format - it's usually unreadable)
Code:
L0
LINENUMBER 54 L0
NEW net/minecraft/item/ItemStack
DUP
LDC "buildcraft.BuildCraftTransport"
INVOKESTATIC java/lang/Class.forName (Ljava/lang/String;)Ljava/lang/Class;
LDC "pipePowerGold"
INVOKEVIRTUAL java/lang/Class.getField (Ljava/lang/String;)Ljava/lang/reflect/Field;
ACONST_NULL
INVOKEVIRTUAL java/lang/reflect/Field.get (Ljava/lang/Object;)Ljava/lang/Object;
CHECKCAST net/minecraft/item/Item
ICONST_1
ICONST_0
INVOKESPECIAL net/minecraft/item/ItemStack.<init> (Lnet/minecraft/item/Item;II)V
ASTORE 1
An example of modifying this code is
here. This code turns
Code:
Block.blocksList[l].harvestBlock(this.theWorld, this.thisPlayerMP, par1, par2, par3, i1);
into
Code:
boolean x = Block.blocksList[l].harvestBlock(this.theWorld, this.thisPlayerMP, par1, par2, par3, i1);
Veinminer.instance.blockMined(this.theWorld, this.thisPlayerMP, par1, par2, par3, x, i1);
Yes, it is difficult.
As for Greg doing ASM, he doesn't do any (as far as the version in TPPI, anyway). He does all his changes by being last (if you can be last to edit recipes, for example, you can just change the recipes without having to worry about other mods changing them.