Cancelling placement Events

A new update is now available, introducing seasons and more!
Latest hotfix: 0.8.0.1 (2024-12-20)
  • I'm not sure if this should be in this forum? But I don't want to spam the Discussion form with something technical that possibly regards the API.


    Currently in RW, if an event such as onPlayerPlaceBlock is cancelled the player placing the block is still "charged" for placing the block. I.e. their block count is decremented by a block, or multiple blocks if multiple block placement.


    Will this still be the case in the new version? I.e. I will need to use the API to replace the used (but at the same time not used) blocks?

  • I would think that is intended behaviour as from the game's side the event happened and then a plugin decided to cancel its action.


    To avoid the player losing the blocks you would need to add them back to the inventory after cancelling the event

  • Well, actually the block isn't really removed if the event is cancelled - it just looks like the item is missing :D In the Java version, the client and server inventory were updated independently: When placing an item, the item is first removed from the clientside inventory, then the "place item" packet is sent to the server which invokes the API event, then - if the event wasn't cancelled - the item also gets removed from the serverside inventory and the item is placed in the world.

    Cancelling the event prevents the item from being removed from the server inventory, but at this stage, it is already removed from the client inventory (strictly speaking, this results in a desync between client and server inventory). If the client closes and opens his inventory again, the game detects the desync and requests the inventory from the server - this restores the missing item (so at the end of the day, the player actually didn't really lose the item).


    The reason for this overly complicated implementation was to keep the latency and bandwidth as low as possible. Tbh, this wasn't the best idea, since this implementation is error prone and doesn't work well with the API (resulting in the issue you've mentioned).

    However, inventory and item handling works completely different in the new version - the client inventory only gets updated after the server inventory was actually updated (no longer resulting in desync if you cancel such an even through the API) - so yes, this will be "fixed" in the new version ;)

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!