You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The PlayerBlockPlacement packet is also responsible for any block interaction ie. opening chests or filling bottles from a cauldron. The current block placement system have to be reworked into the following three steps.
Try to interact with the block
Try to place the held item at the location
Try to place the held item at the location + face
Interacting with blocks simple match over held item and block.
It might be wise to use a different approach than the match for interactions—as the number of blocks supporting interactions increases, this function is going to get pretty unwieldy. Would something like the inventory crate be of interest here?
It seems like inventory would be a nice fit, however I had thought about using the event system. Such that an interaction event is first fired and it has a mutable canceled field which any event handler must set to true if the interaction was successful. Second a block place event is fired at the location if the previous event was unsuccessful and last a block place event at location + face.
I dont know how to add a mutable field to an event, if it is even possible without a mutex guard. If so it would be a synchronization overhead which would negatively effect performance.
It appears block placement does not have any checks to make sure it is not blocked by an entity (ex: players) - I don't believe this is a known issue at the moment
Activity
caelunshun commentedon Mar 2, 2020
It might be wise to use a different approach than the
matchfor interactions—as the number of blocks supporting interactions increases, this function is going to get pretty unwieldy. Would something like the inventory crate be of interest here?Defman commentedon Mar 3, 2020
It seems like inventory would be a nice fit, however I had thought about using the event system. Such that an interaction event is first fired and it has a mutable
canceledfield which any event handler must set to true if the interaction was successful. Second a block place event is fired at the location if the previous event was unsuccessful and last a block place event atlocation + face.I dont know how to add a mutable field to an event, if it is even possible without a mutex guard. If so it would be a synchronization overhead which would negatively effect performance.
Defman commentedon Mar 3, 2020
Seems like tonks already uses inventory for event handler registration?
AnEthernetCable commentedon Aug 10, 2020
It appears block placement does not have any checks to make sure it is not blocked by an entity (ex: players) - I don't believe this is a known issue at the moment