func (chunk *Chunk) reqInteractBlock(player gamerules.IPlayerClient, held gamerules.Slot, target *BlockXyz, againstFace Face) { // TODO use held item to better check of if the player is trying to place a // block vs. perform some other interaction (e.g hoeing dirt). This is // perhaps best solved by sending held item type and the face to // blockType.Aspect.Interact() blockInstance, blockType, ok := chunk.blockInstanceAndType(target) if !ok { return } if _, isBlockHeld := held.ItemTypeId.ToBlockId(); isBlockHeld && blockType.Attachable { // The player is interacting with a block that can be attached to. // Work out the position to put the block at. dx, dy, dz := againstFace.Dxyz() destLoc := target.AddXyz(dx, dy, dz) if destLoc == nil { // there is overflow with the translation, so do nothing return } player.PlaceHeldItem(*destLoc, held) } else { // Player is otherwise interacting with the block. blockType.Aspect.Interact(blockInstance, player) } return }