Posted May 16, 201411 yr I have been working on getting the id of the mob but for some reason when i check to see if the item is null or my item it crashes. @SubscribeEvent public void OnEntityDeath(LivingDeathEvent event) { if(event.source.getSourceOfDamage() instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.source.getSourceOfDamage(); int size = player.inventory.mainInventory.length; for(int i = 0; i < size; i++) { ItemStack itemStack = player.inventory.mainInventory[i]; if(itemStack.getItem() != null) { if(itemStack.getItem() instanceof ItemSoulJar) { //if(rand.nextInt(50) == 1) if(itemStack.stackTagCompound == null) { itemStack.setTagCompound(new NBTTagCompound()); itemStack.stackTagCompound.setInteger("Entity Id", event.entityLiving.getEntityId()); } } } } } } ---- Minecraft Crash Report ---- // Quite honestly, I wouldn't worry myself about that. Time: 16/05/14 1:05 AM Description: Ticking memory connection java.lang.NullPointerException: Ticking memory connection at com.jdb.base.events.ModEventHandler.OnEntityDeath(ModEventHandler.java:31) at cpw.mods.fml.common.eventhandler.ASMEventHandler_4_ModEventHandler_OnEntityDeath_LivingDeathEvent.invoke(.dynamic) at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:51) at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:122) at net.minecraftforge.common.ForgeHooks.onLivingDeath(ForgeHooks.java:289) at net.minecraft.entity.EntityLivingBase.onDeath(EntityLivingBase.java:992) at net.minecraft.entity.passive.EntityHorse.onDeath(EntityHorse.java:1018) at net.minecraft.entity.EntityLivingBase.attackEntityFrom(EntityLivingBase.java:950) at net.minecraft.entity.passive.EntityAnimal.attackEntityFrom(EntityAnimal.java:224) at net.minecraft.entity.passive.EntityHorse.attackEntityFrom(EntityHorse.java:360) at net.minecraft.entity.player.EntityPlayer.attackTargetEntityWithCurrentItem(EntityPlayer.java:1401) at net.minecraft.network.NetHandlerPlayServer.processUseEntity(NetHandlerPlayServer.java:873) at net.minecraft.network.play.client.C02PacketUseEntity.processPacket(C02PacketUseEntity.java:51) at net.minecraft.network.play.client.C02PacketUseEntity.processPacket(C02PacketUseEntity.java:69) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:232) at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:720) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:608) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:746) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at com.jdb.base.events.ModEventHandler.OnEntityDeath(ModEventHandler.java:31) at cpw.mods.fml.common.eventhandler.ASMEventHandler_4_ModEventHandler_OnEntityDeath_LivingDeathEvent.invoke(.dynamic) at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:51) at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:122) at net.minecraftforge.common.ForgeHooks.onLivingDeath(ForgeHooks.java:289) at net.minecraft.entity.EntityLivingBase.onDeath(EntityLivingBase.java:992) at net.minecraft.entity.passive.EntityHorse.onDeath(EntityHorse.java:1018) at net.minecraft.entity.EntityLivingBase.attackEntityFrom(EntityLivingBase.java:950) at net.minecraft.entity.passive.EntityAnimal.attackEntityFrom(EntityAnimal.java:224) at net.minecraft.entity.passive.EntityHorse.attackEntityFrom(EntityHorse.java:360) at net.minecraft.entity.player.EntityPlayer.attackTargetEntityWithCurrentItem(EntityPlayer.java:1401) at net.minecraft.network.NetHandlerPlayServer.processUseEntity(NetHandlerPlayServer.java:873) at net.minecraft.network.play.client.C02PacketUseEntity.processPacket(C02PacketUseEntity.java:51) at net.minecraft.network.play.client.C02PacketUseEntity.processPacket(C02PacketUseEntity.java:69) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:232) -- Ticking connection -- Details: Connection: net.minecraft.network.NetworkManager@71431492 Stacktrace: at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:720) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:608) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:746) -- System Details -- Details: Minecraft Version: 1.7.2 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.7.0_21, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 924929440 bytes (882 MB) / 1056309248 bytes (1007 MB) up to 1056309248 bytes (1007 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 2688 (150528 bytes; 0 MB) allocated, 2443 (136808 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP v9.03 FML v7.2.196.1082 Minecraft Forge 10.12.1.1082 4 mods loaded, 4 mods active mcp{9.03} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available FML{7.2.196.1082} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.1.1082.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Forge{10.12.1.1082} [Minecraft Forge] (forgeSrc-1.7.2-10.12.1.1082.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Totem{1.0} [Totem] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Profiler Position: N/A (disabled) Vec3 Pool Size: 339 (18984 bytes; 0 MB) allocated, 314 (17584 bytes; 0 MB) used Player Count: 1 / 8; [EntityPlayerMP['Player219'/145, l='New World', x=355.91, y=4.00, z=-808.66]] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge' Creator of Jobo's ModLoader If I helped you could you please click the thank you button and applaud my karma.
May 16, 201411 yr The ItemStack may also be null, and if it's not, then itemstack.getItem() will not ever be null. "if (itemstack != null && itemstack.getItem() instanceof SomeItem)" is safe from null exceptions. http://i.imgur.com/NdrFdld.png[/img]
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.