So I have a basic autosmelting pickaxe setup, utilizing HarvestDropsEvent.
@SubscribeEvent
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)
{
if(!e.getWorld().isRemote)
{
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",
e.getDrops().get(i).getDisplayName(),dropstack.getDisplayName());
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);
}
else
{
System.out.println("Dropping item failed.");
}
} else {System.out.printf("%s has no smelting output.\n",
e.getDrops().get(i).getDisplayName());}
}
}
}
e.setDropChance(0);
}
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?