Saturday, March 24, 2012

Timesink part 9: Requiem for a plugin

Whenever there is an update to Minecraft, the good folks at the Bukkit Project need to update the Craftbukkit server. This, in turn, means that some plugins might need to be updated.

Most plugins are made by the Craftbukkit community of users, which means that for any given plugin the developer's interest in maintaining might drop to the point that it is abandoned.

Such seems to be the fate of the brilliant plugin ItemCommands. I honestly don't know why every server didn't use this. Let me try and explain just why this was such a great plugin.

I know there are a few people reading this that haven't actually played Minecraft, so for those dear reader, in Minecraft the player ispresented with a screen which has a crosshair in the center. When the player is within a certain distance of a block, the block's edges are hilighted in black. This means the player is close enough to interact with the block by clicking on it. The clicks can either be a normal mouse click or a cntrl+click (I don't know the Window's left/right mouse click convention).

The vast majority of plugins for Craftbukkit allow the player to execute commands by first typing "t" which opens up a chat window. The player then has to enter some character that tells the server that the player wants to execute a command and not send a chat message. The character is "/". So, for example, if the player wants to teleport to the in-game spawn point, they type:
 t<return> /spawn

Example Minecraft interface. Note the crosshairs (center screen) on the block outlined in black lines. The ability to execute commands via the chat interface is visible. In this case the command /spawn would teleport the player to the in-game spawn point. For those interested in the city-related stuff, note the presence of Mayan-inspired buildings in the distance.

This is fine, but it breaks the arm-flailing convention of Minecraft and makes immersion into the game hard. Enter ItemCommand.

ItemCommand allowed server admins to link items in a player's inventory, or what they did with items in their hands, with commands. For example, on the server I was running prior to the crash if one was holding a compass and they cntrl+clicked on a location, it would execute a command that would make the compass point to that location. It would link the action of the player holding the compass to the command "/compass here" enabled by the CompassEx plugin. If the player just clicked the mouse while holding the compass, it would make the compass point to the spawn location (executing the command "/compass reset").

It was brilliant! Players could teleport to their home or spawn using chunks of lapis lazuli (depending on whether it was a click or a cntrl+click), change where the compass pointed, etc. Even very young kids could get into it and there was far more suspension of disbelief.

Unfortunately, with the recent updates to CraftBukkit, the plugin no longer works and it looks like the author is no longer active. The code is on github, but frankly, I'm rubbish with Java. There's a project out there that allows one to write plugins in python, but it's not very well documented.

So, consider this a plea: if there's anyone out there that loved ItemCommands or thinks the idea of letting players execute commands without having to type is cool, AND they can update the Java project, please oh please update it and let me know.

Timesink, part 8: Automating city placement with python (and some Excel help)


People actually read this? Well gosh....


It has been a while, and before I start talking about how I largely automated city placement, let me offer an explanation as to why it's been quiet.

To avoid a tl;dr version: the computer hosting the minecraft server had several drive die one after the other. One of the drives had the running server. Another had the backup.

Dust in the wind.

Couple that with the release of Minecraft 1.2.3 (and now 1.2.4) and the lag between Minecraft updates and plugin updates, and things have been really dead.

Things are officially back up, though. A brand new world for people to explore.

But in the last post I said I would talk about the tools I'm using to automatically place cities, so let's get to that. Warning: this is a pretty boring post.

If I just wanted clusters of buildings to appear on the minecraft landscape, I could probably do that with just the Terrain Control plugin and the BOB files. What I'm trying to accomplish is complicated by the fact that

  1. There is a mathematical pattern to where each city is
  2. There are five distinct architectural styles
  3. Each of the architectural styles appears in specific biome types, but are not strictly limited to a certain biome. It makes no sense for a civilization from a forest biome to refuse to build anything in a plains biome just to the west, for example.
  4. If you are placing more than 20 cities, the process of teleporting to a set of coordinates and waiting 10 minutes for all the buildings to render (sometimes it can take longer depending on the buildings being placed) is tedious and should be automated.


To address the first point, I made myself an excel worksheet (which I'm happy to make available if people are interested).

The user enters two values--# of cities wanted and a scale multiplier (see post "Timesink, part 3" for details)--and then places a * next to the in-game spawn location, and the sheet does the rest...with the exception of the biome type. I'll get to that in a bit.

As a guide to understand the excel sheet, things which are underlined are things which the user must input. Anything in italics represents something which has been automatically calculated. Bold things are just headers. It's a convention I worked out for myself many years ago to quickly allow me to look at an excel sheet I made (maybe years ago) and understand what are the inputs and outputs.

The excel sheet assumes that at the center of my spiral is some sort of main complex. The Capital or Holy City...something. Of course, if you have a Holy City, you probably think of it as being the center of your world; your 0,0 starting point. In the story I'm working on for the server, the main city and the new player spawn point(set to in-game's 0, 64, 0) are different. This is why the excel sheet calculates a city's coordinates from the Holy City's perspective and from the in-game spawn point's perspective.

In the example excel image I posed city #3 is centered at in-game coordinates -203,595. That same city, if one assumed the Holy City was 0,0 is at -75, 164. This allows me to use the in-game coordinates(-203,595) to go to that location, but use the story related coordinates(-75,164) to provide a gate address to reach the city(see post "Timesink, part 4").

What my sheet can't do is tell me what biomes are at those coordinates. For that, I used screen and python.

If you are not familiar with screen, you can think of it as a command-line way to keep a "window" open, even if you are not actually connected to a computer. In practical terms, it means one can log into a computer, make a screen session, close your connection, and the computer you had logged into continues to behave as though you are still logged in. It lets one start and keep a minecraft server up and running even when one is not logged into the host computer, for example.

You can name your screen sessions, which then allow you pipe commands into the session. For example

screen -S minescreen

will start a new screen session named "minescreen". And we can send it commands from a python script.



To determine what biomes are present at various coordinates, I wrote a quick little python script that tells the cratbukkit server running in the "minescreen" screen to force a player (me) to teleport to a location and then force the player to query what biome they are in. Wait five minutes and repeat. The five minutes is because, just because you happen to land in an Ocean biome doesn't mean that's the biome you should use. If gives the user some time to look around and make a judgement about what the biome should be.

Write down the biome or notes in the Biome column, and you're ready for step two: splitting things up by biome.

I have split each of my architecture types up by biome and named the files and folders accordingly. The folders and files have common prefixes--"_swamp", for example.


This allows me to use command line tools to move files found.


Now, I admit that this isn't the exact script I used; I cleaned it up for posting so it might not actually work lol. When I was using it, I would do a single biome type since that means 10 or more cities were placed, and it often took a few tests to get the right settings for the BOB files to make sure there were a decent number of buildings, but not too many, and not too much overlap as buildings were rendered on top of or into other structures.

So I think that's it. As of today, the server is back up, all the cities are placed and I'm starting to place the Gate rings. There's still a lot of testing that needs to be done to makes sure all the plugins are working as they should.

Left to do:

  • Place all the Gates and test them
  • Start writing the messages from the enigmatic "H" who acts as the players absent guide and breadcrumb leaver.