Is it possible to somehow determine if a player is currently mining a block? I have been trying around with events a little, but there does not seem to be a suitable solution.
I basically want to make a barrier block breakable by first detecting if a player started hitting a block, then counting a specified amount of time, eventually replacing it with air and dropping an appropriate item, just like in vanilla fashion.
InteractBlockEvent does not completely fill my needs, since it is only fired when a player performs the first hit. I hoped it would be fired every few ticks a player is trying to break it, but that is only the case for the secondary hand, not the primary. I think this way there is no way of detecting, if the mining process is still going on.
ChangeBlockEvent don’t seem to work either.
I think detecting if the player is still mining should technically be possible since the player entity’s swinging arm is visible to other clients. My best guesses are the Data API or some networking stuff…
Thanks for advice!