Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.