Jump to content

Recommended Posts

Posted

I don't even know what's causing this one. It happens whenever I right click an item that I created.

 

Note: It works perfectly the first two times I use it but on the third one it crashes. Also this only seems to pertain to the Skin type.

 

Error

14:22:29] [server thread/FATAL] [FML]: Exception caught executing FutureTask: java.util.concurrent.ExecutionException: java.lang.NullPointerException
java.util.concurrent.ExecutionException: java.lang.NullPointerException
at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.7.0_79]
at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.7.0_79]
at net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:715) [FMLCommonHandler.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:727) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:669) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:171) [integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:540) [MinecraftServer.class:?]
at java.lang.Thread.run(Unknown Source) [?:1.7.0_79]
Caused by: java.lang.NullPointerException
at net.minecraft.server.management.ItemInWorldManager.tryUseItem(ItemInWorldManager.java:398) ~[itemInWorldManager.class:?]
at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:607) ~[NetHandlerPlayServer.class:?]
at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:67) ~[C08PacketPlayerBlockPlacement.class:?]
at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:114) ~[C08PacketPlayerBlockPlacement.class:?]
at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:24) ~[PacketThreadUtil$1.class:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.7.0_79]
at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.7.0_79]
at net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:714) ~[FMLCommonHandler.class:?]

 

Item Class

@Override
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn){
	if (!worldIn.isRemote){
		if(!playerIn.capabilities.isCreativeMode){
			if(PackManager.crackPack(playerIn, type)){
				itemStackIn.stackSize --;
				return null;
			}else{
				playerIn.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "You are out of inventory space!"));
			}
		}else{
			playerIn.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "You must be in survival mode to use this!"));
		}
	}
	return itemStackIn;
}

 

More code that might be helpful.

/**
 * Opens a trail pack for the player.
 * @param player
 */
public static boolean crackPack(EntityPlayer player, EnumPackType type){
	if(!player.worldObj.isRemote){
		switch(type){
		default:
			logger.error("Invalid pack type for type " + type + "!");
			return false;
		case Trail:
			if(player.inventory.hasItem(ItemManager.trailPack)){
				Trail trail = TrailManager.getRandomTrail();

				ItemStack is = new ItemStack(ItemManager.openedTrailPack, 1);
				NBTTagCompound tag = new NBTTagCompound();
				is.setTagCompound(tag);
				tag.setString("Type", EnumPackType.Trail.toString());
				tag.setString("Trail", trail.getName());
				is.setStackDisplayName("" + EnumAppRarity.getColorFromTrail(trail) + trail.getRarity() + EnumChatFormatting.AQUA + " Trail Pack");

				if(player.inventory.addItemStackToInventory(is)){
					player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "You have cracked a " + EnumAppRarity.getColorFromTrail(trail) + trail.getRarity() + EnumChatFormatting.AQUA + " Trail of " + EnumAppRarity.getColorFromTrail(trail) + trail.getName() + "!"));
					if(trail.getRarity() == EnumAppRarity.Mythic){
						PacketManager.sendPacketToAll(new PacketChatMessage(EnumChatFormatting.GOLD + player.getName() + " just cracked a " + EnumAppRarity.getColorFromTrail(trail) + trail.getRarity() + EnumChatFormatting.GOLD + " Trail of " + EnumAppRarity.getColorFromTrail(trail) + trail.getName() + "!"));
					}
					return true;
				}else{
					return false;
				}
			}
			break;
		case Skin:
			if(player.inventory.hasItem(ItemManager.skinPack)){
				Skin skin = SkinManager.getRandomSkin();

				ItemStack is = new ItemStack(ItemManager.openedSkinPack, 1);
				NBTTagCompound tag = new NBTTagCompound();
				is.setTagCompound(tag);
				tag.setString("Type", EnumPackType.Skin.toString());
				tag.setString("Skin", skin.getName());
				is.setStackDisplayName("" + EnumAppRarity.getColorFromRarity(skin.getRarity()) + skin.getRarity() + EnumChatFormatting.AQUA + " Skin Pack");

				if(player.inventory.addItemStackToInventory(is)){
					player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "You have cracked a " + EnumAppRarity.getColorFromRarity(skin.getRarity()) + skin.getRarity() + EnumChatFormatting.AQUA + " Skin of " + EnumAppRarity.getColorFromRarity(skin.getRarity()) + skin.getName() + "!"));
					if(skin.getRarity() == EnumAppRarity.Mythic){
						PacketManager.sendPacketToAll(new PacketChatMessage(EnumChatFormatting.GOLD + player.getName() + " just cracked a " + EnumAppRarity.getColorFromRarity(skin.getRarity()) + skin.getRarity() + EnumChatFormatting.GOLD + " Skin of " + EnumAppRarity.getColorFromRarity(skin.getRarity()) + skin.getName() + "!"));
					}
					return true;
				}else{
					return false;
				}
			}
			break;
		}

	}
	return false;
}

Posted

I think the error is caused by returning null from

Item#onItemRightClick

.

ItemInWorldManager#tryUseItem

expects a non-null

ItemStack

to be returned, even if its

stackSize

is 0 (which it explicitly checks for).

 

Oddly enough, it does check if the returned

ItemStack

is null; but only after checking that the returned

ItemStack

is equal to the original

ItemStack

(which can't possibly be null at that point).

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
  On 8/21/2015 at 7:44 PM, Choonster said:

I think the error is caused by returning null from

Item#onItemRightClick

.

ItemInWorldManager#tryUseItem

expects a non-null

ItemStack

to be returned, even if its

stackSize

is 0 (which it explicitly checks for).

 

Oddly enough, it does check if the returned

ItemStack

is null; but only after checking that the returned

ItemStack

is equal to the original

ItemStack

(which can't possibly be null at that point).

 

If I don't return null then for whatever ungodly reason is it starts to give me negative item stack sizes.

 

EDIT: Just for testing purposes I made it return the itemstack regardless but the error is still happening.

EDIT EDIT: Well I take back my last edit, I see your reasoning so I made it return the itemstack and now it crashes without any errors.

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • My name is Richie Leo, and I’m sharing this message with a heart full of gratitude and hope. Several months ago, I was a victim of a devastating online scam that cost me a staggering $873,463. I was devastated, confused, and had nearly given up on ever recovering my money — until I came across Wizard George Cyber Service. Through their exceptional cyber recovery expertise and deep investigative skills, Wizard George and his team were able to trace, track, and recover the full amount that was stolen from me. Their professionalism, speed, and transparency truly amazed me. If you’re reading this and you’ve been scammed — whether it’s crypto, investment fraud, or any kind of online theft — don’t give up. I strongly recommend reaching out to Wizard George Cyber Service. 📧 Em: wizardgeorgecyberservice(AT) g m a l L. C o M
    • Alright, here is the log file https://mclo.gs/5eCwafV
    • Please read the FAQ (https://forums.minecraftforge.net/topic/125488-rules-and-frequently-asked-questions-faq/) and post log files as described there, using a site such as https://mclo.gs/ and post the link here.  
    • I tried updating the mods in my modpack which caused incompatibilities so i have tried to revert them back to their older versions i was using before. In the logs it doesnt show me any clear incompatibilities except for tfmg & entity texture features, but when i try to remove those it still doesn't work. I have tried removing the forge-client.toml file which was a suggestion i found on  a few other posts. This is the log file i get. [inline log removed] Any help would be appreciated. Thanks in advance
    • I don't use KubeJS, never even heard of it. But after doing what "Ugdhar" suggested earlier in this post with the "config/Mekanism/generator-storage.toml", I tried going into an individual save's serverconfig folder, and just deleting everything except the parcool folder (I have that mod installed.) Then, a bit of loading and temporary freezing later, seems to have worked. Even when quitting to menu and loading back in, or also when quitting to menu, exiting to desktop, and re-launching MC, choose a save and loading it.
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.