I'm making this a formal request as it wasn't directly answered in the other thread before it got locked.
But are we getting an event that fires before a player begins to mine an entity with an optional flag to cancel that attempt as invalid or the like?
Per API docs, there's currently only an event for when a player finishes the mining process but before the entity is removed whereas robots have an event that happens before they begin the mining process.
The need for this is that it's the appropriate time to figure out if a player can mine an entity (canceling before a player spends time on futility, based on variable and entity specific conditions), and is also the time where the mod would be able to dynamically determine the character's mining speed against the entity being mined. Which is something that can augment the new mining categories feature being added with 0.17.
Also completeness sake, since robots have it and such.
New on_pre_player_mine Event
Re: New on_pre_player_mine Event
Currently the game doesn't support canceling any events and I don't see that changing any time soon.
Also a minor point: robots don't have anything different from players. Robots simply don't respect mining time so they go directly from starting to finishing.
Also a minor point: robots don't have anything different from players. Robots simply don't respect mining time so they go directly from starting to finishing.
If you want to get ahold of me I'm almost always on Discord.
Re: New on_pre_player_mine Event
So what would happen if the player's mining categories were updated during this event to make the mining attempt invalid/valid where the opposite was previously true?
That's not canceling the event, just setting the data to be used right after the event when mining begins.
That's not canceling the event, just setting the data to be used right after the event when mining begins.
Re: New on_pre_player_mine Event
Currently you can't do that. If support to change mining categories is added then it would stop mining.Rythe wrote: Tue Jan 08, 2019 8:37 pm So what would happen if the player's mining categories were updated during this event to make the mining attempt invalid/valid where the opposite was previously true?
That's not canceling the event, just setting the data to be used right after the event when mining begins.
If you want to get ahold of me I'm almost always on Discord.
Re: New on_pre_player_mine Event
We're talking about the player here. The idea is to have 'em stop mining if that category changes to disallow it. We're also talking about an event that happens before mining begins. So it's more: about to start -> can't after all so don't actually start.Rseding91 wrote: Tue Jan 08, 2019 9:44 pmCurrently you can't do that. If support to change mining categories is added then it would stop mining.Rythe wrote: Tue Jan 08, 2019 8:37 pm So what would happen if the player's mining categories were updated during this event to make the mining attempt invalid/valid where the opposite was previously true?
That's not canceling the event, just setting the data to be used right after the event when mining begins.
event.preventDefault() basically, one way or another. Plus the opposite of: about to try to mine invalid target -> target becomes valid so do actually start.