Jump to content

[Solved][1.9] Autosmelting Pickaxe; new EntityItem drop doesn't spawn every time


Recommended Posts

So I have a basic autosmelting pickaxe setup, utilizing HarvestDropsEvent.

public void OnBlockBreak(HarvestDropsEvent e)
	EntityPlayer player = e.getHarvester();
	//If the player is holding the blazing pickaxe in their main hand
	if(player != null && player.getHeldItemMainhand().getItem() == ModItems.blazingPick)
			for(int i = 0; i < e.getDrops().size(); i++)

				ItemStack dropstack = FurnaceRecipes.instance().getSmeltingResult(e.getDrops().get(i));
				if(dropstack != null)
					System.out.printf("%s smelts to: %s\n",

					if(e.getWorld().spawnEntityInWorld(new EntityItem(e.getWorld(),                                  
                                                e.getPos().getX()+0.5,e.getPos().getY() + 0.5, e.getPos().getZ() + 0.5, dropstack)))
						System.out.printf("Dropped item at %s, %s, %s\n", e.getPos().getX() + 0.5, 
                                                        e.getPos().getY() + 0.5, e.getPos().getZ() + 0.5);
						System.out.println("Dropping item failed.");
				} else {System.out.printf("%s has no smelting output.\n",


Strangely, this code causes the event to "smelt" the drops the first time it smelts the drops, but if you try to mine a block that produces the same drops after that first one (eg. mining the same block again, or mining stone then cobblestone), it doesn't spawn the new EntityItem.


For example, I can mine three blocks of Iron Ore, but only the first one drops the smelted item, the others just don't drop anything as the drop chance has been set to 0. However, I can go and mine some gold, and it'll drop from the first one, but this doesn't reset anything, and trying to mine the iron will still spawn no new drops.


All of this seems to run correctly, since the System.out.println/printf calls still run. I have no idea why it would run through the code but not spawn the EntityItem. Any ideas?

Link to comment
Share on other sites

Make sure you spawn the EntityItem using a COPY of the ItemStack (i.e. dropstack.copy()) - IIRC, #getSmeltingResult returns only a single ItemStack instance, not a new one each time, so after you have picked up the first stack dropped, every drop after that will have a stack size of zero.


Usually in that case, however, the item will still spawn but picking it up doesn't give you anything. It's possible they have changed this behavior since 1.7.10/1.8.

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.

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.


  • Create New...

Important Information

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