Groovier Blockmania!


Org Co-Founder & Project Lead
It works! Pretty much exactly like expected :D ... 494dc09a85

Took me all evening (I'm rusty!) and I'll have to ask for delayed final judgement calls on it until I can actually do the writeup in the wiki I intended (also didn't find time for the git intro, other getting started bits, more communication - argh, not enough time!). But it works!

So in short (bigger writeup later):

* Groovy is now embedded within my Blockmania branch (Groovy is a light-weight "scripting language" front for Java)
* Groovy commands can be executed via the console and interact with the running game state dynamically! - in other words, interact freely with the game without writing debug/console code to allow the interaction first!
* Writing plugins is now possible without touching the Java code, by writing something small in Groovy and leaving it in a directory (current test hook is before the game starts, so not very fancy - other hooks are possible)
* Thin automated clients are now possible by issuing commands to the game via Groovy - for in-game unit/performance testing
* Config & simple game data could be defined in super-duper-easy Groovy instead of hard coded in Java or pricked in-between pointy XML tags (never was quite the fan...)

I have a vastly bigger enthusiastic rant about exactly what that means, but I'll have to contain my giddiness for another day. I'm just thrilled that it works - in particular because I didn't think about it until a day or two ago :D

I've known of Groovy's potential before, including the ability to embed it inside Java (you can do the same with Javascript, etc), but it didn't "click" for me until just recently where you'd really be able to make that shine. Essentially it gives us an easy debug system, the potential foundation for a plugin system (Minecraft doesn't even have that yet! Bukkit is a nice community-created bandaid, but a bandaid none the less), in-game automation, and lots of nifty config / setup power via fancy stuff like ConfigSlurper (you can't argue with that name!)

Current prototype will take lots more work but demonstrates two things:

1) On startup it executes a Groovy script inside a new plugins directory - it doesn't do much, but does demonstrate that it can access live variables from inside Java (it can modify them too, but baby steps and all!). Imagine a script like that adding a "tool" to an available Set of tools, and registering a quick piece of functionality that can be executed later when said tool is active (I'm going to try making a gun that spawns slimes, but that'll take a bit, hehe)

2) Try the following in the console while pointing somewhere you can place blocks (no quotes): "groovy world.getPlayer().placeBlock((byte) 8)"

Sure, that's no different than "place block 8" but it directly interacts with Java rather than rely on there being a custom console command to catch and execute a predefined bit of Java. The "groovy " prefix tosses the console string at the new GrovyManager class and any other command accessible via "world" (which is a variable shared with the "Groovy Binding") works - both good and bad. I'm sure you can totally crash the game and even corrupt a world that way, but it is hella-handy for debug :D

Having a lighter way of developing stuff without having to mess with the code will also make it easier to allow low-level contribution. Imagine where Minecraft would be today if Mojang had embraced plugin development rather than obfuscate the source?

More later... 2 mins till midnight!


Project Founder and Lead Developer
I'm stunned. Never thought it could be so easy to integrate a whole scripting language into the game. :shock: Very good idea and please continue working on it (I know that you'll do :D). Already tinkered a bit around with it and it works very well!