Jump to content

[1.8] Dropped items create ghost copies


Ferrettomato

Recommended Posts

I'm attempting to empty the "contents" of an item by dropping them on the ground to eliminate the possibility of the contents being deleted due to a full inventory, but, whenever I attempt to do this, a ghost copy of the previously stored item is created in addition to the actual, collectible item. Is there any way to fix this?

 

Method (there are two uses of playerIn.entityDropItem()):

 public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
 {
	 if(itemStackIn.getItem() instanceof ItemInlayArmor)
	 {
		 int focusTarget = playerIn.inventory.currentItem + 1;
		 if(!playerIn.isSneaking())
		 {

			 if(itemStackIn.hasTagCompound())
			 {
				 if(playerIn.inventory.getStackInSlot(focusTarget) != null)
				 {
					 if(Item.getByNameOrId(itemStackIn.getTagCompound().getString("id")).equals(playerIn.inventory.getStackInSlot(focusTarget).getItem()))
					 {
						 return itemStackIn;
					 }
				 }
				 playerIn.entityDropItem(new ItemStack(Item.getByNameOrId(itemStackIn.getTagCompound().getString("id")), 1, itemStackIn.getTagCompound().getShort("Damage")), 0);
				 //playerIn.inventory.addItemStackToInventory(new ItemStack(Item.getByNameOrId(itemStackIn.getTagCompound().getString("id")), 1, itemStackIn.getTagCompound().getShort("Damage")));
				 itemStackIn.setTagCompound(null);
			 }
			 ItemInlayArmor item = (ItemInlayArmor)itemStackIn.getItem();

			 if(playerIn.inventory.getStackInSlot(focusTarget) != null)
			 {
				 ItemStack focusItem = playerIn.inventory.getStackInSlot(focusTarget);
				 if(validItems.contains(Item.itemRegistry.getNameForObject(focusItem.getItem()).toString()))
				 {
					 if(Item.itemRegistry.getNameForObject(focusItem.getItem()).toString().equals("minecraft:dye") && focusItem.getItemDamage() != 0)
					 {
						 return itemStackIn;
					 }
					playerIn.inventory.decrStackSize(focusTarget, 1);

					NBTTagCompound nbt = itemStackIn.getTagCompound();
					if(nbt == null)
				 	{
						nbt = new NBTTagCompound();
						itemStackIn.setTagCompound(nbt);
				 	}
					itemStackIn.loadItemStackFromNBT(focusItem.writeToNBT(nbt));
				 }
			 }

		 }
		 else if(itemStackIn.hasTagCompound())
		 {
			 playerIn.entityDropItem(new ItemStack(Item.getByNameOrId(itemStackIn.getTagCompound().getString("id")), 1, itemStackIn.getTagCompound().getShort("Damage")), 0);
			 //playerIn.inventory.addItemStackToInventory(new ItemStack(Item.getByNameOrId(itemStackIn.getTagCompound().getString("id")), 1, itemStackIn.getTagCompound().getShort("Damage")));
			 itemStackIn.setTagCompound(null);
			 return itemStackIn;
		 }
	 }
     return itemStackIn;
 }

 

I tried worldIn.updateEntities() without knowing its precise function, but, regardless, it had no effect.

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.