Jump to content

Recommended Posts

Posted

My custom achievements are not showing on the custom Achievement Page. Here's my code:

 

 

package f1repl4ce.mechsuit;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
import net.minecraft.stats.AchievementList;
import net.minecraftforge.common.AchievementPage;
import net.minecraftforge.common.util.EnumHelper;
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.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import f1repl4ce.mechsuit.armor.*;
import f1repl4ce.mechsuit.events.MSOnCraft;
import f1repl4ce.mechsuit.items.*;

@Mod(modid = "mechsuit", name = "MechSuit", version = "1.0.0")
public class MechSuitBase {
@Instance(value = "mechsuit")
    public static MechSuitBase instance;

public static Achievement achMicrochip;
public static Achievement achT1;
public static Achievement achT2V1;
public static Achievement achT2V2;
public static Achievement achT3;
public static Achievement achT4;
    //Creative Tab Registry
    public static CreativeTabs TabMechSuit = new MechSuitTab(CreativeTabs.getNextID(), "MechSuit");
    //Armor Materials
    public static ArmorMaterial armorT1 = EnumHelper.addArmorMaterial("TIER1", 15, new int[]{3, 4, 5, 4}, 5);
    public static ArmorMaterial armorT2 = EnumHelper.addArmorMaterial("TIER2", 20, new int[]{4, 5, 5, 4}, 10);
    public static ArmorMaterial armorT3 = EnumHelper.addArmorMaterial("TIER3", 25, new int[]{4, 6, 5, 5}, 15);
    public static ArmorMaterial armorT4 = EnumHelper.addArmorMaterial("TIER4", 25, new int[]{5, 6, 6, 5}, 20);
//Armor
    public static Item T1Helmet = new Tier1Suit(armorT1, 4, 0).setUnlocalizedName("T1Helmet").setCreativeTab(TabMechSuit).setTextureName("mechsuit:T1Helmet");
    public static Item T1Chestplate = new Tier1Suit(armorT1, 4, 1).setUnlocalizedName("T1Chestplate").setCreativeTab(TabMechSuit).setTextureName("mechsuit:T1Chestplate");
    public static Item T1Leggings = new Tier1Suit(armorT1, 4, 2).setUnlocalizedName("T1Leggings").setCreativeTab(TabMechSuit).setTextureName("mechsuit:T1Leggings");
    public static Item T1Boots = new Tier1Suit(armorT1, 4, 3).setUnlocalizedName("T1Boots").setCreativeTab(TabMechSuit).setTextureName("mechsuit:T1Boots");
    public static Item T2HelmetV1 = new Tier1Suit(armorT2, 4, 0).setUnlocalizedName("T2HelmetV1").setCreativeTab(TabMechSuit).setTextureName("mechsuit:T2HelmetV1");
    public static Item T2ChestplateV1 = new Tier1Suit(armorT2, 4, 1).setUnlocalizedName("T2ChestplateV1").setCreativeTab(TabMechSuit).setTextureName("mechsuit:T2ChestplateV1");
    public static Item T2LeggingsV1 = new Tier1Suit(armorT2, 4, 2).setUnlocalizedName("T2LeggingsV1").setCreativeTab(TabMechSuit).setTextureName("mechsuit:T2LeggingsV1");
    public static Item T2BootsV1 = new Tier1Suit(armorT2, 4, 3).setUnlocalizedName("T2BootsV1").setCreativeTab(TabMechSuit).setTextureName("mechsuit:T2BootsV1");
    public static Item T2HelmetV2 = new Tier1Suit(armorT2, 4, 0).setUnlocalizedName("T2HelmetV2").setCreativeTab(TabMechSuit).setTextureName("mechsuit:T2HelmetV2");
    public static Item T2ChestplateV2 = new Tier1Suit(armorT2, 4, 1).setUnlocalizedName("T2ChestplateV2").setCreativeTab(TabMechSuit).setTextureName("mechsuit:T2ChestplateV2");
    public static Item T2LeggingsV2 = new Tier1Suit(armorT2, 4, 2).setUnlocalizedName("T2LeggingsV2").setCreativeTab(TabMechSuit).setTextureName("mechsuit:T2LeggingsV2");
    public static Item T2BootsV2 = new Tier1Suit(armorT2, 4, 3).setUnlocalizedName("T2BootsV2").setCreativeTab(TabMechSuit).setTextureName("mechsuit:T2BootsV2");
    public static Item T3Helmet = new Tier3Suit(armorT3, 4, 0).setUnlocalizedName("T3Helmet").setCreativeTab(TabMechSuit).setTextureName("mechsuit:T3Helmet");
    public static Item T3Chestplate = new Tier3Suit(armorT3, 4, 1).setUnlocalizedName("T3Chestplate").setCreativeTab(TabMechSuit).setTextureName("mechsuit:T3Chestplate");
    public static Item T3Leggings = new Tier3Suit(armorT3, 4, 2).setUnlocalizedName("T3Leggings").setCreativeTab(TabMechSuit).setTextureName("mechsuit:T3Leggings");
    public static Item T3Boots = new Tier3Suit(armorT3, 4, 3).setUnlocalizedName("T3Boots").setCreativeTab(TabMechSuit).setTextureName("mechsuit:T3Boots");
    public static Item T4Helmet = new Tier4Suit(armorT4, 4, 0).setUnlocalizedName("T4Helmet").setCreativeTab(TabMechSuit).setTextureName("mechsuit:T4Helmet");
    public static Item T4Chestplate = new Tier4Suit(armorT4, 4, 1).setUnlocalizedName("T4Chestplate").setCreativeTab(TabMechSuit).setTextureName("mechsuit:T4Chestplate");
    public static Item T4Leggings = new Tier4Suit(armorT4, 4, 2).setUnlocalizedName("T4Leggings").setCreativeTab(TabMechSuit).setTextureName("mechsuit:T4Leggings");
    public static Item T4Boots = new Tier4Suit(armorT4, 4, 3).setUnlocalizedName("T4Boots").setCreativeTab(TabMechSuit).setTextureName("mechsuit:T4Boots");
//Items
    public static Item Microchip = new Microchip().setCreativeTab(TabMechSuit).setTextureName("mechsuit:microchip").setUnlocalizedName("MechSuitMicrochip");
    
@EventHandler
    public void preInit(FMLPreInitializationEvent event) {
	//Item Registry
	GameRegistry.registerItem(Microchip, "Microchip");
	GameRegistry.registerItem(T1Helmet, "T1Helmet");
	GameRegistry.registerItem(T1Chestplate, "T1Chestplate");
	GameRegistry.registerItem(T1Leggings, "T1Leggings");
	GameRegistry.registerItem(T1Boots, "T1Boots");
	GameRegistry.registerItem(T2HelmetV1, "T2HelmetV1");
	GameRegistry.registerItem(T2ChestplateV1, "T2ChestplateV1");
	GameRegistry.registerItem(T2LeggingsV1, "T2LeggingsV1");
	GameRegistry.registerItem(T2BootsV1, "T2BootsV1");
	GameRegistry.registerItem(T2HelmetV2, "T2HelmetV2");
	GameRegistry.registerItem(T2ChestplateV2, "T2ChestplateV2");
	GameRegistry.registerItem(T2LeggingsV2, "T2LeggingsV2");
	GameRegistry.registerItem(T2BootsV2, "T2BootsV2");
	GameRegistry.registerItem(T3Helmet, "T3Helmet");
	GameRegistry.registerItem(T3Chestplate, "T3Chestplate");
	GameRegistry.registerItem(T3Leggings, "T3Leggings");
	GameRegistry.registerItem(T3Boots, "T3Boots");
	GameRegistry.registerItem(T4Helmet, "T4Helmet");
	GameRegistry.registerItem(T4Chestplate, "T4Chestplate");
	GameRegistry.registerItem(T4Leggings, "T4Leggings");
	GameRegistry.registerItem(T4Boots, "T4Boots");
    	FMLCommonHandler.instance().bus().register(new MSOnCraft());//makes the handler work
	//Achievement Code
	achMicrochip = new Achievement("achievement.microchip", "microchip", 0, 0, Microchip, AchievementList.acquireIron).registerStat();
	achT1 = new Achievement("achievement.t1", "t1", 0, 2, T1Helmet, achMicrochip).registerStat();
	achT2V1 = new Achievement("achievement.t2v1", "t2v1", 2, 2, T2HelmetV1, achT1).registerStat();
	achT2V2 = new Achievement("achievement.t2v2", "t2v2", -2, 2, T2HelmetV2, achT1).registerStat();
	achT3 = new Achievement("achievement.t3", "t3", 0, 3, T2HelmetV1, achT2V1).registerStat();//add second requirement of T2V2
	achT4 = new Achievement("achievement.t4", "t4", 0, 4, T2HelmetV2, achT3).registerStat();
	//Achievement Page Code
	AchievementPage achPageMechsuit = new AchievementPage("MechSuit", new Achievement[]{achMicrochip, achT1, achT2V1, achT2V2, achT3, achT4});
	AchievementPage.registerAchievementPage(achPageMechsuit);
    }
    
    @EventHandler
    public void load(FMLInitializationEvent event) {
    }
    
    @EventHandler
    public void postInit(FMLPostInitializationEvent event) {
    }
}

 

 

If I helped please press the Thank You button.

 

Check out my mods at http://www.curse.com/users/The_Fireplace/projects

Posted

You can still have it. I have used it.

 

You should also be initializing variables in the pre-init method, btw. Try that and come back. That might fix it. Everything else seems fine.

-Mitchellbrine

 

Minecraft can do ANYTHING, it's coded in Java and you got the full power of Java behind you when you code. So nothing is impossible.

It may be freaking fucking hard though, but still possible ;)

 

If you create a topic on Modder Support, live by this motto:

I don't want your charity, I want your information
  • 2 weeks later...
Posted

You have a mistake in the following line.

 

achMicrochip = new Achievement("achievement.microchip", "microchip", 0, 0, Microchip, AchievementList.acquireIron).registerStat();

 

Replce "AcheivementList.acquireIron" with null.

 

Copy/Paste has struck again.

 

Long time Bukkit & Forge Programmer

Happy to try and help

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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