Skip to content

Instantly share code, notes, and snippets.

@revodavid
Created June 2, 2017 14:54
Show Gist options
  • Select an option

  • Save revodavid/feab4dd718124caede88f147e5e8ffa4 to your computer and use it in GitHub Desktop.

Select an option

Save revodavid/feab4dd718124caede88f147e5e8ffa4 to your computer and use it in GitHub Desktop.
Function to detect when a Minecraft player is standing in a hole. (Required miner package.)
findMyId <- function() {
# Requires https://github.com/ROpenSciLabs/miner
# dig a hole one block deep and stand in it to be found
# returns the IDs of players standing in a hole
ids <- getPlayerIds()
holehiders <- NULL
for (id in ids) {
pos <- getPlayerPos(id, tile=TRUE)
surround <- getBlocks(pos[1]-1,pos[2],pos[3]-1, pos[1]+1, pos[2], pos[3]+1)[,1,]
inhole <- all(c(surround[1,2],surround[2,1],surround[2,3], surround[3,2])!=0)
if(inhole) holehiders <- c(holehiders,id)
}
holehiders
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment