firegodjr Posted June 21, 2016 Share Posted June 21, 2016 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? Quote Link to comment Share on other sites More sharing options...
coolAlias Posted June 22, 2016 Share Posted June 22, 2016 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. Quote http://i.imgur.com/NdrFdld.png[/img] Link to comment Share on other sites More sharing options...
Anon10W1z Posted June 22, 2016 Share Posted June 22, 2016 Take a look at my auto-smelt enchantment code if you need any other assistance. Quote Maker of the Craft++ mod. Link to comment Share on other sites More sharing options...
firegodjr Posted June 22, 2016 Author Share Posted June 22, 2016 @coolAlias: That worked! Thank you! @Anon10W1z: Thanks for the offer, but I wanted to make this pickaxe as sort of a personal challenge, since I'd never actually made one like it. No copy/paste for me. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.