Block placement / interaction · Issue #177 · feather-rs/feather · GitHub
Skip to content

Block placement / interaction #177

Description

@Defman

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.

  1. Try to interact with the block

  2. Try to place the held item at the location

  3. Try to place the held item at the location + face

  4. 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(),
  ...
}
  1. 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),
  ...
}
  1. This step is identical to step 2. but the from block = state.block_at(location + face).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions