Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Add PlayerPlaceBlockEvent/PostPlayerPlaceBlockEvent

Open Owen1212055 opened this issue 2 years ago • 2 comments

In general, there are many flaws with the current block place event. Mainly, the server has to properly attempt to revert the block being placed, however, this had led to an unpredictable amount of issues each update and in general has seen to introduce some duping issues.

This PR suggests deprecating the current events and in favor of introducing events that more properly represent the current block-placing process.

The PlayerPlaceBlockEvent allows you to cancel the placing of a block. This is a simple event and occurs at the highest point of block placement logic.

The PostPlayerPlaceBlockEvent allows you to get what blocks are placed due to a block placement, however, unlike the BlockPlaceEvent, you are unable to cancel this event. This is because the API cannot promise that the state will actually be resolved.

There isn't any win-win situation for this. In general, it is impossible to nicely revert block placements like this.

Owen1212055 avatar Jun 10 '23 01:06 Owen1212055

Where in the new logic would the BlockCanBuildEvent fit in? To me it seems like the PlayerPlaceBlockEvent serves the same purpose, except that it properly uses Cancellable and not some weird setBuildable logic

Malfrador avatar Jun 10 '23 02:06 Malfrador

Where in the new logic would the BlockCanBuildEvent fit in? To me it seems like the PlayerPlaceBlockEvent serves the same purpose, except that it properly uses Cancellable and not some weird setBuildable logic

Very similar, but we can prolly end up deprecating that event too. In general that event is a block event, which can lead to the improper assumption that the block is already in the world (bad api, in general). And so really, it's better to just have our generic event there instead.

Owen1212055 avatar Jun 10 '23 06:06 Owen1212055