Spongeapi: Add an event for block break start , end and abort

Created on 11 Feb 2018  路  10Comments  路  Source: SpongePowered/SpongeAPI

what i tried was InteractBlockEvent.Primary.MainHand , which is getting fired on every tick (i guess) when mining the block , so its not possible to get when the player started digging without listening for the packet .
adding this will be nice

input wanted event enhancement

Most helpful comment

I'd keep it named as Action Target Event as the API follows, like ChangeBlockEvent or DestroyLivingEvent, etc. Since the action is always constant, the target can change, and we don't use the source in the naming convention since it is included already in the cause.

I'm in favor of DiggingBlockEvent with Start / Stop / Abort and possibly Complete if it's possible in implementation to determine whether it's completed etc.

All 10 comments

@jd1378 What is your usecase?

Some use cases I can think of off the top of my head that may or may not want to be considered.

  1. Anticheat plugin that needs to log/know everything to make smart decisions, usually monitor only.
  2. A plugin that wants to cancel / create / manipulate the block breaking effects.
  3. A plugin that wants to warn a player as early as possible about protected areas, but doesn't want to spam their chat every tick.
  4. A plugin that want's to time how long it takes to break blocks?
  5. A plugin that wants to manipulate how long it takes to break a block.

Where should be the event? In ChangeBlockEvent.Break? like ChangeBlockEvent.Break.Start/Stop/Abort ?

@ryantheleach 1 and 4 are my usecase,
@RedNesto I don't know exactly where the event should be in the API, but IMO it is not necessarily changing the block , while its related to changing the block ,but anyway, what you suggest seems fine to me

It won't be ChangeBlockEvent as the block isn't being changed until it finally breaks.

Since there is Key for Sneaking and Sprinting , why not add the key for these ?
Or there can be a new PlayerActionEvent with both entity action and player digging ? PlayerActionEvent.Start.Sneaking/Sprinting/Mining....?

The Player part of the event name can be too restrictive, so I'll ask here what I asked you in PM: Can Humans/Humanoids dig?

The another issue with the event you are giving us is that the last sub-events (Sneaking, Sprinting) are already accessible via the Keys so what about just a DiggingBlockEvent with sub-event like Start/Stop/Abort?

I'd keep it named as Action Target Event as the API follows, like ChangeBlockEvent or DestroyLivingEvent, etc. Since the action is always constant, the target can change, and we don't use the source in the naming convention since it is included already in the cause.

I'm in favor of DiggingBlockEvent with Start / Stop / Abort and possibly Complete if it's possible in implementation to determine whether it's completed etc.

@RedNesto in answer to your question , i think it depends on the implementation of the humanoid , while it can start digging , there's actually little to no benefit in doing so imo , since the swing and interaction should be handled separately ?

@RedNesto Many entities in modded Minecraft can dig, not just humans.

I only used humans as an example for vanilla. I also was in a hurry and haven't had the time to add reference to mods :3

Was this page helpful?
0 / 5 - 0 ratings

Related issues

connorhartley picture connorhartley  路  3Comments

kashike picture kashike  路  3Comments

ryantheleach picture ryantheleach  路  5Comments

mbax picture mbax  路  3Comments

BrainStone picture BrainStone  路  4Comments