Skip to content

Commit

Permalink
Add setPlayerRotation(), setPlayerPitch(), and setPlayerDirection()
Browse files Browse the repository at this point in the history
  • Loading branch information
kbroman committed Feb 11, 2019
1 parent 1c0a4e9 commit 845360f
Show file tree
Hide file tree
Showing 6 changed files with 193 additions and 2 deletions.
3 changes: 3 additions & 0 deletions NAMESPACE
Expand Up @@ -20,7 +20,10 @@ export(mc_close)
export(mc_connect)
export(setBlock)
export(setBlocks)
export(setPlayerDirection)
export(setPlayerPitch)
export(setPlayerPos)
export(setPlayerRotation)
export(spawnEntity)
importFrom(stats,setNames)
importFrom(utils,assignInMyNamespace)
Expand Down
5 changes: 3 additions & 2 deletions NEWS.md
Expand Up @@ -7,9 +7,10 @@

- A bunch of new functions available with the latest version of the
RaspberryJuice plugin (1.11): `getPlayerId()`, `getPlayerName()`,
`getEntityTypes()`
`getEntityTypes()`, `spawnEntity()`, `setDirection()`,
`setRotation()`, and `setPitch()`.

- Added `find_entity()` for search the output of `getEntityTypes()` to
- Added `find_entity()` for searching the output of `getEntityTypes()` to
find a particular type of entity. This is similar to `find_item()`.


Expand Down
95 changes: 95 additions & 0 deletions R/setPlayerOrientation.R
@@ -0,0 +1,95 @@
#' Set a player's rotation
#'
#' Set a player's rotation
#'
#' @md
#'
#' @param angle Angle of rotation (0-360)
#' @param id Player or entity ID
#'
#' @examples
#' \dontrun{
#' mc_connect()
#' getPlayerIds()
#' current <- getPlayerRotation(355)
#' setPlayerRotation(current + 90, 355)
#' }
#'
#' @seealso [getPlayerRotation()], [setPlayerPitch()], [setPlayerDirection()],
#' [setPlayerPos()]
#'
#' @export
#'

setPlayerRotation <- function(angle, id)
{

mc_sendreceive(merge_data("entity.setRotation", angle, id))

}


#' Set a player's pitch
#'
#' Set a player's pitch
#'
#' @md
#'
#' @param angle Angle of pitch (-90 is straight up and +90 is straight down)
#' @param id Player or entity ID
#'
#' @examples
#' \dontrun{
#' mc_connect()
#' getPlayerIds()
#' setPlayerPitch(45, 355)
#' }
#'
#' @seealso [getPlayerPitch()], [setPlayerRotation()], [setPlayerDirection()],
#' [setPlayerPos()]
#'
#' @export
#'

setPlayerPitch <- function(angle, id)
{

mc_send(merge_data("player.setPitch", angle, id))

}




#' Set a player's direction
#'
#' Set a player's direction
#'
#' @md
#'
#' @param x east/west direction
#' @param y up/down direction
#' @param z north/south direction
#' @param id Player or entity ID
#'
#' @details (`x`, `y`, `z`) define a unit vector to which the player will now point.
#'
#' @examples
#' \dontrun{
#' mc_connect()
#' getPlayerIds()
#' setPlayerDirection(45, 355)
#' }
#'
#' @seealso [getPlayerDirection()], [setPlayerRotation()], [setPlayerPitch()],
#' [setPlayerPos()]
#'
#' @export
#'

setPlayerDirection <- function(x, y, z, id)
{

mc_send(merge_data("player.setDirection", x, y, z, id))

}
35 changes: 35 additions & 0 deletions man/setPlayerDirection.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions man/setPlayerPitch.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions man/setPlayerRotation.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 845360f

Please sign in to comment.