Latest Release | Documentation |
---|---|
PiCraft is a Julia package which allows control over the Minecraft World using code. It is compatible with the Minecraft: Pi Edition and the Java Edition with the help of RaspberryJamMod or RaspberryJuice.
Programming in the Minecraft world can be very beneficial in constructing large scale projects which can be automated and this can also be a fun way to introduce programming to children.
Some sample projects available in the documentation are:
.schematic
models without external software.Officially the ability to communicate with the Minecraft world is only available for the Minecraft: Pi edition. To get this to work on the Java edition we need to install a Mod. Detailed instructions can be found here
Download the appropriate Julia version for your system from here. If you are on a raspberry pi you should follow the instructions given in the documentation here.
]add PiCraft
OR
using Pkg
Pkg.add("https://github.com/JuliaBerry/PiCraft.jl")
Documentation for this package can be accessed at https://juliaberry.github.io/PiCraft.jl/ The documentation consists of a setup instructions, basic tutorials, examples and reference pages.
Load the PiCraft
package on the Julia console:
using PiCraft
On load, the library will attempt to connect to a running Minecraft world on localhost
. If Minecraft is not running, an error message will be printed. Subsequently, once Minecraft has been started, a connection can be forced by calling connectToWorld()
.
A 3-D coordinate system is used to describe the Minecraft world. Every position in the Minecraft World can be described with the help of 3 numbers. The X, Y and Z coordinates. These coordinates can be viewed by opening the Debug screen pressing the F3
key.
You can find and set your player's location:
1) Find Player position: getPos()
Tuple{Float64, Float64, Float64}
which contains the player's current coordinates.
2) Set Player position: setPos(pos::Tuple{Float64, Float64, Float64})
For example : setPos(getPos() .+ (0, 10, 0))
will teleport you 10m above you current position.
Blocks are the heart of Minecraft. The package provides the ability to modify blocks at specified coordinates.
Block
is an immutable datatype defined in src/blocks.jl
.
struct Block
id::Int
data::Int
end
The id
defines the type of block (like cobblestone, wool, wood,.etc) and the data
attribute defines additional characteristics of the block, on default every block has it data
set to 0
. For example, Wool's block id is 35, Block(35,0)
refers to a block of white wool. Different wool colors can be accessed by changing the data
attribute. Red Wool is Block(35, 14)
, Pink Wool is Block(35,6)
and so on. A complete reference can be found here in the documentation.
1) Place Block: setBlock(Tuple{Int, Int, Int}, block::Block)
setBlocks(p1::Tuple{Real, Real, Real}, p2::Tuple{Real, Real, Real}, block::Block)
getBlock(Tuple{Int,Int,Int})
While the getBlock
and setBlock
functions will accept Float64
as arguments these will be rounded and set to Int
as a block cannot be placed on non-integer coordinates.
Contributions, feature requests and bug reports are welcome! If you want to share some of your work or have a query you can post on the #PiCraft channel on julialang's slack (get an invite from https://slackinvite.julialang.org ) or open an issue on the PiCraft github page directly.