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()).

 

Use

EntityItemPickupEvent

or an

IPickupNotifier

.

 

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 {

@Instance(ModInformation.ID)
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);

@EventHandler
public void preInit(FMLPreInitializationEvent event) {
	ConfigHandler.init(event.getSuggestedConfigurationFile());
	Items.init();
	Blocks.init();
	proxy.initSounds();
	proxy.initRenderers();
}

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


}

@EventHandler
public void modsLoader(FMLPostInitializationEvent event) {

}


}

 

PickupHandler.class:

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 {
@Override
public void notifyPickup(EntityItem item, EntityPlayer player) {

	if (item.getEntityItem().itemID == ItemInfo.TEAR_DEFAULT)
			player.triggerAchievement(AchievementList.buildWorkBench);

}
}

 

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.

Guest
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.



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • A while ago I went to install forge, everything was going well until after downloading the forge when I clicked open the download, it appeared for me to choose an app to open, then I tried to open it with apps like internet explorer , but it was not opening as I had seen in some tutorials on youtube. I kept looking at tutorials and noticed that the forge should open via java. I went to my control panel to see if I had the java, and nothing came up, so I decided to install the java. I tried to open the forge through java, but it didn't work. I continued trying, then I even found the java file folder on my computer, explaining how I play minecraft (not a pirate), I tried to open the forge with a java that I found in this java folder, but it didn't work. So, the problem with all these times that I tried to open it through java is that only a black screen appears for 1 second, and every now and then it opens, but only a black screen appears. Does anyone know how to solve my problem?
    • 1.7 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support.
    • Please ignore this message, I wrote in portuguese and I release that this is an inglesh forum
    • Hi, I'm trying to make a forge 1.7.10 server. I'm getting unknown errors, any ideas? D:\Pulpit\Crazy craft testing>java -Xmx6144M -Xms6144M -jar forge.jar nogui [18:45:21] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLServerTweaker [18:45:21] [main/INFO] [LaunchWrapper]: Using primary tweak class name cpw.mods.fml.common.launcher.FMLServerTweaker [18:45:21] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLServerTweaker [18:45:21] [main/INFO] [FML]: Forge Mod Loader version 7.99.40.1614 for Minecraft 1.7.10 loading [18:45:21] [main/INFO] [FML]: Java is Java HotSpot(TM) 64-Bit Server VM, version 1.8.0_281, running on Windows 10:amd64:10.0, installed at C:\Program Files\Java\jre1.8.0_281 [18:45:21] [main/WARN] [FML]: The coremod codechicken.nei.asm.NEICorePlugin does not have a MCVersion annotation, it may cause issues with this version of Minecraft [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: java.lang.NoClassDefFoundError: codechicken/lib/asm/ASMInit [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at codechicken.nei.asm.NEICorePlugin.<init>(NEICorePlugin.java:18) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at java.lang.reflect.Constructor.newInstance(Unknown Source) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at java.lang.Class.newInstance(Unknown Source) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at cpw.mods.fml.relauncher.CoreModManager.loadCoreMod(CoreModManager.java:501) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at cpw.mods.fml.relauncher.CoreModManager.discoverCoreMods(CoreModManager.java:389) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at cpw.mods.fml.relauncher.CoreModManager.handleLaunch(CoreModManager.java:221) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at cpw.mods.fml.relauncher.FMLLaunchHandler.setupHome(FMLLaunchHandler.java:90) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at cpw.mods.fml.relauncher.FMLLaunchHandler.setupServer(FMLLaunchHandler.java:74) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at cpw.mods.fml.relauncher.FMLLaunchHandler.configureForServerLaunch(FMLLaunchHandler.java:39) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at cpw.mods.fml.common.launcher.FMLServerTweaker.injectIntoClassLoader(FMLServerTweaker.java:23) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at net.minecraft.launchwrapper.Launch.launch(Launch.java:115) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at java.lang.reflect.Method.invoke(Unknown Source) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at cpw.mods.fml.relauncher.ServerLaunchWrapper.run(ServerLaunchWrapper.java:43) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at cpw.mods.fml.relauncher.ServerLaunchWrapper.main(ServerLaunchWrapper.java:12) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: Caused by: java.lang.ClassNotFoundException: codechicken.lib.asm.ASMInit [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at java.lang.ClassLoader.loadClass(Unknown Source) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at java.lang.ClassLoader.loadClass(Unknown Source) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   ... 21 more [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: Caused by: java.lang.NullPointerException [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:182) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   ... 23 more [18:45:21] [main/ERROR] [FML]: An error occurred trying to configure the minecraft home at D:\Pulpit\Crazy craft testing\. for Forge Mod Loader java.lang.NoClassDefFoundError: codechicken/lib/asm/ASMInit         at codechicken.nei.asm.NEICorePlugin.<init>(NEICorePlugin.java:18) ~[NotEnoughItemsuniversal.jar:?]         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_281]         at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_281]         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_281]         at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_281]         at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_281]         at cpw.mods.fml.relauncher.CoreModManager.loadCoreMod(CoreModManager.java:501) ~[forge.jar:?]         at cpw.mods.fml.relauncher.CoreModManager.discoverCoreMods(CoreModManager.java:389) ~[forge.jar:?]         at cpw.mods.fml.relauncher.CoreModManager.handleLaunch(CoreModManager.java:221) ~[forge.jar:?]         at cpw.mods.fml.relauncher.FMLLaunchHandler.setupHome(FMLLaunchHandler.java:90) [forge.jar:?]         at cpw.mods.fml.relauncher.FMLLaunchHandler.setupServer(FMLLaunchHandler.java:74) [forge.jar:?]         at cpw.mods.fml.relauncher.FMLLaunchHandler.configureForServerLaunch(FMLLaunchHandler.java:39) [forge.jar:?]         at cpw.mods.fml.common.launcher.FMLServerTweaker.injectIntoClassLoader(FMLServerTweaker.java:23) [forge.jar:?]         at net.minecraft.launchwrapper.Launch.launch(Launch.java:115) [launchwrapper-1.12.jar:?]         at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_281]         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_281]         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_281]         at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_281]         at cpw.mods.fml.relauncher.ServerLaunchWrapper.run(ServerLaunchWrapper.java:43) [forge.jar:?]         at cpw.mods.fml.relauncher.ServerLaunchWrapper.main(ServerLaunchWrapper.java:12) [forge.jar:?] Caused by: java.lang.ClassNotFoundException: codechicken.lib.asm.ASMInit         at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191) ~[launchwrapper-1.12.jar:?]         at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_281]         at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_281]         ... 21 more Caused by: java.lang.NullPointerException         at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:182) ~[launchwrapper-1.12.jar:?]         at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_281]         at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_281]         ... 21 more A problem occurred running the Server launcher.[18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: java.lang.reflect.InvocationTargetException [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at java.lang.reflect.Method.invoke(Unknown Source) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at cpw.mods.fml.relauncher.ServerLaunchWrapper.run(ServerLaunchWrapper.java:43) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at cpw.mods.fml.relauncher.ServerLaunchWrapper.main(ServerLaunchWrapper.java:12) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: Caused by: java.lang.NoClassDefFoundError: codechicken/lib/asm/ASMInit [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at codechicken.nei.asm.NEICorePlugin.<init>(NEICorePlugin.java:18) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at java.lang.reflect.Constructor.newInstance(Unknown Source) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at java.lang.Class.newInstance(Unknown Source) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at cpw.mods.fml.relauncher.CoreModManager.loadCoreMod(CoreModManager.java:501) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at cpw.mods.fml.relauncher.CoreModManager.discoverCoreMods(CoreModManager.java:389) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at cpw.mods.fml.relauncher.CoreModManager.handleLaunch(CoreModManager.java:221) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at cpw.mods.fml.relauncher.FMLLaunchHandler.setupHome(FMLLaunchHandler.java:90) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at cpw.mods.fml.relauncher.FMLLaunchHandler.setupServer(FMLLaunchHandler.java:74) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at cpw.mods.fml.relauncher.FMLLaunchHandler.configureForServerLaunch(FMLLaunchHandler.java:39) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at cpw.mods.fml.common.launcher.FMLServerTweaker.injectIntoClassLoader(FMLServerTweaker.java:23) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at net.minecraft.launchwrapper.Launch.launch(Launch.java:115) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   ... 6 more [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: Caused by: java.lang.ClassNotFoundException: codechicken.lib.asm.ASMInit [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at java.lang.ClassLoader.loadClass(Unknown Source) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at java.lang.ClassLoader.loadClass(Unknown Source) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   ... 21 more [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: Caused by: java.lang.NullPointerException [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:182) [18:45:21] [main/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:   ... 23 more D:\Pulpit\Crazy craft testing>PAUSE Press any key to continue . . .
    • Nvm, the error does not seem to come from the slot by itself but from somwhere else. Currently investigating.  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.