Posted June 9, 201510 yr 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.
June 9, 201510 yr You are dropping the items on the server side and the client side. Do a !world.isRemote check first.
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.