-
Notifications
You must be signed in to change notification settings - Fork 146
Open
Labels
Milestone
Description
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.
match (held_item, from_block) {
(_, Block::Chest(_)) => open_chest(),
(Item::Bottle, Block::Cauldron(_)) => fill_bottle(),
...
}- Simple match on the from block, ie. can the block be replaced
match from_block {
Block::Air | Block::CaveAir | Block::Grass ... => place_block
}
// Handle waterlog
match (held_item, from_block) {
(Item::WaterBucket, Block::Fence) => Block::Fence(data.waterlogged = true),
...
}- This step is identical to step 2. but the from block = state.block_at(location + face).