Jump to content

mod organization question 1.6.4 & 1.7.10


Glistre

Recommended Posts

I am confused about the preinitialization, initialization , and post initialization and how to organize the mod best, I think I am probably missing the big picture:

 

1)why would it be that my custom egg and other classes only work if declared BEFORE preinitialization?  I have seen other people have that after preinit but before init and their mods work fine;

 

2) what is the best way to organize mod ? 3)do recipes always go in the init section?

 

In 1.7.10 I have my world which only works in post init, and my creative tab only works in post init...versus 1.6.4 totally different

Here is my 1.6.4

 package mymod;

import java.awt.Color;

import mymod.armor.MyArmor;
import mymod.biome.MyBiome;
import mymod.blocks.MyBlock;
import mymod.blocks.MyBlockGen;
import mymod.entity.tobo.MyEntityTobo;
import mymod.entity.tobo.MyModelTobo;
import mymod.entity.tobo.MyRenderTobo;
import mymod.entity.wolf.MyEntityWolf;
import mymod.entity.wolf.MyModelWolf;
import mymod.entity.wolf.MyRenderWolf;
import mymod.handlers.MyCraftingHandler;
import mymod.handlers.MyPickupHandler;
import mymod.items.GlistreDust;
import mymod.items.GlistreIngot;
import mymod.items.CustomSpawner;
import mymod.items.GlistreSword;
import mymod.items.MyFood;
import mymod.items.MyItem;
import mymod.items.MyPickaxe;
import mymod.items.MySword;
import mymod.proxies.CommonProxy;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityEggInfo;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.src.ModLoader;
import net.minecraft.stats.Achievement;
import net.minecraft.stats.AchievementList;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.EnumHelper;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
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.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;


/* 	MOD INFO */
@Mod( modid = "mymod", name = "Glistre Mod", version = "1.0")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)	


public class Main {

/*	PROXY INFO */
@SidedProxy(clientSide = "mymod.proxies.ClientProxy", serverSide = "mymod.proxies.CommonProxy")
public static CommonProxy proxy;


/**	
* DECLARATION SECTION 
* *********************************************************** */
/**Declares The Block/Item */
//  DECLARE THE SWORD 
        public static Item MySword_1;
        
//  DECLARE THE SWORD 
        public static Item Glistre_Sword;
    
//  DECLARE THE PICKAXE 
        public static Item MyPickaxe_1;

//  DECLARE THE PICKAXE 
        public static Item Glistre_Pickaxe;

//  DECLARE NEW TOOL MATERIAL
        public static EnumToolMaterial MyToolMaterial = EnumHelper.addToolMaterial("Silver", 1, 2000, 16.0F, 24.0F, 10);
        
//  DECLARE NEW TOOL MATERIAL
        public static EnumToolMaterial MyToolMaterial_2 = EnumHelper.addToolMaterial("Glistre_Ingot", 2, 2000, 20.0F, 36.0F, 16);

//  DECLARE THE ITEM
        public static Item MyItem_1;

//  DECLARE THE ITEM
        public static Item Glistre_Dust;

//  DECLARE THE ITEM
        public static Item Glistre_Ingot;

//  DECLARE GLISTERING BREAD
        public static Item MyFood_1;
        
//  DECLARE GLISTERING PIE
        public static Item MyFood_2;

//  DECLARE THE BLOCK
        public static Block MyBlock_1;

//  DECLARE THE ARMOR
        public static Item MyHelmet_1;
        public static Item MyChest_1;
        public static Item MyLeggings_1;
        public static Item MyBoots_1;

//  DECLARE THE ARMOR MATERIAL
        														/** maxDamageFactor, damageReductionAmountArray, enchantability*/
        public static EnumArmorMaterial MyArmorMaterial_1 = EnumHelper.addArmorMaterial("Glistre", 28, new int[]{3, 7, 6, 4}, 50);

//  DECLARE THE BIOME
        public static  BiomeGenBase MyBiome_1;

// CUSTOM SPAWNER

        public static Item CustomSpawner;

//  DECLARE THE MOB ID
        static int MyEntityID = 300;
    
    //  SEARCH FOR UNIQUE ID    
        public static int getUniqueEntityId() {
            do {
                MyEntityID++;
            }
            while (EntityList.getStringFromID(MyEntityID) != null);
            return MyEntityID++;
        }

   
    //  DECLARE A NEW EGG OLD WAY using global ID's cannot put spawn egg in Creative Tab
/*       public static void registerEntityEgg(Class <? extends Entity> entity, int primaryColor, int secondaryColor) {
            int id = getUniqueEntityId();
            EntityList.IDtoClassMapping.put(id, entity);
            EntityList.entityEggs.put(id, new EntityEggInfo(id, primaryColor, secondaryColor));
        }*/

//	DECLARE THE NEW ACHIEVEMENTS	
    	public static Achievement MyAchievement_1;
    	public static Achievement MyAchievement_2;    	
    	public static Achievement MyAchievement_3;
    	public static Achievement MyAchievement_4;
    	public static Achievement MyAchievement_5;
    	public static Achievement MyAchievement_6;
    	public static Achievement MyAchievement_7;
//    	public static Achievement MyAchievement_8;
    	public static Achievement MyAchievement_9;
    	public static Achievement MyAchievement_10;
    	public static Achievement MyAchievement_11;
    	public static Achievement MyAchievement_12;
    	public static Achievement MyAchievement_13;
    	public static Achievement MyAchievement_14;

//  DECLARE A NEW CREATIVE TAB  
        public static CreativeTabs MyCreativeTab_1;

/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */	


@EventHandler	
public  void preInit( FMLPreInitializationEvent event ) 
{
/** 
* LOAD SECTION 
* *********************************************************** */ 
/**Loads The Item/Block*/
//  LOAD THE CREATIVE TAB
        MyCreativeTab_1 = new CreativeTabs("MyCreativeTab_1") {
            public ItemStack getIconItemStack() {
                return new ItemStack(Glistre_Sword, 1, 0);   // Icon, Stack Size, Tab Position
            }
        };

//  LOAD THE SILVER_SWORD
        MySword_1 = new MySword(2021, MyToolMaterial, "MySword_1").setCreativeTab(Main.MyCreativeTab_1);
        GameRegistry.registerItem(MySword_1, "MySword_1");
        LanguageRegistry.addName(MySword_1, "Silver Sword");

//  LOAD THE SWORD_OF_GLISTRE
        Glistre_Sword = new GlistreSword(2024, MyToolMaterial_2, "Glistre_Sword").setCreativeTab(MyCreativeTab_1);
        GameRegistry.registerItem(Glistre_Sword, "Glistre_Sword");
        LanguageRegistry.addName(Glistre_Sword, "Sword of Glistre"); 
       
//  LOAD THE PICKAXE
        MyPickaxe_1 = new MyPickaxe(2022, MyToolMaterial, "MyPickaxe_1").setCreativeTab(MyCreativeTab_1);
        GameRegistry.registerItem(MyPickaxe_1, "MyPickaxe_1");
        LanguageRegistry.addName(MyPickaxe_1, "Silver Pickaxe");

//  LOAD THE SILVER_INGOT
        MyItem_1 = new MyItem(2030, "MyItem_1").setCreativeTab(MyCreativeTab_1);
        LanguageRegistry.addName(MyItem_1, "Silver Ingot");

//  LOAD THE GLISTRING_DUST
        Glistre_Dust = new GlistreDust(2032, "Glistre_Dust").setCreativeTab(MyCreativeTab_1).setMaxStackSize(64);
        GameRegistry.registerItem(Glistre_Dust, "Glistre_Dust");
        LanguageRegistry.addName(Glistre_Dust, "Glistre_Dust");

//  LOAD THE ITEM
        Glistre_Ingot = new GlistreIngot(2034, "Glistre_Ingot").setCreativeTab(MyCreativeTab_1).setMaxStackSize(64);
        GameRegistry.registerItem(Glistre_Ingot, "Glistre_Ingot");
        LanguageRegistry.addName(Glistre_Ingot, "Glistre_Ingot");

//  LOAD GLISTERING BREAD
        /** itemID, healAmount, saturationModifier (F), isWolfsFavoriteMeat, Texture Name */
        MyFood_1 = new MyFood(2040, 6, 5.0F, true, "MyFood_1").setAlwaysEdible().setCreativeTab(MyCreativeTab_1);
        GameRegistry.registerItem(MyFood_1, "MyFood_1");
        LanguageRegistry.addName(MyFood_1, "Glistering Bread");

//  LOAD GLISTERING PIE
        /** itemID, healAmount, saturationModifier (F), isWolfsFavoriteMeat, Texture Name */
        MyFood_2 = new MyFood(2041, 8, 5.5F, true, "MyFood_2").setAlwaysEdible().setCreativeTab(MyCreativeTab_1);
        GameRegistry.registerItem(MyFood_2, "MyFood_2");
        LanguageRegistry.addName(MyFood_2, "Glistre Pie");

//  LOAD THE BLOCK 
        MyBlock_1 = new MyBlock(250, Material.rock, "MyBlock_1").setLightValue(1.0F).setResistance(5.0F).setHardness(3.5F)
        .setStepSound(Block.soundStoneFootstep).setCreativeTab(MyCreativeTab_1);
        GameRegistry.registerBlock(MyBlock_1, "MyBlock_1");
        LanguageRegistry.addName(MyBlock_1, "Silver Ore"); 
	MinecraftForge.setBlockHarvestLevel(MyBlock_1, "pickaxe", 1);

//  LOAD HELMET 
        MyHelmet_1 = new MyArmor(2060, EnumArmorMaterial.IRON, 0, 0, "myarmor").setCreativeTab(MyCreativeTab_1);
        GameRegistry.registerItem(MyHelmet_1, "MyHelmet_1");
        LanguageRegistry.addName(MyHelmet_1, "Helmet of Glistre");      
    
//  LOAD CHESTPLATE
        MyChest_1 = new MyArmor(2061, EnumArmorMaterial.IRON, 0, 1, "myarmor").setCreativeTab(MyCreativeTab_1);
        GameRegistry.registerItem(MyChest_1, "MyChest_1");
        LanguageRegistry.addName(MyChest_1, "Chestplate of Glistre");

//  LOAD LEGGINGS    
        MyLeggings_1 = new MyArmor(2062, EnumArmorMaterial.IRON, 0, 2, "myarmor").setCreativeTab(MyCreativeTab_1);
        GameRegistry.registerItem(MyLeggings_1, "MyLeggings_1");
        LanguageRegistry.addName(MyLeggings_1, "Leggings of Glistre");

//  LOAD BOOTS   
        MyBoots_1 = new MyArmor(2063, EnumArmorMaterial.IRON, 0, 3, "myarmor").setCreativeTab(MyCreativeTab_1);
        GameRegistry.registerItem(MyBoots_1, "MyBoots_1");
        LanguageRegistry.addName(MyBoots_1, "Boots of Glistre");

//  LOAD BIOME
        MyBiome_1 = new MyBiome(30);
        GameRegistry.addBiome(MyBiome_1);
        
//  REMOVE OTHER BIOMES
        GameRegistry.removeBiome(BiomeGenBase.beach);
        GameRegistry.removeBiome(BiomeGenBase.desert);
        GameRegistry.removeBiome(BiomeGenBase.desertHills);
        GameRegistry.removeBiome(BiomeGenBase.desertHills);
        GameRegistry.removeBiome(BiomeGenBase.extremeHills);
        GameRegistry.removeBiome(BiomeGenBase.extremeHillsEdge);
        GameRegistry.removeBiome(BiomeGenBase.forest);
        GameRegistry.removeBiome(BiomeGenBase.forestHills);
        GameRegistry.removeBiome(BiomeGenBase.frozenOcean);
        GameRegistry.removeBiome(BiomeGenBase.frozenRiver);
        GameRegistry.removeBiome(BiomeGenBase.iceMountains);
        GameRegistry.removeBiome(BiomeGenBase.icePlains);
        //GameRegistry.removeBiome(BiomeGenBase.jungle);
        //GameRegistry.removeBiome(BiomeGenBase.jungleHills);
        GameRegistry.removeBiome(BiomeGenBase.mushroomIsland);
        GameRegistry.removeBiome(BiomeGenBase.ocean);
        GameRegistry.removeBiome(BiomeGenBase.plains);
        GameRegistry.removeBiome(BiomeGenBase.river);
        GameRegistry.removeBiome(BiomeGenBase.swampland);
        GameRegistry.removeBiome(BiomeGenBase.taiga);
        //GameRegistry.removeBiome(BiomeGenBase.taigaHills);

//  REGISTER MOB - ENTITY GLISTRE WOLF
          EntityRegistry.registerGlobalEntityID(MyEntityWolf.class, "GlistreWolf", EntityRegistry.findGlobalUniqueEntityId());
          EntityRegistry.addSpawn(MyEntityWolf.class, 30, 3, 10, EnumCreatureType.monster, BiomeGenBase.jungle);
          EntityRegistry.addSpawn(MyEntityWolf.class, 30, 3, 5, EnumCreatureType.monster, BiomeGenBase.jungleHills);		
          EntityRegistry.addSpawn(MyEntityWolf.class, 30, 3, 10, EnumCreatureType.monster, BiomeGenBase.taiga);
          EntityRegistry.addSpawn(MyEntityWolf.class, 30, 3, 5, EnumCreatureType.monster, BiomeGenBase.taigaHills);
          EntityRegistry.addSpawn(MyEntityWolf.class, 30, 3, 10, EnumCreatureType.monster, MyBiome_1);     
//          registerEntityEgg(MyEntityWolf.class, (new Color(255, 255, 255)).getRGB(), (new Color(255, 255, 75)).getRGB());
          RenderingRegistry.registerEntityRenderingHandler(MyEntityWolf.class, new MyRenderWolf(new MyModelWolf(), 0.3F));
          ModLoader.addLocalization("entity.GlistreWolf.name", "Glistre Wolf");
        
//  REGISTER MOB - ENTITY TOBIE
        EntityRegistry.registerGlobalEntityID(MyEntityTobo.class, "Tobie", EntityRegistry.findGlobalUniqueEntityId());
        EntityRegistry.addSpawn(MyEntityTobo.class, 15, 1, 3, EnumCreatureType.monster, BiomeGenBase.taiga);
        EntityRegistry.addSpawn(MyEntityTobo.class, 15, 1, 2, EnumCreatureType.monster, BiomeGenBase.taigaHills);  
        EntityRegistry.addSpawn(MyEntityTobo.class, 15, 3, 7, EnumCreatureType.monster, MyBiome_1);  
//        registerEntityEgg(MyEntityTobo.class, (new Color(210, 210, 210)).getRGB(), (new Color(17, 180, 246)).getRGB());
        RenderingRegistry.registerEntityRenderingHandler(MyEntityTobo.class, new MyRenderTobo(new MyModelTobo(), 0.3F));
        ModLoader.addLocalization("entity.Tobie.name", "Tobie");

//	LOAD THE ACHIEVEMENTS
	MyAchievement_1 = new Achievement(2001, "MyAchievement_1", -3, -1, MyBlock_1, AchievementList.openInventory).registerAchievement();
	MyAchievement_2 = new Achievement(2002, "MyAchievement_2", -6, -1, MyItem_1, MyAchievement_1).registerAchievement();
	MyAchievement_3 = new Achievement(2003, "MyAchievement_3", -7, -3, Glistre_Dust, MyAchievement_2).registerAchievement();
	MyAchievement_4 = new Achievement(2004, "MyAchievement_4", -9, -3, Glistre_Ingot, MyAchievement_3).registerAchievement();
	MyAchievement_5 = new Achievement(2005, "MyAchievement_5", -11, -3, Glistre_Sword, MyAchievement_4).registerAchievement();
	MyAchievement_6 = new Achievement(2006, "MyAchievement_6", -8, -1, MySword_1, MyAchievement_2).registerAchievement();
	MyAchievement_7 = new Achievement(2007, "MyAchievement_7", -6, 1, MyPickaxe_1, MyAchievement_2).registerAchievement();
//		MyAchievement_8 = new Achievement(2008, "MyAchievement_8", -9, -5, Glistre_Pickaxe, MyAchievement_4).registerAchievement();
	MyAchievement_9 = new Achievement(2009, "MyAchievement_9", -5, -5, MyFood_1, MyAchievement_3).registerAchievement();
	MyAchievement_10 = new Achievement(2010, "MyAchievement_10", -4, -3, MyFood_2, MyAchievement_3).registerAchievement();
	MyAchievement_11 = new Achievement(2011, "MyAchievement_11", -9, -5, MyHelmet_1, MyAchievement_4).registerAchievement();
	MyAchievement_12 = new Achievement(2012, "MyAchievement_12", -9, -6, MyChest_1, MyAchievement_4).registerAchievement();
	MyAchievement_13 = new Achievement(2013, "MyAchievement_13", -9, -7, MyLeggings_1, MyAchievement_4).registerAchievement();
	MyAchievement_14 = new Achievement(2014, "MyAchievement_14", -9, -8, MyBoots_1, MyAchievement_4).registerAchievement();

	//	(id, "NameOfAchievement", x, y coordinates on Achievement map, icon, Required Achievement to unlock)
	// 	For no Pre-required achievement, use "(Achievement)null"



/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */	

}

@EventHandler
public static void init( FMLInitializationEvent event ) 
{

/**	
* RECIPES SECTION 
* *********************************************************** */
/**Adds A Recipe For The Item/Block */
//  SWORD RECIPE  
        GameRegistry.addRecipe(new ItemStack(MySword_1, 1), new Object[]
        {
                " X ",
                " X ",
                " S ",
            'S', Item.stick,
            'X', MyItem_1,
        });
        
//  SWORD RECIPE  
        GameRegistry.addRecipe(new ItemStack(Glistre_Sword, 1), new Object[]
        {
                " X ",
                " X ",
                " S ",
            'S', Item.stick,
            'X', Glistre_Ingot,
        });

//  PICKAXE RECIPE  
        GameRegistry.addRecipe(new ItemStack(MyPickaxe_1, 1), new Object[]
        {
                "XXX",
                " X ",
                " S ",            
            'S', Item.stick,
            'X', MyItem_1,
        });

// GLISTRE DUST RECIPE
        ItemStack GlistreDust = new ItemStack(Main.Glistre_Dust);
        ItemStack SilverIngot = new ItemStack(Main.MyItem_1);
        ItemStack GoldIngot = new ItemStack(Item.ingotGold);
        
        GameRegistry.addShapelessRecipe(GlistreDust, MyItem_1, GoldIngot);
        
// SMELTING GLISTRE ORE RECIPE
        ItemStack GlistreIngot = new ItemStack(Main.Glistre_Ingot);

       GameRegistry.addSmelting(Main.Glistre_Dust.itemID, GlistreIngot, 12.0F);        

//  SMELTING RECIPE
        GameRegistry.addSmelting(MyBlock_1.blockID, (new ItemStack(MyItem_1, 1)), 12);

//  GLISTERING BREAD RECIPE         
        GameRegistry.addRecipe(new ItemStack(MyFood_1, 1), new Object[]
        {
                "   ",
                " X ",
                " S ",
            'S', Item.bread,
            'X', Main.Glistre_Dust,
        });

//  GLISTERING PIE RECIPE         
        GameRegistry.addRecipe(new ItemStack(MyFood_2, 1), new Object[]
        {
                " S ",
                " Z ",
                "   ",
            'Z', Item.sugar,
            'S', Main.MyFood_1,
        });
       
//  HELMET RECIPE   
    GameRegistry.addRecipe(new ItemStack(MyHelmet_1, 1), new Object[]
    {
            "XXX",
            "X X",
        'X', MyItem_1,
    });         

//  CHESTPLATE RECIPE   
    GameRegistry.addRecipe(new ItemStack(MyChest_1, 1), new Object[]
    {
            "X X",
            "XXX",
            "XXX",
        'X', MyItem_1,
    });         

//  LEGGINGS RECIPE 
    GameRegistry.addRecipe(new ItemStack(MyLeggings_1, 1), new Object[]
    {
            "XXX",
            "X X",
            "X X",
        'X', MyItem_1,
    });         

//  BOOTS RECIPE    
    GameRegistry.addRecipe(new ItemStack(MyBoots_1, 1), new Object[]
    {
            "X X",
            "X X",
        'X', MyItem_1,
    });


/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */	


/**	
* EXTRA METHODS SECTION 
* *********************************************************** */

//  REGISTER THE ORE GENERATION 
    GameRegistry.registerWorldGenerator(new MyBlockGen());

//	CHANGE THE TEXT OF THE ACHIEVEMENTS	
    	LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_1", "en_US", "Silver Ore");
    	LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_1.desc", "en_US", "Mine Silver Ore");
    	LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_2", "en_US", "Silver Ingot");
    	LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_2.desc", "en_US", "Smelt Silver Ore");
    	LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_3", "en_US", "Glistre Dust");
    	LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_3.desc", "en_US", "Craft Glistre Dust");
    	LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_4", "en_US", "Glistre Ingot");
    	LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_4.desc", "en_US", "Smelt Glistre Ingot");
    	LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_5", "en_US", "Glistre Sword");
    	LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_5.desc", "en_US", "Craft Sword of Glistre");
    	LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_6", "en_US", "Silver Sword");
    	LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_.desc", "en_US", "Craft Silver Sword");
    	LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_7", "en_US", "Silver Pickaxe");
    	LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_.desc", "en_US", "Craft Silver Pickaxe");
//    	LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_8", "en_US", "Glistering Pickaxe");
//   	LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_.desc", "en_US", "Craft Glistering Pickaxe");
    	LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_9", "en_US", "Tasty Glistering Bread");
    	LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_.desc", "en_US", "Craft Tasty Glistering Bread");
    	LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_10", "en_US", "Yummy Glistre Pie");
    	LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_.desc", "en_US", "Craft Yummy Glistre Pie");
    	LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_11", "en_US", "Helmet of Glistre");
    	LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_.desc", "en_US", "Craft Helmet of Glistre");
    	LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_12", "en_US", "Chestplate of Glistre");
    	LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_.desc", "en_US", "Craft Chestplate of Glistre");
    	LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_13", "en_US", "Leggings of Glistre");
    	LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_.desc", "en_US", "Craft Leggings of Glistree");
    	LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_14", "en_US", "Boots of Glistre");
    	LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_.desc", "en_US", "Craft Boots of Glistre");

//  REGISTER PICKUP HANDLER
        MyPickupHandler MyPickupHandler_1 = new MyPickupHandler();
        GameRegistry.registerPickupHandler(MyPickupHandler_1);  

//  REGISTER CRAFTING HANDLER
        MyCraftingHandler MyCraftingHandler_1 = new MyCraftingHandler();
        GameRegistry.registerCraftingHandler(MyCraftingHandler_1);  

//  CHANGE TAB NAME
        LanguageRegistry.instance().addStringLocalization("itemGroup.MyCreativeTab_1", "en_US", "Glistre Stuffs");   

//	SETTINGS FOR CUSTOM SPAWNER
	CustomSpawner = new CustomSpawner (1016).setUnlocalizedName ("CustomSpawner").setTextureName("mymod:spawn_egg").setCreativeTab(MyCreativeTab_1);
	LanguageRegistry.addName(CustomSpawner, "Spawn" + "");
/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */	


}

@EventHandler
public static void postInit( FMLPostInitializationEvent event ) 
{

}

}

 

 

My 1.7.10 same mod:

 

package com.glistre.glistremod;

import java.awt.Color;

import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.entity.projectile.EntityEgg;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
import net.minecraft.world.WorldType;

import com.glistre.glistremod.WorldTypeGlistre;

import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.BiomeDictionary.Type;
import net.minecraftforge.common.BiomeManager;
import net.minecraftforge.common.BiomeManager.BiomeEntry;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.EnumHelper;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
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.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;

import com.glistre.glistremod.BiomeRegistry;
import com.glistre.glistremod.GlistreArmor;
import com.glistre.glistremod.GlistreDust;
import com.glistre.glistremod.GlistreIngot;
import com.glistre.glistremod.GlistreSword;
import com.glistre.glistremod.CommonProxy;
import com.glistre.glistremod.ClientProxy;
import com.glistre.glistremod.MyItem;
import com.glistre.glistremod.MyPickaxe;
import com.glistre.glistremod.MySword;
import com.glistre.glistremod.MyFood;
import com.glistre.glistremod.MyBlock;
//import com.glistre.glistremod.MyArmor;
import com.glistre.glistremod.GlistreBiome;
//import com.glistre.glistremod.MyBlockGen;
import com.glistre.glistremod.EntityGlistreWolf;
//import com.glistre.glistremod.MyEntityTobo;


/* 	MOD INFO */
@Mod(modid = GlistreMod.MODID, name = "Glistre Mod", version = "2.0")

public class GlistreMod {

public static final String MODID = "GlistreMod";
public static final String NAME = "Glistre Mod";
public static final String VERSION = "2.0";

@Instance("GlistreMod")
public static GlistreMod instance;

/*	PROXY INFO */
@SidedProxy(clientSide = ("com.glistre.glistremod.ClientProxy"), serverSide = ("com.glistre.glistremod.CommonProxy"))
public static CommonProxy proxy;

GlistreEventHandler handler = new GlistreEventHandler();


/**	
* DECLARATION SECTION 
* *********************************************************** */
public static ItemArmor GlistreArmor;

// DECLARE THE ARMOR
public static Item MyHelmet_1;
public static Item MyChestplate_1;
public static Item MyLeggings_1;
public static Item MyBoots_1;

//ARMOR ID's
public static int MyHelmet_1ID;
public static int MyChestplate_1ID;
public static int MyLeggings_1ID;
public static int MyBoots_1ID;


// DECLARE THE ARMOR MATERIAL
public static ArmorMaterial Glistre=
/** maxDamageFactor, damageReductionAmountArray, enchantability*/		
		EnumHelper.addArmorMaterial("Glistre", 28, new int[]{3, 7, 6, 4}, 50);
//GlistreArmor= EnumHelper.addArmorMaterial("GlistreArmor", 28, new int[]{3, 7, 6, 4}, 50);

//  DECLARE THE SWORD 
        public static Item MySword_1;
        
//  DECLARE THE SWORD 
        public static Item Glistre_Sword;
    
//  DECLARE THE PICKAXE 
        public static Item MyPickaxe_1;

//  DECLARE THE PICKAXE 
        public static Item Glistre_Pickaxe;
        
//  DECLARE THE ITEM
        public static Item MyItem_1;

//  DECLARE THE ITEM
        public static Item Glistre_Dust;

//  DECLARE THE ITEM
        public static Item Glistre_Ingot;

//  DECLARE GLISTERING BREAD
        public static Item MyFood_1;
        
//  DECLARE GLISTERING PIE
        public static Item MyFood_2;

//  DECLARE THE BLOCK
        public static Block MyBlock_1;

//  DECLARE THE BIOME
      
//  DECLARE THE MOB ID

   

//  DECLARE THE MOB SPAWN EGG



//	DECLARE THE NEW ACHIEVEMENTS	
        public static Achievement MyAchievement_1;
        public static Achievement MyAchievement_2;    	
        public static Achievement MyAchievement_3;

        public int modEntityID = 0;


/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */	


        
@EventHandler	
public void preInit( FMLPreInitializationEvent event ){

FMLCommonHandler.instance().bus().register(handler);
MinecraftForge.EVENT_BUS.register(handler);

proxy.registerRendering();


/**	
* LOAD SECTION 
* *********************************************************** */ 
//LOAD THE CREATIVE TAB


//LOAD THE ARMOR

	MyHelmet_1 = new GlistreArmor(Glistre, MyHelmet_1ID, 0).setUnlocalizedName("MyHelmet_1").setCreativeTab(GlistreTab_1).setTextureName(MODID + ":" + "MyHelmet_1");
	//MyArmor(2060, EnumArmorMaterial.IRON, 0, 0, "myarmor");
	GameRegistry.registerItem(MyHelmet_1, "MyHelmet_1");

	MyChestplate_1 = new GlistreArmor(Glistre, MyChestplate_1ID, 1).setUnlocalizedName("MyChestplate_1").setCreativeTab(GlistreTab_1).setTextureName(MODID + ":" + "MyChestplate_1");
	GameRegistry.registerItem(MyChestplate_1, "MyChestplate_1");

	MyLeggings_1 = new GlistreArmor(Glistre, MyLeggings_1ID, 2).setUnlocalizedName("MyLeggings_1").setCreativeTab(GlistreTab_1).setTextureName(MODID + ":" + "MyLeggings_1");
	GameRegistry.registerItem(MyLeggings_1, "MyLeggings_1");

	MyBoots_1 = new GlistreArmor(Glistre, MyBoots_1ID, 3).setUnlocalizedName("MyBoots_1").setCreativeTab(GlistreTab_1).setTextureName(MODID + ":" + "MyBoots_1");
	GameRegistry.registerItem(MyBoots_1, "MyBoots_1");        

//  LOAD THE SWORDS
        MySword_1 = new Item().setUnlocalizedName("MySword_1").setCreativeTab(GlistreTab_1).setTextureName(MODID + ":" + "MySword_1"); 
        	//	MySword(ToolMaterial Item, EnumToolMaterial, "MySword_1");
        GameRegistry.registerItem(MySword_1, MySword_1.getUnlocalizedName());

        Glistre_Sword = new Item().setUnlocalizedName("Glistre_Sword").setCreativeTab(GlistreTab_1).setTextureName(MODID + ":" + "Glistre_Sword");
        GameRegistry.registerItem(Glistre_Sword, Glistre_Sword.getUnlocalizedName());
       
//  LOAD THE PICKAXE
        MyPickaxe_1 = new Item().setUnlocalizedName("MyPickaxe_1").setCreativeTab(GlistreTab_1).setTextureName(MODID + ":" + "MyPickaxe_1");
        GameRegistry.registerItem(MyPickaxe_1, MyPickaxe_1.getUnlocalizedName());

//  LOAD THE ITEMS
        MyItem_1 = new Item().setUnlocalizedName("MyItem_1").setCreativeTab(GlistreTab_1).setMaxStackSize(64).setTextureName(MODID + ":" + "MyItem_1");
        GameRegistry.registerItem(MyItem_1, MyItem_1.getUnlocalizedName());

        Glistre_Dust = new Item().setUnlocalizedName("Glistre_Dust").setCreativeTab(GlistreTab_1).setMaxStackSize(64).setTextureName(GlistreMod.MODID + ":" + "Glistre_Dust");
        GameRegistry.registerItem(Glistre_Dust, Glistre_Dust.getUnlocalizedName());

        Glistre_Ingot = new Item().setUnlocalizedName("Glistre_Ingot").setCreativeTab(GlistreTab_1).setMaxStackSize(64).setTextureName(MODID + ":" + "Glistre_Ingot");
        		//GlistreOre(2034, "Glistre_Ore").setCreativeTab(CreativeTabs.tabMisc).setMaxStackSize(64);
        GameRegistry.registerItem(Glistre_Ingot, Glistre_Ingot.getUnlocalizedName());

//  GLISTERING BREAD
        /** itemID, healAmount, saturationModifier (F), isWolfsFavoriteMeat, Texture Name */
        MyFood_1 = new ItemFood(6,5.0F,true).setUnlocalizedName("MyFood_1").setCreativeTab(GlistreTab_1).setMaxStackSize(64).setTextureName(MODID + ":" + "MyFood_1");
        GameRegistry.registerItem(MyFood_1, MyFood_1.getUnlocalizedName());

//  GLISTERING PIE
        /** itemID, healAmount, saturationModifier (F), isWolfsFavoriteMeat, Texture Name */
        MyFood_2 = new ItemFood(8,5.5F, true).setUnlocalizedName("MyFood_2").setCreativeTab(GlistreTab_1).setMaxStackSize(64).setTextureName(MODID + ":" + "MyFood_2");
        //MyFood(2041, 8, 5.5F, true, "MyFood_2").setAlwaysEdible().setCreativeTab(CreativeTabs.tabFood);
        GameRegistry.registerItem(MyFood_2, MyFood_2.getUnlocalizedName());

//  LOAD THE BLOCK 
        MyBlock_1 = new MyBlock().setBlockName("MyBlock_1").setCreativeTab(GlistreTab_1).setBlockTextureName(MODID + ":" + "MyBlock_1")
        		.setLightLevel(1.0F).setResistance(5.0F).setHardness(3.5F).setStepSound(Block.soundTypeStone);
        GameRegistry.registerBlock(MyBlock_1, MyBlock_1.getUnlocalizedName());
	//MinecraftForge.setBlockHarvestLevel(MyBlock_1, "pickaxe", 1);	

//  LOAD BIOME
        BiomeRegistry.GlisterMod();

//  REGISTER YOUR ENTITY
// old way of registering Entity      EntityRegistry.registerGlobalEntityID(EntityGlistreWolf.class, "Glistre_Wolf", EntityGlistreWolfID);
// new way       int modEntityID = 0;
//       EntityRegistry.registerModEntity(EntityGlistreWolf.class, "Glistre_Wolf", ++modEntityID, <name of your mod's main class>.instance, 80, 3, false);

        EntityRegistry.registerModEntity(EntityGlistreWolf.class, "Glistre Wolf", ++modEntityID, GlistreMod.instance, 80, 3, false);
        EntityRegistry.addSpawn(EntityGlistreWolf.class, 10, 3, 7, EnumCreatureType.creature, BiomeRegistry.biomeGlistre);
	EntityRegistry.addSpawn(EntityGlistreWolf.class, 10, 3, 7, EnumCreatureType.creature, BiomeRegistry.biomeGlistre);
	EntityRegistry.addSpawn(EntityGlistreWolf.class, 2, 3, 7, EnumCreatureType.creature, BiomeGenBase.desert);
	EntityRegistry.addSpawn(EntityGlistreWolf.class, 10, 3, 7, EnumCreatureType.creature, BiomeGenBase.jungle);
	EntityRegistry.addSpawn(EntityGlistreWolf.class, 10, 3, 7, EnumCreatureType.creature, BiomeGenBase.jungleEdge);
	EntityRegistry.addSpawn(EntityGlistreWolf.class, 10, 3, 7, EnumCreatureType.creature, BiomeGenBase.taiga);
	EntityRegistry.addSpawn(EntityGlistreWolf.class, 100, 3, 7, EnumCreatureType.creature, BiomeGenBase.forest);
	EntityRegistry.addSpawn(EntityGlistreWolf.class, 10, 3, 7, EnumCreatureType.creature, BiomeGenBase.roofedForest);
	EntityRegistry.addSpawn(EntityGlistreWolf.class, 100, 3, 7, EnumCreatureType.creature, BiomeGenBase.savanna);
	EntityRegistry.addSpawn(EntityGlistreWolf.class, 10, 3, 7, EnumCreatureType.creature, BiomeGenBase.coldTaiga);
	EntityRegistry.addSpawn(EntityGlistreWolf.class, 20, 3, 7, EnumCreatureType.creature, BiomeGenBase.plains);		
	EntityRegistry.addSpawn(EntityGlistreWolf.class, 10, 3, 7, EnumCreatureType.creature, BiomeGenBase.swampland);		
	EntityRegistry.addSpawn(EntityGlistreWolf.class, 100, 3, 7, EnumCreatureType.creature, BiomeGenBase.birchForest);



// REGISTER GLISTREWOLF SPAWNEGGS

	Item itemSpawnEgg = new GlistreEntityMonsterPlacer("Glistre Wolf", 0xFFFFFF, 0xFFFF5D)
	.setUnlocalizedName ("spawn_egg")
	.setTextureName("glistremod:spawn_egg");
	GameRegistry.registerItem(itemSpawnEgg, "spawn_egg");      
       

//	LOAD THE ACHIEVEMENTS
	//MyAchievement_1 = new Achievement(2001, "MyAchievement_1", -1, -3, MyBlock_1, (Achievement) null).registerAchievement();
	//MyAchievement_2 = new Achievement(2002, "MyAchievement_2", -3, -3, MyItem_1, MyAchievement_1.registerAchievement());
	//MyAchievement_3 = new Achievement(2003, "MyAchievement_3", -5, -3, Glistre_Dust, AchievementList.buildFurnace);
	//	(id, "NameOfAchievement", x, y coordinates on Achievement map, icon, Required Achievement to unlock)
	// 	For no Pre-required achievement, use "(Achievement)null"




}



/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */	


@EventHandler
public static void init(FMLInitializationEvent event ) 
{


/**	
* RECIPES SECTION 
* *********************************************************** */

//  SWORD RECIPE  
        GameRegistry.addRecipe(new ItemStack(MySword_1, 1), new Object[]
        {
                " X ",
                " X ",
                " S ",
            'S', Items.stick,
            'X', MyItem_1,
        });
        
//  SWORD RECIPE  
        GameRegistry.addRecipe(new ItemStack(Glistre_Sword, 1), new Object[]
        {
                " X ",
                " X ",
                " S ",
            'S', Items.stick,
            'X', Glistre_Ingot,
        });

//  PICKAXE RECIPE  
        GameRegistry.addRecipe(new ItemStack(MyPickaxe_1, 1), new Object[]
        {
                "XXX",
                " X ",
                " S ",            
            'S', Items.stick,
            'X', MyItem_1,
        });

// GLISTRE DUST RECIPE
        ItemStack GlistreDust = new ItemStack(GlistreMod.Glistre_Dust);
        ItemStack SilverIngot = new ItemStack(GlistreMod.MyItem_1);
        ItemStack GoldIngot = new ItemStack(Items.gold_ingot);
        
        GameRegistry.addShapelessRecipe(GlistreDust, MyItem_1, GoldIngot);
        
// SMELTING GLISTRE ORE RECIPE
        ItemStack GlistreIngot = new ItemStack(GlistreMod.Glistre_Ingot);

       GameRegistry.addSmelting(GlistreMod.Glistre_Dust, GlistreIngot, 12.0F);        

//  SMELTING RECIPE
        GameRegistry.addSmelting(MyBlock_1, (new ItemStack(MyItem_1, 1)), 12);

//  GLISTERING BREAD RECIPE         
        GameRegistry.addRecipe(new ItemStack(MyFood_1, 1), new Object[]
        {
                "   ",
                " X ",
                " S ",
            'S', Items.bread,
            'X', GlistreMod.Glistre_Dust,
        });

//  GLISTERING PIE RECIPE         
        GameRegistry.addRecipe(new ItemStack(MyFood_2, 1), new Object[]
        {
                " Z ",
                " S ",
                "   ",
            'Z', Items.sugar,
            'S', GlistreMod.MyFood_1,
        });
       



/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */	


/**	
* EXTRA METHODS SECTION 
* *********************************************************** */

//  REGISTER THE ORE GENERATION 
    //GameRegistry.registerWorldGenerator(new MyBlockGen());

//	CHANGE THE TEXT OF THE ACHIEVEMENTS	
    	//LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_1", "en_US", "Silver Ore");
    	//LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_1.desc", "en_US", "Mine Silver Ore");
    	//LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_2", "en_US", "Silver Ingot");
    	//LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_2.desc", "en_US", "Smelt Silver Ore");
    	//LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_3", "en_US", "Glistre Dust");
    	//LanguageRegistry.instance().addStringLocalization("achievement.MyAchievement_3.desc", "en_US", "Craft Glistre Dust");

/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */	


    			
}

@EventHandler
public static void postInit( FMLPostInitializationEvent event ) 
{

WorldType BIOMEGLISTRE = new WorldTypeGlistre(3, "biomeGlistre");

}
//DECLARE CREATIVE TAB
public static CreativeTabs GlistreTab_1 = new CreativeTabs("GlistreTab_1"){

	public Item getTabIconItem(){
		return new ItemStack(Glistre_Sword).getItem();
	}


};


}	

 

Link to comment
Share on other sites

One of the points of preinit, init and postinit is to allow you to order things with respect to other mods.  For example, if people generally register their items and blocks in preinit then you can feel confident that in your init you could register a recipe that included something from their mod.

 

Also, each of the events passes some fields and methods which may be useful.  For example, the FMLPreInitializationEvent has the getSuggestedConfigurationFile() method so it makes sense that you might initialize your Configuration in pre-init using that file path (although you could also presumably save the path for later).  You should check out the methods for each of the events to see things that might be useful.

 

Note also that besides the common preinit, init and postinit there are a couple other "FML Life Cycle" events such as a server starting event (this is good place to register any custom server commands).

 

Here is how I've organized mine, maybe it can give you some ideas: http://jabelarminecraft.blogspot.com/p/minecraft-modding-organizing-your-proxy.html

 

Note that the sphere stuff in my client proxy is an example that if you have methods that you only need on (or that will only compile on) the client side you can put them in the client proxy as well.  In this case my method calls the Minecraft.getMinecraft() which is only valid on client side.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

How I do it, I don't know if it's the best way, but I declare the items and blocks before preinit, initialize them in preinit, register them in init, then add recipes and other stuff in postinit. That way everything is easier to use and easier to look at (I don't like messy code). My new mod however needs to be oragnized a little more, it's really messy.

Link to comment
Share on other sites

How I do it, I don't know if it's the best way, but I declare the items and blocks before preinit, initialize them in preinit, register them in init, then add recipes and other stuff in postinit. That way everything is easier to use and easier to look at (I don't like messy code). My new mod however needs to be oragnized a little more, it's really messy.

 

It is possible to do it in different ways. Some things need to be done in order though -- like you need to register recipes after the items and blocks if the recipes use those items or blocks. Also as I mentioned above, there are certain methods that are unique to each FML life cycle event -- for example only the pre-init gives a recommended config file path and only the server starting event gives a server command registration hook.

 

The way I do it seems to work. See my explanation here: http://jabelarminecraft.blogspot.com/p/minecraft-modding-organizing-your-proxy.html

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.