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:
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());
}
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);
}
}
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);
}
}
}
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);
}
}
}
Create an account or sign in to comment.