Using Clojure we create interesting 3D shapes in Minecraft to the beat of music generated from Overtone.
We achieve this by embedding a Clojure REPL inside a Java Minecraft server which loads Overtone and connects to an external Supercollider instance (What Overtone uses for sound).
- Java Minecraft server Craftbukkit/Spigot: http://www.spigotmc.org/
- Minecraft client (requires purchase) https://minecraft.net
- clj-minecraft Bukkit plugin: https://github.com/josephwilk/clj-minecraft
- Overtone (patched): https://github.com/josephwilk/overtone/tree/minecraft_overtone
- MUD (useful helpers for Overtone): https://github.com/josephwilk/mud
- Supercollider: http://supercollider.sourceforge.net
(Dependent on your IDE of choice)
- Emacs – cider: https://github.com/clojure-emacs/cider
- Vim – fireplace: https://github.com/tpope/vim-fireplace
Building the world
We need to install Spigot which is an optimized version of the Craftbukkit Java Minecraft server and install clj-minecraft project as a plugin. Things are complicated by Bukkit no longer being registered in Maven.
Read through the Makefile install:
If your happy clone and run:
Bukkit + clj-minecraft will be installed for you.
Running the world
You will need to edit the
minecraft/eula.txt indicating you agree with the license. Then you can run your Minecraft server:
Seeing the world
Buy and install a Minecraft client: https://minecraft.net
Select >“Multiplayer” >“Direct connect” and enter the “Server Address” as localhost.
Bring music to the world
Install and Boot Supercollider
1 2 3 4 5 6 7
Speaking to the Minecraft REPL
clj-minecraft opens a REPL on localhost port 4005. Using emacs and
cider connect to this REPL instance.
Boot and connect Overtone:
1 2 3
MUD we have some useful wrappers around Overtone for scheduling functions on beats.
To coordinate graphics and sound we schedule both within a single function.
1 2 3 4 5 6 7 8 9 10
Most functions that change the state of the Minecraft world need to be run in the main GUI thread. To achieve this we wrap any state changing function within
For example a function to place a block into the Minecraft world:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
For further documentation of whats possible, the Bukkit Java docs: https://hub.spigotmc.org/javadocs/bukkit/
clj-minecaft has lots of helpers + examples: https://github.com/CmdrDats/clj-minecraft/tree/master/src/cljminecraft
Create, play and share all the crazy things you can come up with using Clojure and Minecraft.
For more live programming music and sound checkout my performances as Repl Electric: http://www.repl-electric.com
Built on the back of lots of great open source projects. Thanks to the Craftbukkit/Spigot contributors, @CmdrDats for clj-minecraft and @samaaron for Overtone and inspiring this crazy journey with the musical Sonic Pi (which supports combining music and Minecraft on the RaspberryPi).