Minecraft first got its hooks into me more than 2 years ago. I first played it in Sept 2010 (yeah - I'm bragging my early adopter status - so what ;-p ) but its hold on me has only grown stronger over time. Needless to say I'm hooked. Minecraft fascinates me not so much as a player but as a developer. I've recently watched 'Minecraft - The Mojang Story'. It's clear from watching the documentary that Notch's achievement has gotten the attention of other well-known and respected game developers who admire him not only for what he did but how he did it. No other game gets my creative juices flowing as much as Minecraft does.
The number 2 is printed. Everything after
/js is evaluated as
Unfortunately, there are good reasons why this isn't viable. Being a
good modding citizen means all of the decompiled minecraft code must be
recompiled and reobfuscated. This means that run-time class names and
method names aren't scripter-friendly so the entire minecraft
useful functions ...
getBlock(x,y,z) returns the block id and metadata for the block at
a given position. If no x,y,z coords are provided then the block under
the cross-hairs (the current selected/targeted block) is used instead.
putBlock(x,y,z,blockId,metadata) places a block at the given
coordinates. Again - if no x,y,z coords are provided then the block
under the cross-hairs (the current selected/targeted block) is replaced
with the blockId and metadata provided.
getPlayerPos() returns the
player's x,y,z coordinates and also their rotationYaw (angle at which
they're looking left/right) which is the direction they're facing.
getMousePos() returns the x,y,z coordinates of the currently
selected/targeted block or null if the player is pointing at thin air.
load(path_to_script) will load and evaluate the script specified. If
no script is specified then a file open dialog is shown so the player
print(object) will print the specified parameter on the in-game console's window.
... Keep in mind this is Rhino so
window and DOM are not
available since those objects/APIs only make sense in a browser context.
ability to get and put blocks at any location in Minecraft is powerful
but even so, to use the above functions as-is would require some
knowledge of 3D geometry. Fortunately, you don't have to use the
putBlock() functions - I've provided a wrapper which
takes care of much of the finickiness of moving about and building in 3D
/js d = new Drone().up().box('5:1',3,4,7).up(4).right().fwd(3).box('5:2');
... which creates a new Drone object (by default at the cross-hairs location), moves it up, builds a box of spruce wood 3 wide by 4 tall by 7 long, then moves up, right and fwd (to top-center of box) and places a single block of birch wood. The above code can be shortened even further to just...
... All of the Drone object's methods are also exposed as global
functions which return Drone objects, so they too can be chained togther
to make entering statements at the in-game command prompt, less of a
chore. I've been doing some usability testing with my 11 year old
apparent that having to type
new Drone() before a method chain was
language - simplifying the API in this way wouldn't even be possible in Java.
[Update: The Drone API is preloaded when you install the ScriptCraft bukkit mod]
Unfortunately the Drone API doesn't (yet) come pre-loaded with the mod
so in order to do some serious building the first thing you must do when
you fire up Minecraft is type...
... and load either the drone.js file or one of the example_script files (which also load drone.js as they depend on it). Once loaded you can create a humble dwelling with the following statement...
... of course ScriptCraft wouldn't be much fun if it was only used to
create humble dwellings (even lots of them). ScriptCraft comes into its
own when building structures which would take time and be tedious to
build manually. The fort.js extension is an example of how
ScriptCraft's Drone object can be extended so that new more complex
buildings can be chained. The example
fort() method can take
height which specify how long each side of the
fort should be and how tall it should be. Even more interesting is
castle.js which (literally) builds on fort's code to create
even larger buildings.
Ultimately I think the ScriptCraft mod could be used to take building in Minecraft to a whole new level. With a full-blown language at the Player's disposal, it should be possible to create not just castles and forts but entire road networks and cities. It makes it possible for Minecraft Server administrators to create interesting places for players to come and play. Anyone who played SimCity 2000 in the mid 90s will remember the city-planning aspect of that game. ScriptCraft makes it possible to begin thinking about Minecraft in the same way.