本文整理匯總了Golang中chunkymonkey/gamerules.IPlayerClient.PlaceHeldItem方法的典型用法代碼示例。如果您正苦於以下問題:Golang IPlayerClient.PlaceHeldItem方法的具體用法?Golang IPlayerClient.PlaceHeldItem怎麽用?Golang IPlayerClient.PlaceHeldItem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類chunkymonkey/gamerules.IPlayerClient
的用法示例。
在下文中一共展示了IPlayerClient.PlaceHeldItem方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: reqInteractBlock
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
}