Jump to content

Recommended Posts

Posted

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 (I think) in my Mod, and I suspect something is not right - please help me:

 

Spoiler

(from my 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());
}

 

(my item class)

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

 

(my event listener)

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

 

 


 

 

 

 

 

 

Posted

1.7.10 is not supported here anymore. Update to the newer versions.

This is my signature. I don't really too much know about java but i try to help and i try to get help from others too. Thank you!

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.