package eggdropsoap.spreadinglilypads;

import java.lang.reflect.*;

import net.minecraft.block.Block;
import net.minecraft.block.BlockLilyPad;
import net.minecraft.creativetab.CreativeTabs;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler; // used in 1.6.2
//import cpw.mods.fml.common.Mod.PreInit;    // used in 1.5.2
//import cpw.mods.fml.common.Mod.Init;       // used in 1.5.2
//import cpw.mods.fml.common.Mod.PostInit;   // used in 1.5.2
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.LanguageRegistry;

@Mod(modid="SpreadingLilypads", name="Spreading Lilypads", version="0.1.0")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class SpreadingLilypads {

	public Block spreadingLilyPad = (new BlockSpreadingLilyPad(500))
			.setHardness(0.0F).setStepSound(Block.soundGrassFootstep)
			.setUnlocalizedName("waterlily")
			.func_111022_d("waterlily")
			.setCreativeTab(CreativeTabs.tabDecorations);
	
    // The instance of your mod that Forge uses.
    @Instance("SpreadingLilypads")
    public static SpreadingLilypads instance;
   
    // Says where the client and server 'proxy' code is loaded.
    @SidedProxy(clientSide="eggdropsoap.spreadinglilypads.client.ClientProxy", serverSide="eggdropsoap.spreadinglilypads.CommonProxy")
    public static CommonProxy proxy;
   
    
    @EventHandler // used in 1.6.2
    //@PreInit    // used in 1.5.2
    public void preInit(FMLPreInitializationEvent event) {
            // Stub Method
    }
   
    @EventHandler // used in 1.6.2
    //@Init       // used in 1.5.2
    public void load(FMLInitializationEvent event) {
            proxy.registerRenderers();
          
            LanguageRegistry.addName(spreadingLilyPad, "Spreading Lily Pad");
            
//            Block.blocksList[Block.waterlily.blockID] = null;
//            spreadingLilyPad = (new BlockSpreadingLilyPad(5001)).setHardness(0.0F).setStepSound(Block.soundGrassFootstep).setUnlocalizedName("waterlily").func_111022_d("waterlily");
            Block.blocksList[Block.waterlily.blockID] = spreadingLilyPad;
            
/*            try
            {
            	Class<?> block = Block.class;
            	Field oldLilyPad = block.getDeclaredField("waterlily");		// field_71991_bz in 1.6.2
            	Field blocksList = block.getDeclaredField("blocksList");	// field_71973_m in 1.6.2

//            	blocksList.setAccessible(true);
            	
//            	try {
					Utils.unfinalise(blocksList);
//				} catch (Exception e) {
					// TODO Auto-generated catch block
//					e.printStackTrace();
//				}

//            	Object ob = blocksList.get(null);
            	
//            	System.out.println("Reflected access: " + value.getUnlocalizedName());
            	
//            	try {
//					Utils.unfinalise(oldLilyPad);
//				} catch (Exception e) {
//					// TODO Auto-generated catch block
//					e.printStackTrace();
//				}
            	
            } catch (NoSuchFieldException e) {
            	// TODO Auto-generated catch block
            	e.printStackTrace();
            } catch (SecurityException e) {
            	// TODO Auto-generated catch block
            	e.printStackTrace();
            }*/

    }
   
    @EventHandler // used in 1.6.2
    //@PostInit   // used in 1.5.2
    public void postInit(FMLPostInitializationEvent event) {
            // Stub Method
    }
}

@@ -1062,16 +1062,45 @@
 ad(500))
+ // FIXME: config for temp ID
 %0A%09%09%09.set
@@ -1984,25 +1984,24 @@
 ;%0A          
-%0A
             
@@ -2004,1528 +2004,95 @@
     
-LanguageRegistry.addName(spreadingLilyPad, %22Spreading Lily Pad%22);%0A            %0A//            Block.blocksList%5BBlock.waterlily.blockID%5D = null;%0A//            spreadingLilyPad = (new BlockSpreadingLilyPad(5001)).setHardness(0.0F).setStepSound(Block.soundGrassFootstep).setUnlocalizedName(%22waterlily%22).func_111022_d(%22waterlily%22);%0A            Block.blocksList%5BBlock.waterlily.blockID%5D = spreadingLilyPad;%0A            %0A/*            try%0A            %7B%0A            %09Class%3C?%3E block = Block.class;%0A            %09Field oldLilyPad = block.getDeclaredField(%22waterlily%22);%09%09// field_71991_bz in 1.6.2%0A            %09Field blocksList = block.getDeclaredField(%22blocksList%22);%09// field_71973_m in 1.6.2%0A%0A//            %09blocksList.setAccessible(true);%0A            %09%0A//            %09try %7B%0A%09%09%09%09%09Utils.unfinalise(blocksList);%0A//%09%09%09%09%7D catch (Exception e) %7B%0A%09%09%09%09%09// TODO Auto-generated catch block%0A//%09%09%09%09%09e.printStackTrace();%0A//%09%09%09%09%7D%0A%0A//            %09Object ob = blocksList.get(null);%0A            %09%0A//            %09System.out.println(%22Reflected access: %22 + value.getUnlocalizedName());%0A            %09%0A//            %09try %7B%0A//%09%09%09%09%09Utils.unfinalise(oldLilyPad);%0A//%09%09%09%09%7D catch (Exception e) %7B%0A//%09%09%09%09%09// TODO Auto-generated catch block%0A//%09%09%09%09%09e.printStackTrace();%0A//%09%09%09%09%7D%0A            %09%0A            %7D catch (NoSuchFieldException e) %7B%0A            %09// TODO Auto-generated catch block%0A            %09e.printStackTrace();%0A            %7D catch (SecurityException e) %7B%0A            %09// TODO Auto-generated catch block%0A            %09e.printStackTrace();%0A            %7D*/
+%0A            Block.blocksList%5BBlock.waterlily.blockID%5D = spreadingLilyPad;%0A            
 %0A%0A  

Remove testing name change and non-functional reflection code.