Jump to content

[1.7.10] How to add items to inventory


pcnorden

Recommended Posts

Hi there, and thanks for helping me.

 

I have made a pickaxe that detects when something is meltable, and melts it, but when I try to add the result into the inventory, which I do with "player.inventory.addItemStackToInventory(stack);".

 

public boolean onBlockDestroyed(ItemStack par1, World par2, Block par3, int x, int y, int z, EntityLivingBase par4){
	if(!par2.isRemote){
		ItemStack stack = FurnaceRecipes.smelting().getSmeltingResult(par1);
		if(stack != null){
			if(par4 instanceof EntityPlayer){
				EntityPlayer player = (EntityPlayer) par4;
				player.inventory.addItemStackToInventory(stack);
				return true;
			}else{
				return false;
			}
		}else{
			return false;
		}
	}else{
		return false;
	}
}

 

And I can mine one time, and get the item, and the rest of the times, it just go througt the code, to "player.inventory.addItemStackToInventory(stack);", and past, but does not give me the item.

 

What am I doing wrong?

Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

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