Minecraft Environmental Lighting Experiment
Unless you live under a rock (or don’t have any kids) you’ll know that Minecraft is a hugely popular video game. The game presents itself as a 3D world where you mine for resources and then create structures with the resources you collect. The game can be played by one person, or you can play with hundreds of thousands people over the Internet.
My son has been playing for a couple of years now. He and his friends spend hours every week creating amazing structures in this 3D world.
When my son and I saw the first Internet promotional video for the Phillips Hue, we immediately thought that it would be really cool to “hack” the lights to be in sync with the day/night cycle in Minecraft. So in the daylight hours, the lights would be on and emitting out a nice daylight colour. while the sun sets and rises, the lights would fade through a cycle of warm colours. And of course when it was night time, the lights would be dark.
Last week while I was at an Apple Store, I picked up the Phillips Hue Starter Set which includes 3 LED bulbs and the wireless hub that controls the bulbs. The Starter Set is not cheap - it costs $199, and extra bulbs run at $59. Setup is really easy - plugin the wireless controller, screw in the bulbs and download the free Phillips Hue app from the AppStore and your ready to being. The bulbs themselves are very nice - the range of colours that the lights can generate are quite amazing and the app comes with some great presets for simulating common lighting environments.
Unfortunately Phillips does not yet offer a SDK, but a quick search on Github listed quite a few community projects for controlling the Hue lights with a variety of languages including Ruby, Python and Objective-C. The goals for my project included not only being able to adjust the colour of the LED bulbs, but also being able to calibrate the programs clock to that of the current time in the Minecraft world you are playing in. Ideally you’d want your program to query the Minecraft server or world your playing in to obtain the current time, however that would have required me to make a server plugin and on top of that, whatever server my son was currently playing on would have to have that plugin loaded. That’s a highly unlikely scenario, so I became clear that I would need to create some sort of UI that would somehow allow the user to calibrate itself to the time of the current Minecraft session.
I decided that I would create an iPad App that would have a very visual way of setting the time by panning your finger across the screen to position the sun/moon to set the time. The time conversion itself was pretty simple (link to mine craft wiki). Each minute in Minecraft is .83 seconds in real time. Daytime lasts 10 real world minutes, nighttime is 7 real world minutes and sunrise and sunset are each 1.5 real world minutes.
The app itself provides 3 purposes:
- A heads up display. My son plays on a computer with a single screen, so an iPad app gives him an extra screen for a heads up display so he can see the time in Minecraft
- Clock Calibration. You can use the app to calibrate the time between Minecraft and the app that controls the lights
- Interface to the Phillips Hue. The app is doing the work to change the lights at the appropriate time of day.
The app is open source and if you’re an iOS developer, please checkout the code and compile for your own use. I will likely submit to the app store in the next few days, and if all goes well the app will be available for free on the App Store. Mind you, you will have to shell out 200 clams for the lights!
The Objective-C source code for the project can be found at:
And finally a bit of shameless self promotion… I am currently available for iOS development employment or contracts. Please visit my about.me page and contact me! And one last bit of promotion for my son’s YouTube Channel where he posts his game play sessions. He’d love you to watch some of his videos and toss him a like or two!