1

Achievement not working - please help

tsant2009's Avatar tsant20094/9/20 3:51 pm history
1 emeralds 132
Hello all,
I am trying to program an achievement on picking up a certain item in my mod, but cannot get it to work.
My mod is targeting MC 1.7.10. I know it's old but I like to work with that version for now.

This is the relevant code in my Mod's main class, and I suspect something is not right - please help me:



Main Class
@EventHandler
public void init(FMLInitializationEvent event)
{

Item linxiumItem = new LinxiumItem("linxiumItem");
GameRegistry.registerItem(linxiumItem, "linxiumItem");

ach = new Achievement("", "LinxiumAchievement", 0, 0, linxiumItem, null);
FMLCommonHandler.instance().bus().register(new EventListener());

}

Linxium Item
package com.tsant2009.examplemod.items;

import com.tsant2009.examplemod.ExampleMod;

import net.minecraft.item.*;
import net.minecraft.creativetab.CreativeTabs;

public class LinxiumItem extends Item {
public LinxiumItem(String itemName)
{
this.setUnlocalizedName(itemName);
this.setTextureName(ExampleMod.MODID + ":" + itemName);
this.setCreativeTab(CreativeTabs.tabMisc);
}
}

EventListener
package com.tsant2009.examplemod;

import net.minecraft.init.Items;
import cpw.mods.fml.common.gameevent.PlayerEvent.ItemPickupEvent;

public class EventListener {
public void pickup(ItemPickupEvent event)
{
if(event.pickedUp.getEntityItem().getItem() == ExampleMod.linxiumItem)
{
event.player.addStat(ExampleMod.ach, 1);
}
}
}



Posted by tsant2009's Avatar
tsant2009
Level 3 : Apprentice Engineer
0

Create an account or sign in to comment.

Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome