Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Item pickup help.

Recommended Posts

I need some help figuring out if there is a way to perform a certain action when an item is picked up or when it's detected in the players inventory. At the moment I have quite a few items that I'm wanting to change a variable of another item when the item is picked up. However, I don't know if this is possible or if it is, how I'm meant to do it.

Is there an 'onItemPickup' function or something? And is there somewhere to find all the functions and what they do?

I hope this makes sense, if not, please tell me and I'll try and make myself clear.

Many thanks, Tom.

Link to post
Share on other sites

This is handled by Ipickupnotifier. One has to implement its only method which is called when an item gets into inventory. When done, register new instance of the class - GameRegistry.registerPickupHandler(new Blabla()).




or an




Hi, thanks for the replies. I decides to do a bit of research on 'IPickupNotifier' and found some tutorials. However, they don't seem to be working... I decided to test it with picking up an item and receiving an achievement. I believe I have done it right, but I'm not sure, here is my code:



Main class:

package tbos;

import net.minecraft.creativetab.CreativeTabs;
import tbos.blocks.Blocks;
import tbos.config.ConfigHandler;
import tbos.items.Items;
import tbos.network.PacketHandler;
import tbos.network.PickupHandler;
import tbos.proxies.CommonProxy;
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.Mod.PreInit;
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.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;

@Mod(modid = ModInformation.ID, name = ModInformation.NAME, version = ModInformation.VERSION)
@NetworkMod(channels = {ModInformation.CHANNEL}, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
public class TheBindingOfSteve {

public static TheBindingOfSteve instance;

@SidedProxy(clientSide = "tbos.proxies.ClientProxy", serverSide = "tbos.proxies.CommonProxy")
public static CommonProxy proxy;

public static CreativeTabs CustomCreativeTab = new CustomCreativeTab(CreativeTabs.getNextID(), ModInformation.NAME);

public void preInit(FMLPreInitializationEvent event) {

public void load(FMLInitializationEvent event) {
	LanguageRegistry.instance().addStringLocalization("itemGroup." + ModInformation.NAME, "en_US", ModInformation.NAME);
	GameRegistry.registerPickupHandler(new PickupHandler());


public void modsLoader(FMLPostInitializationEvent event) {





package tbos.network;

import tbos.items.ItemInfo;
import tbos.items.Items;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.stats.AchievementList;
import cpw.mods.fml.common.IPickupNotifier;

public class PickupHandler implements IPickupNotifier {
public void notifyPickup(EntityItem item, EntityPlayer player) {

	if (item.getEntityItem().itemID == ItemInfo.TEAR_DEFAULT)



And ItemInfo.class:

package tbos.items;

public class ItemInfo {

public static final String TEXTURE_LOCATION = "tbos";

public static int TEAR_ID;
public static final String TEAR_KEY = "Tear";
public static final int TEAR_DEFAULT = 24201;

public static final String TEAR_UNLOCALIZED_NAME = "Basic-Tear";
public static final String TEAR_NAME = "Tear";

public static final String TEAR_ICON = "tear";



Any help with this would be greatly appreciated!



Link to post
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.

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 Privacy Policy.