Posted June 5, 20178 yr Hello, I have created an enchantment, that makes tools break multiple block at once (like in 3x3 area). However, now it simply destroys the additional block and if there is any enchantment on that tool, that affects block loot, it has no effect. Is there any way how to simulate, that that block was mined by the tool, that caused it to break, so all the enchantments n that tool would be applied on that block properly. Thakns for any help. Edited June 7, 20178 yr by fcelon
June 5, 20178 yr Block::harvestBlock applies all vanilla enchantments, adds stats to the player's stat tracker and drops appropriate items. It will not set the block to air for you so you have to do it manualy. It does not fire forge's events that are related to block destruction(it will however fire the HarvestDropsEvent) so you might want to fire some of those manualy too. Just don't trigger a recursion where you handle the even you are firing - that would only result in a crash. Note that if you want to completely simulate the harvesting of the block including all events, drops and whatnot you can simply invoke PlayerInteractionManager::tryHarvestBlock. Just be aware that it is going to fire all forge events related to block harvesting. Most likely including the one you are handling so you will have to avoid infinite recursion.
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.