| Title: | Extra Functions to Control Minecraft with RaspberryJuice API |
|---|---|
| Description: | Extra functions to illustrate the use of the miner package to control Minecraft with the RaspberryJuice API. |
| Authors: | Karl Broman [aut, cre], Brooke Anderson [aut], Gergely Daróczi [aut], Ali Zaidi [aut], Mario Inchiosa [aut], David Smith [aut], Felix Ling [aut] |
| Maintainer: | Karl Broman <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.3.6 |
| Built: | 2026-06-01 16:42:58 UTC |
| Source: | https://github.com/kbroman/craft |
Build a building with specified dimensions, with a foundation, walls, floorboards, carpet, and a door
buildBuilding( length = 8, width = 6, height = 5, foundation = 1, wall = 45, floorBoards = 125, carpet = 171, carpet_style = 11, gap = 0, player_id = NULL )buildBuilding( length = 8, width = 6, height = 5, foundation = 1, wall = 45, floorBoards = 125, carpet = 171, carpet_style = 11, gap = 0, player_id = NULL )
length |
Length of the building |
width |
Width of the building |
height |
Height of the building |
foundation |
ID for foundation blocks (1 = stone) |
wall |
ID for wall blocks (45 = brick) |
floorBoards |
ID for floor boards (125 = wood planks) |
carpet |
ID for carpet blocks (171 = carpet) |
carpet_style |
ID for carpet style (11 = blue) |
gap |
ID for gap blocks (0 = air) |
player_id |
Player ID |
None.
Felix Ling
Build a door in the wall (or any non-AIR block) that the player is looking at, opening in that same direction. If desired, also puts a pressure plate in front of and behind the door to automatically open it. Alternatively, can specify the coordinates and direction manually.
buildDoor( x = NULL, y = NULL, z = NULL, direction = NULL, doorBlock = 64, pressurePlate = TRUE, pressurePlateBlock = 70, player_id = NULL )buildDoor( x = NULL, y = NULL, z = NULL, direction = NULL, doorBlock = 64, pressurePlate = TRUE, pressurePlateBlock = 70, player_id = NULL )
x |
x-coordinate of where to put the door. If any of |
y |
y-coordinate of where to put the door. |
z |
z-coordinate of where to put the door. |
direction |
The compass direction the door should open in. |
doorBlock |
The material to create the door out of. |
pressurePlate |
Whether to put pressure plates around the door. |
pressurePlateBlock |
The material to create the pressure plate out of. |
player_id |
Player ID |
For door blocks, see mc::find_item("door"); they include
64 for oak and 71 for iron. Pressure place blocks include 70
for stone and 72 for wood.
Felix Ling
Build a fence around a square area, adding a gate in a random side, and filling the ground underneath to make a uniform height
buildFence( length = 8, fenceBlock = 85, gateBlock = 107, foundationBlock = 1, player_id = NULL )buildFence( length = 8, fenceBlock = 85, gateBlock = 107, foundationBlock = 1, player_id = NULL )
length |
Length and width of fence (must be >= 3) |
fenceBlock |
Block ID for fence |
gateBlock |
Block ID for gate in fence |
foundationBlock |
Block ID for foundation (to get everything to a uniform height) |
player_id |
Player ID; fence centered at player's current position |
None.
Render the R logo in minecraft
buildRlogo( bottomleft, height = 80, width = NULL, dir = c("north", "south", "east", "west"), blue_id = 35, blue_style = 11, gray_id = 35, gray_style = 8 )buildRlogo( bottomleft, height = 80, width = NULL, dir = c("north", "south", "east", "west"), blue_id = 35, blue_style = 11, gray_id = 35, gray_style = 8 )
bottomleft |
Bottom left position ( |
height |
Height of R logo in blocks |
width |
Width of R logo in blocks (if not provided, determined to preserve aspect ratio |
dir |
Which direction should the logo go? |
blue_id |
Block ID for blue blocks |
blue_style |
Block style for blue blocks |
gray_id |
Block ID for gray blocks |
gray_style |
Block style for gray blocks |
## Not run: library(miner) mc_connect() pos <- getPlayerPos(getPlayerIds()[1]) buildRlogo(pos + c(5, 10, 5)) # used stained glass blue_glass <- find_item("Blue Stained Glass") gray_glass <- find_item("Gray Stained Glass") buildRlogo(pos + c(5, 10, 5), blue_id=blue_glass[2], blue_style=blue_glass[3], gray_id=gray_glass[2], gray_style=gray_glass[3]) ## End(Not run)## Not run: library(miner) mc_connect() pos <- getPlayerPos(getPlayerIds()[1]) buildRlogo(pos + c(5, 10, 5)) # used stained glass blue_glass <- find_item("Blue Stained Glass") gray_glass <- find_item("Gray Stained Glass") buildRlogo(pos + c(5, 10, 5), blue_id=blue_glass[2], blue_style=blue_glass[3], gray_id=gray_glass[2], gray_style=gray_glass[3]) ## End(Not run)
Build stairs up or down from player position in the specified direction. For now, width should be odd so that we can have a central staircase and extend to the right and left of it to widen it.
buildStairs( player_id = NULL, down = TRUE, stopHeight = 0, stopOnNotAir = TRUE, width = 1, stairId = 109, blockId = 98, blockStyle = 0, buildBlock = TRUE )buildStairs( player_id = NULL, down = TRUE, stopHeight = 0, stopOnNotAir = TRUE, width = 1, stairId = 109, blockId = 98, blockStyle = 0, buildBlock = TRUE )
player_id |
Player ID |
down |
Whether to build stairs downward. If false, builds upward |
stopHeight |
The height at which to stop building. |
stopOnNotAir |
Whether to stop if about to build where something exists. |
width |
How wide to build the staircase. MUST BE AN ODD NUMBER |
stairId |
The block ID for the stairs. |
blockId |
The block ID for the block underneath each stair. Can set to AIR if you don't want this block. |
blockStyle |
The block style for the block underneath each stair. |
buildBlock |
If false, don't put the blocks under the stairs |
For stairs block IDs, see miner::find_item("stairs"); they include
53 for oak, 67 for cobblestone, and 108 for brick. The corresponding blocks for these materials are 5 for oak, 4 for cobblestone, and 45 for brick
Clear out a cube around a player
clearSpace(length, player_id = NULL)clearSpace(length, player_id = NULL)
length |
length of each side of the cube to be cleared |
player_id |
player's entity id |
Felix Ling
miner::setBlocks(), miner::getPlayerPos()
## Not run: id <- getPlayerIds()[1] clearSpace(5, id) ## End(Not run)## Not run: id <- getPlayerIds()[1] clearSpace(5, id) ## End(Not run)
Make a solid or hollow cube.
cube( xlen = 10, ylen = 10, zlen = 10, blockid = 1, styleid = 0, fill = FALSE, offset = c(0, -1, 0), playerid = miner::getPlayerIds(), pos, xlim, ylim, zlim )cube( xlen = 10, ylen = 10, zlen = 10, blockid = 1, styleid = 0, fill = FALSE, offset = c(0, -1, 0), playerid = miner::getPlayerIds(), pos, xlim, ylim, zlim )
xlen |
integer. Cube length. |
ylen |
integer. Cube hight. |
zlen |
integer. Cube depth. |
blockid |
integer. Block type. |
styleid |
integer. Block style. |
fill |
logical. If TRUE then solid. If FALSE then hollow. |
offset |
vector of length three. How many units to offset the cube from |
playerid |
integer of length one. Defaults to player id in solo play. Set explicitly in multi play. |
pos |
vector of length three. Defines the corner of the cube. Defaults to the player's position. |
xlim |
vector of length two. Defines the lower and upper cuttoff points to truncate the cube. |
ylim |
vector of length two. Defines the lower and upper cuttoff points to truncate the cube. |
zlim |
vector of length two. Defines the lower and upper cuttoff points to truncate the cube. |
Builds a cube or cuboid with the corner at the player's position. By default, the cube is hollow, but you can also use fill=TRUE to create a solid cube. The players position is determined by miner::getPlayerPos(). You can you can reposition the cube with the offset command. Use xlim, ylim, zlim to truncate the cube to create a fence or wall. This function will return the cube origin.
sphere() to create a sphere.
## Not run: # Stone cube 10x10x10 cube(pos = c(0, 0, 0)) # Erase cube cube(blockid = 0, pos = c(0, 0, 0)) # Stone fence cube(ylim = c(2, 3), offset = c(0, -2, 0)) ## End(Not run)## Not run: # Stone cube 10x10x10 cube(pos = c(0, 0, 0)) # Erase cube cube(blockid = 0, pos = c(0, 0, 0)) # Stone fence cube(ylim = c(2, 3), offset = c(0, -2, 0)) ## End(Not run)
Give a player revsese Elsa powers, to clean up after running elsafy(): when she walks over ice, it turns back to water.
de_elsafy(player_id = NULL, water = 8, ice = 174, delay = 0.05)de_elsafy(player_id = NULL, water = 8, ice = 174, delay = 0.05)
player_id |
Player's entity ID |
water |
Item IDs for water |
ice |
Item ID for ice |
delay |
Delay (in seconds) between calls to the minecraft server |
None.
## Not run: # Runs in an infinite loop; press ctrl-C to stop. de_elsafy(215) ## End(Not run)## Not run: # Runs in an infinite loop; press ctrl-C to stop. de_elsafy(215) ## End(Not run)
Implements Bresenham's line-drawing algorithm in 3D space. Takes two points, where each point is a vector of 3 coordinates, and constructs a line between the two points.
drawLine(p0, p1, id = 1, style = 0)drawLine(p0, p1, id = 1, style = 0)
p0 |
vector of the first endpoint |
p1 |
vector of the second endpoint |
id |
Minecraft block ID to draw the line with |
style |
Minecraft block style ID to draw the line with (e.g., color) |
None
Felix Ling, based on python code in a gist by theJollySin that has since been removed
Give a player Elsa powers: when she walks on water, it turns to ice.
elsafy(player_id = NULL, water = c(8, 9), ice = 174, delay = 0.02)elsafy(player_id = NULL, water = c(8, 9), ice = 174, delay = 0.02)
player_id |
Player's entity ID |
water |
Vector of item IDs for different kinds of water |
ice |
Item ID for ice |
delay |
Delay (in seconds) between calls to the minecraft server |
None.
## Not run: # Runs in an infinite loop; press ctrl-C to stop. elsafy(215) ## End(Not run)## Not run: # Runs in an infinite loop; press ctrl-C to stop. elsafy(215) ## End(Not run)
Find a set of Minecraft items by name or ID. If querying by ID, the search can also specify item styles.
find_items(name = NULL, id = NULL, style = 0)find_items(name = NULL, id = NULL, style = 0)
name |
Vector of character string with the names of Minecraft
items (specify either |
id |
Vector of numeric or character strings with the ID of a
Minecraft item (specify either |
style |
Vector of numeric or character string with the style
of a Minecraft item (use this argument only if querying by |
If name is provided, we first look to see whether there
is an exact match to the name column in mc_items. If there
is, we return that row. If not, we don't include the results.
If instead id is provided, we return the row with that id
and style==0 (or whatever style was provided).
Data frame with a row for each item found in mc_items,
provided the matches are unique.
miner::find_item(), miner::mc_items
flower_names <- c("Chorus Flower", "Peony", "Rose Bush", "Lilac", "Sunflower", "Pink Tulip", "White Tulip", "Orange Tulip", "Red Tulip", "Oxeye Daisy", "Allium", "Dandelion", "Poppy", "Blue Orchid", "Peony") flowers <- find_items(flower_names)flower_names <- c("Chorus Flower", "Peony", "Rose Bush", "Lilac", "Sunflower", "Pink Tulip", "White Tulip", "Orange Tulip", "Red Tulip", "Oxeye Daisy", "Allium", "Dandelion", "Poppy", "Blue Orchid", "Peony") flowers <- find_items(flower_names)
Font set data used to construct text from blocks within minecraft
data(font_sets)data(font_sets)
An object of class list of length 12.
The dataset is a list of fonts with each font being represented as a list with
charset - a vector of character strings with the characters present in the font
png - a matrix of 0's and 1's grabbed from the PNG file for the font using the package
imager.
http://uzebox.org/wiki/index.php?title=Font_Bitmaps
data(font_sets)data(font_sets)
Determine blocks within a cuboid
getBlocksV(pos0, pos1)getBlocksV(pos0, pos1)
pos0 |
Vector (x,y,z) of first position |
pos1 |
Vector (x,y,z) of second position |
An 3-D array of integers where each integer gives the ID of the type of a block in the cuboid.
## Not run: library(miner) mc_connect() p <- getPlayerPos() getBlocksV(p - c(0, 1, 0), p - c(0, 5, 0)) ## End(Not run)## Not run: library(miner) mc_connect() p <- getPlayerPos() getBlocksV(p - c(0, 1, 0), p - c(0, 5, 0)) ## End(Not run)
Determine block at position (x,y,z)
getBlockV(pos, include_style = TRUE)getBlockV(pos, include_style = TRUE)
pos |
Vector (x,y,z) of position |
include_style |
A logical value of whether the block's style should also be included in the output (defaults to TRUE). |
A numeric vector of length one or two with the type ID
and style, if include_style is TRUE, of the block
at position (x, y, z). You can use find_item() to
find the name of the block type based on this returned ID.
## Not run: library(miner) mc_connect() p <- getPlayerPos() getBlockV(p + c(0, -1, 0)) ## End(Not run)## Not run: library(miner) mc_connect() p <- getPlayerPos() getBlockV(p + c(0, -1, 0)) ## End(Not run)
Get player heading
getHeading(player_id)getHeading(player_id)
player_id |
An integer with the player id |
Player heading in degrees
## Not run: getHeading(myid) ## End(Not run)## Not run: getHeading(myid) ## End(Not run)
Get the direction that a player is facing as a compass bearing (north, south, east, west, etc.)
getPlayerCompass(player_id = NULL, n_compass_points = c("16", "8", "4"))getPlayerCompass(player_id = NULL, n_compass_points = c("16", "8", "4"))
player_id |
Numeric ID for the player |
n_compass_points |
Number of compass points to use (4, 8, or 16) |
A character string representing the player's direct as a compass bearing
## Not run: library(miner) getPlayerIds() getPlayerRotation(355) getPlayerCompass(355, 8) ## End(Not run)## Not run: library(miner) getPlayerIds() getPlayerRotation(355) getPlayerCompass(355, 8) ## End(Not run)
Make an ice tower of a random height wherever you hit.
ice_towers( player_id, block_id = 212, block_style = 0, max_height = 4, delay = 0.2 )ice_towers( player_id, block_id = 212, block_style = 0, max_height = 4, delay = 0.2 )
player_id |
Player's entity ID |
block_id |
Item ID (id=212 for frosted ice) |
block_style |
Item style |
max_height |
Maximum height of ice tower |
delay |
Delay (in seconds) between calls to the minecraft server |
None.
Only right clicks with an iron sword will work.
## Not run: # connect to minecraft miner::mc_connect() # Need to use ctrl-c to stop ice_towers( getPlayerIds()[1] ) ## End(Not run)## Not run: # connect to minecraft miner::mc_connect() # Need to use ctrl-c to stop ice_towers( getPlayerIds()[1] ) ## End(Not run)
Set player heading to match the direction the player is facing
initHeading(player_id)initHeading(player_id)
player_id |
An integer with the player id |
## Not run: initHeading(myid) ## End(Not run)## Not run: initHeading(myid) ## End(Not run)
Check the block type (if any) ahead of the player. Look in the direction of the player heading at the specified distance.
lookForward(player_id, distance = 1)lookForward(player_id, distance = 1)
player_id |
An integer with the player id |
distance |
The distance to look |
## Not run: lookForward(myid) ## End(Not run)## Not run: lookForward(myid) ## End(Not run)
Remove a scatterplot created with mc_plot() by replacing the blocks with air.
mc_clearplot( lowerleft, x, y, xlab = "x", ylab = "y", width = 120, height = 120, dir = c("east", "west", "north", "south", "up", "down"), top = c("up", "north", "south", "east", "west", "down") )mc_clearplot( lowerleft, x, y, xlab = "x", ylab = "y", width = 120, height = 120, dir = c("east", "west", "north", "south", "up", "down"), top = c("up", "north", "south", "east", "west", "down") )
lowerleft |
Vector of length 3, specifying the position of the lower-left corner of the plot. |
x |
Vector of x values |
y |
Vector of y values |
xlab |
x-axis label |
ylab |
y-axis label |
width |
Width of plot in blocks |
height |
Height of plot in blocks |
dir |
Direction the plot will go |
top |
Direction for the top of the plot |
None.
## Not run: v <- mc_plot(x=iris$Sepal.Length, y=iris$Sepal.Width, group=iris$Species, xlab="Sepal.Length", ylab="Sepal.Width") Sys.sleep(10) mc_clearplot(v, x=iris$Sepal.Length, y=iris$Sepal.Width, xlab="Sepal.Length", ylab="Sepal.Width") ## End(Not run)## Not run: v <- mc_plot(x=iris$Sepal.Length, y=iris$Sepal.Width, group=iris$Species, xlab="Sepal.Length", ylab="Sepal.Width") Sys.sleep(10) mc_clearplot(v, x=iris$Sepal.Length, y=iris$Sepal.Width, xlab="Sepal.Length", ylab="Sepal.Width") ## End(Not run)
Generates a maze in front of a player
mc_maze(n = 5, player_id = NULL)mc_maze(n = 5, player_id = NULL)
n |
size of the maze |
player_id |
optional player id |
Poll the chat window for maze generator commands and spawn mazes right in front of the player
mc_mazer()mc_mazer()
Make a scatterplot within Minecraft
mc_plot( lowerleft = miner::getPlayerPos() + c(0, 5, 5), x, y, xlab = "x", ylab = "y", group = NULL, width = 120, height = 120, dir = c("east", "west", "north", "south", "up", "down"), top = c("up", "north", "south", "east", "west", "down"), block_colors = list(gray = c(35, 8), white = c(35, 0), black = c(35, 15), colors = cbind(35, c(9, 14, 5))) )mc_plot( lowerleft = miner::getPlayerPos() + c(0, 5, 5), x, y, xlab = "x", ylab = "y", group = NULL, width = 120, height = 120, dir = c("east", "west", "north", "south", "up", "down"), top = c("up", "north", "south", "east", "west", "down"), block_colors = list(gray = c(35, 8), white = c(35, 0), black = c(35, 15), colors = cbind(35, c(9, 14, 5))) )
lowerleft |
Vector of length 3, specifying the position of the lower-left corner of the plot. |
x |
Vector of x values |
y |
Vector of y values |
xlab |
x-axis label |
ylab |
y-axis label |
group |
Vector of groups for coloring the points |
width |
Width of plot in blocks |
height |
Height of plot in blocks |
dir |
Direction the plot will go |
top |
Direction for the top of the plot |
block_colors |
A list of block IDs and styles to denote the colors to be used; needs to contain
|
Returns the input lowerleft.
## Not run: v <- mc_plot(getPlayerPos()+c(0, 5, 5), x=iris$Sepal.Length, y=iris$Sepal.Width, group=iris$Species, xlab="Sepal.Length", ylab="Sepal.Width") ## End(Not run)## Not run: v <- mc_plot(getPlayerPos()+c(0, 5, 5), x=iris$Sepal.Length, y=iris$Sepal.Width, group=iris$Species, xlab="Sepal.Length", ylab="Sepal.Width") ## End(Not run)
Hold a race, started in the chat, and see who moves the farthest
mc_race(time = 10)mc_race(time = 10)
time |
Length of race (in seconds) |
Return the player_id of whoever moves the farthest
## Not run: library(miner) mc_connect() whoisfastest() ## End(Not run)## Not run: library(miner) mc_connect() whoisfastest() ## End(Not run)
Look for chat messages that start with "R " and then evaluate the rest as an R expression.
mc_Reval(player_id = NULL, delay = 1)mc_Reval(player_id = NULL, delay = 1)
player_id |
Player's entity ID |
delay |
Delay (in seconds) between checks of the chat messages |
The function looks at chat messages in Minecraft. For messages
that begin "R ", the rest of the message is treated as an R expression
and is evaluated.
The default is to evaluate any such R code. If player_id is
specified, only messages from that player are considered.
Use extreme caution with this; if you don't specify
player_id correctly, you could be letting others execute
code on your computer and so giving them the opportunity to do
bad things.
None.
## Not run: # runs in an infinite loop; use ctrl-c to stop mc_Reval(212) ## End(Not run)## Not run: # runs in an infinite loop; use ctrl-c to stop mc_Reval(212) ## End(Not run)
Listen for "Who am I" on minecraft chat, and respond with the player's entity ID.
mc_whoami(delay = 1, max_time = Inf)mc_whoami(delay = 1, max_time = Inf)
delay |
Delay (in seconds) between checks of the chat messages |
max_time |
Maximum amount of time (in seconds) before quitting. |
Uses base::grepl(), ignoring case, to look for
"who am I" in the chat messages, and prints the player ID of
any player who posts a chat message containing that phrase.
A vector of player IDs
## Not run: #' will run for 15 seconds mc_whoami(max_time=15) ## End(Not run)## Not run: #' will run for 15 seconds mc_whoami(max_time=15) ## End(Not run)
Move the player in the direction of the player heading
moveForward(player_id, distance = 1)moveForward(player_id, distance = 1)
player_id |
An integer with the player id |
distance |
The distance to move the player |
## Not run: initHeading(myid) moveForward(myid, 0.5) ## End(Not run)## Not run: initHeading(myid) moveForward(myid, 0.5) ## End(Not run)
Play guess-a-number game in the chat
num_guess(max_num = 100, delay = 0.2)num_guess(max_num = 100, delay = 0.2)
max_num |
Maximum number |
delay |
Delay (in seconds) between calls to the minecraft server |
The correct number
miner::chatPost(), miner::getChatPosts()b
## Not run: # connect to minecraft miner::mc_connect() # Need to use ctrl-c to stop early num_guess() ## End(Not run)## Not run: # connect to minecraft miner::mc_connect() # Need to use ctrl-c to stop early num_guess() ## End(Not run)
Matrix corresponding to a version of the R logo
data(Rlogo)data(Rlogo)
An object of class cimg (inherits from imager_array, numeric) of dimension 800 x 700 x 1 x 1.
The dataset is a matrix of pixel colors for a reduced-size version of the R logo, with 1=white, 2=gray, and 3=blue.
https://www.r-project.org/logo/"
data(Rlogo) image(Rlogo[,ncol(Rlogo):1], col=c("white", "gray", "blue"), bty="n", xaxt="n", yaxt="n")data(Rlogo) image(Rlogo[,ncol(Rlogo):1], col=c("white", "gray", "blue"), bty="n", xaxt="n", yaxt="n")
Place blocks of a random mixture of types in the cuboid with opposite corners at the positions (x0, y0, z0) and (x1, y1, z1).
setBlocksMix(x0, y0, z0, x1, y1, z1, ids, styles = NULL, prob = NULL)setBlocksMix(x0, y0, z0, x1, y1, z1, ids, styles = NULL, prob = NULL)
x0 |
A numeric string with north/south position of one corner |
y0 |
A numeric string with height of one corner |
z0 |
A numeric string with east/west position of one corner |
x1 |
A numeric string with north/south position of opposite corner |
y1 |
A numeric string with height of opposite corner |
z1 |
A numeric string with east/west position of opposite corner |
ids |
Vector of block ids |
styles |
Vector of block styles (same length as |
prob |
Probabilities for each block type (same length as |
This is like miner::setBlocks() but placing a random
mixture of blocks.
None.
Felix Ling
miner::setBlock(), miner::setBlocks(), setBlocksStyle()
## Not run: mc_connect() items <- find_item("stained glass$") pos <- whereami() setBlocksMix(pos[1]+2, pos[2], pos[3]+2, pos[1]+2, pos[2]+5, pos[3]+2, ids=items[,2], styles=items[,3]) ## End(Not run)## Not run: mc_connect() items <- find_item("stained glass$") pos <- whereami() setBlocksMix(pos[1]+2, pos[2], pos[3]+2, pos[1]+2, pos[2]+5, pos[3]+2, ids=items[,2], styles=items[,3]) ## End(Not run)
Place a cuboid of blocks of a random mixture of types
setBlocksMixV(pos0, pos1, ids, styles = NULL, prob = NULL)setBlocksMixV(pos0, pos1, ids, styles = NULL, prob = NULL)
pos0 |
Vector (x,y,z) of first position |
pos1 |
Vector (x,y,z) of second position |
ids |
Vector of block IDs |
styles |
Vector of block styles |
prob |
Probabilities for each block type |
None.
## Not run: library(miner) mc_connect() p <- getPlayerPos() setBlocksStyleV(p + c(0, 1, 0), p + c(0, 5, 0), 95, 2) ## End(Not run)## Not run: library(miner) mc_connect() p <- getPlayerPos() setBlocksStyleV(p + c(0, 1, 0), p + c(0, 5, 0), 95, 2) ## End(Not run)
Place blocks of a single type (specified by id) in the cuboid
with opposite corners at the positions (x0, y0, z0) and (x1, y1, z1).
setBlocksStyle(x0, y0, z0, x1, y1, z1, id, style = 0)setBlocksStyle(x0, y0, z0, x1, y1, z1, id, style = 0)
x0 |
A numeric string with north/south position of one corner |
y0 |
A numeric string with height of one corner |
z0 |
A numeric string with east/west position of one corner |
x1 |
A numeric string with north/south position of opposite corner |
y1 |
A numeric string with height of opposite corner |
z1 |
A numeric string with east/west position of opposite corner |
id |
Block id |
style |
Block style |
This is just like miner::setBlocks() but with an
added style argument.
None.
Felix Ling
miner::setBlock(), miner::setBlocks()
## Not run: mc_connect() item <- find_item("Blue Stained Glass") pos <- whereami() setBlocksStyle(pos[1]+2, pos[2], pos[3]+2, pos[1]+2, pos[2]+5, pos[3]+2, id=item[2], style=item[3]) ## End(Not run)## Not run: mc_connect() item <- find_item("Blue Stained Glass") pos <- whereami() setBlocksStyle(pos[1]+2, pos[2], pos[3]+2, pos[1]+2, pos[2]+5, pos[3]+2, id=item[2], style=item[3]) ## End(Not run)
Place a cuboid of blocks of a single type, allowing a style parameter
setBlocksStyleV(pos0, pos1, id, style)setBlocksStyleV(pos0, pos1, id, style)
pos0 |
Vector (x,y,z) of first position |
pos1 |
Vector (x,y,z) of second position |
id |
Block ID |
style |
Block style |
None.
## Not run: library(miner) mc_connect() p <- getPlayerPos() setBlocksStyleV(p + c(0, 1, 0), p + c(0, 5, 0), 95, 2) ## End(Not run)## Not run: library(miner) mc_connect() p <- getPlayerPos() setBlocksStyleV(p + c(0, 1, 0), p + c(0, 5, 0), 95, 2) ## End(Not run)
Place a cuboid of blocks of a single type
setBlocksV(pos0, pos1, id)setBlocksV(pos0, pos1, id)
pos0 |
Vector (x,y,z) of first position |
pos1 |
Vector (x,y,z) of second position |
id |
Block ID |
None.
## Not run: library(miner) mc_connect() p <- getPlayerPos() setBlocksV(p + c(0, 1, 0), p + c(0, 5, 0), 46) ## End(Not run)## Not run: library(miner) mc_connect() p <- getPlayerPos() setBlocksV(p + c(0, 1, 0), p + c(0, 5, 0), 46) ## End(Not run)
Place a block at position (x,y,z) by type id
setBlockV(pos, id, style = 0)setBlockV(pos, id, style = 0)
pos |
Vector (x,y,z) of position |
id |
Block ID |
style |
Block style |
None.
## Not run: library(miner) mc_connect() p <- getPlayerPos() setBlockV(p + c(0, 5, 0), 46) ## End(Not run)## Not run: library(miner) mc_connect() p <- getPlayerPos() setBlockV(p + c(0, 5, 0), 46) ## End(Not run)
Set the direction in which moveForward will move the player. The heading is measured in degrees. A heading of 180 or -180 degreees is towards North or negative z A heading of 0 degreees is towards South or positive z A heading of 270 or -90 degreees is towards East or positive x A heading of 90 degrees is towards West or negative x
setHeading(player_id, new_heading)setHeading(player_id, new_heading)
player_id |
An integer with the player id |
new_heading |
A numeric with the direction to head forward |
## Not run: setHeading(myid, 0) ## End(Not run)## Not run: setHeading(myid, 0) ## End(Not run)
Rotate player to direction (x,y,z) specified as a vector
setPlayerDirectionV(pos, player_id = NULL)setPlayerDirectionV(pos, player_id = NULL)
pos |
Vector (x,y,z) giving position |
player_id |
Player ID |
None.
## Not run: library(miner) mc_connect() setPlayerDirectionV( c(1, 0, 1) ) ## End(Not run)## Not run: library(miner) mc_connect() setPlayerDirectionV( c(1, 0, 1) ) ## End(Not run)
Move player to position (x,y,z) specified as a vector
setPlayerPosV(pos, player_id = NULL, tile = FALSE)setPlayerPosV(pos, player_id = NULL, tile = FALSE)
pos |
Vector (x,y,z) giving position |
player_id |
Player ID |
tile |
If TRUE, truncation position to integers |
None.
## Not run: library(miner) mc_connect() pos <- getPlayerPos() setPlayerPosV(pos + c(0, 5, 0)) ## End(Not run)## Not run: library(miner) mc_connect() pos <- getPlayerPos() setPlayerPosV(pos + c(0, 5, 0)) ## End(Not run)
Make a solid or hollow sphere with the player at the center.
sphere( radius = 15, blockid = 20, styleid = 0, fill = FALSE, offset = c(0, 0, 0), playerid = miner::getPlayerIds(), pos, xlim, ylim, zlim )sphere( radius = 15, blockid = 20, styleid = 0, fill = FALSE, offset = c(0, 0, 0), playerid = miner::getPlayerIds(), pos, xlim, ylim, zlim )
radius |
integer. Specifies the radius of the sphere. |
blockid |
integer. Block type to be used. |
styleid |
integer. Block style to be used. |
fill |
logical. Should the sphere be solid or hollow. Defaults to hollow. |
offset |
vector of length three. Defines where to place the sphere with respect to |
playerid |
integer of length one. Defaults to player id in solo play. Set explicitly in multi play. |
pos |
vector of length three. Defines the center of the sphere. Defaults to the player id position. |
xlim |
vector of length two. Defines the lower and upper cuttoff points to truncate the sphere. |
ylim |
vector of length two. Defines the lower and upper cuttoff points to truncate the sphere. |
zlim |
vector of length two. Defines the lower and upper cuttoff points to truncate the sphere. |
Builds a sphere (or a truncated sphere) around the players current position. By default, the sphere is hollow, but you can also use fill=TRUE to create a solid sphere. The players position is determined by miner::getPlayerPos(). You can you can reposition the sphere with the offset command. Use xlim, ylim, zlim to truncate the sphere. This function will return the sphere's origin.
cube() to create a cube.
## Not run: # Hollow glass sphere of size 15 sphere(pos = c(0, 0, 0)) # Erase sphere sphere(blockid = 0, pos = c(0, 0, 0)) # Glass dome sphere(ylim = c(0, 15)) ## End(Not run)## Not run: # Hollow glass sphere of size 15 sphere(pos = c(0, 0, 0)) # Erase sphere sphere(blockid = 0, pos = c(0, 0, 0)) # Glass dome sphere(ylim = c(0, 15)) ## End(Not run)
Use a positive angle value to rotate to the left. Use a negative angle to rotate to the right. The player does not turn in the game; rather, the heading for subsequent movement commands is rotated.
turnLeft(player_id, angle = 90)turnLeft(player_id, angle = 90)
player_id |
An integer with the player id |
angle |
The number of degrees to rotate left |
## Not run: turnLeft(myid) ## End(Not run)## Not run: turnLeft(myid) ## End(Not run)
Get rounded player position
whereami(player_id = NULL, tile = FALSE)whereami(player_id = NULL, tile = FALSE)
player_id |
Integer giving the ID of a player |
tile |
If TRUE, truncate the result to integers |
This is just like miner::getPlayerPos() but with tile=TRUE
being the default.
Felix Ling
## Not run: mc_connect() whereami() ## End(Not run)## Not run: mc_connect() whereami() ## End(Not run)
Write some text in minecraft, using blocks
write_text( text, lowerleft, font = c("4x5", "4x6", "4x8", "6x6", "8x6", "6x8", "8x8", "4x12", "6x12", "8x12", "8x16", "16x16"), id = 1, style = 0, dir = c("north", "south", "east", "west", "up", "down"), top = c("up", "east", "west", "north", "south", "down") )write_text( text, lowerleft, font = c("4x5", "4x6", "4x8", "6x6", "8x6", "6x8", "8x8", "4x12", "6x12", "8x12", "8x16", "16x16"), id = 1, style = 0, dir = c("north", "south", "east", "west", "up", "down"), top = c("up", "east", "west", "north", "south", "down") )
text |
A character string to be written in blocks |
lowerleft |
Vector of length 3 representing the location for the lower-left corner for the text. |
font |
Font size to use |
id |
Block type to use to write the text |
style |
Block style to use to write the text |
dir |
Direction the text should run |
top |
Direction that the top of the text should point |
None
## Not run: library(miner) v <- getPlayerPos() write_text("Hello!", v+c(5,3,0), font="4x8") ## End(Not run)## Not run: library(miner) v <- getPlayerPos() write_text("Hello!", v+c(5,3,0), font="4x8") ## End(Not run)