Jump to content

Recommended Posts

Posted (edited)

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 by fcelon
Posted

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.

Guest
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.

Announcements



×
×
  • Create New...

Important Information

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