Skip to content

Programowanie i Minecraft

Przemysław Biecek edited this page Sep 3, 2016 · 11 revisions

Start

W oparciu o https://www.nostarch.com/programwithminecraft/.

Zaczynamy od instalacji

• Minecraft • Python 3 • Java Development Kit • Minecraft Python API • Spigot Minecraft Server

Tak jak opisano w https://www.nostarch.com/download/LTPWM_ch01_update_online.pdf

Pierwsze instrukcje

Kilka prostych funkcji jest tutaj

https://arghbox.wordpress.com/tag/minecraft-pi/

Łączymy się z R

con <- socketConnection(host="localhost", port = 4711, blocking=TRUE, server=FALSE, open="r+") resp <- writeLines("world.setBlocks(0,2,0,10,10,100,103)", con)

Komendy w mcpi_protocol_spec

https://www.raspberrypi.org/learning/getting-started-with-minecraft-pi/worksheet/

Robimy irysy


addBlock <- function(x, y, z, b, conn) {
  writeLines(paste0("world.setBlock(",round(x),",",round(y),",",round(z),",",round(b),")"), conn)
}

conn <- socketConnection(host="localhost", port = 4711, blocking=TRUE, server=FALSE, open="r+")
baseline <- 70

writeLines(paste0("world.setBlocks(0,0,0,100,",baseline,",100,7)"), conn)

for (i in 1:nrow(iris)) {
  addBlock(10*iris[i,"Sepal.Length"],
           baseline + 10*iris[i,"Sepal.Width"],
           10*iris[i,"Petal.Length"],
           13+as.numeric(iris[i,"Species"]), 
           conn)
}