Versepelles Posted March 28, 2017 Posted March 28, 2017 I have a custom tool which overrides the onBlockDestroyed(...) method from the minecraft ItemTool class. In this, a new item stack is spawned at the location of the destroyed block with no motion. However, the item stack flies a fair distance, as if it were spawned inside the block and gained motion from trying to escape- this seems to imply that it is created (and ticked?) before the block is fully destroyed. I would like the custom drop to not have any motion; any advice would be appreciated. If possible, I'd like to keep this contained to the custom tool's class. It seems that past versions of forge may have had a method called onBlockHarvested, which was called after the block was destroyed. If that is true, something like that is what I'm looking for. public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState state, BlockPos pos, EntityLivingBase entityLiving) { ... EntityItem entityitem = new EntityItem(worldIn, pos.getX(), pos.getY() + 0.5f, pos.getZ(), customDrop); entityitem.motionX = 0f; entityitem.motionY = 0f; entityitem.motionZ = 0f; entityitem.setDefaultPickupDelay(); worldIn.spawnEntityInWorld(entityitem); } Quote
Draco18s Posted March 28, 2017 Posted March 28, 2017 That's because onBlockDestroyed is called before the block gets set to air. So yes, the item is, in fact, inside a solid block. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Versepelles Posted March 28, 2017 Author Posted March 28, 2017 1 minute ago, Draco18s said: That's because onBlockDestroyed is called before the block gets set to air. So yes, the item is, in fact, inside a solid block. What method could be called to after the block has been broken? Or what other workarounds might be good? Quote
Draco18s Posted March 28, 2017 Posted March 28, 2017 Try using harvestBlock Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Versepelles Posted March 28, 2017 Author Posted March 28, 2017 (edited) 44 minutes ago, Draco18s said: Try using harvestBlock Thanks for the suggestion. Where is the method harvestBlock located? I can't seem to find it in Item or ItemTool. (Is it an event? I'm not familiar.) EDIT: I think you are referencing the Block.harvestBlock method. This approach wont work, I think, as I'm trying to get a custom drop from vanilla blocks when using a custom tool. Other approaches would still be appreciated! Edited March 28, 2017 by Versepelles Quote
Draco18s Posted March 28, 2017 Posted March 28, 2017 Use the HarvestDropsEvent instead. 1 Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Versepelles Posted March 29, 2017 Author Posted March 29, 2017 11 hours ago, Draco18s said: Use the HarvestDropsEvent instead. Thanks, this worked! Quote
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.