недеља, 16. септембар 2012.

After quite some time I've decided to port my Joypad Mod to the newest version of Minecraft - 1.3.2. I'm happy to announce that the work is done, and the version 0.11.3 - released. Read more for some back story.

This was the first time I updated the mod to the different version of Minecraft. Thanks to the awesome work the MCP team is doing in decompiling the original jar file it was not too hard to do.

But since I had some long standing issues with the mod functionality I wanted to tackle, I took some time to figure things out, and not just simply port the old code.

This first and maybe the most important problem was the inability to map all of the game features to all kinds of input events. Some actions like jumping and attacking had to be assigned to buttons, while moving the player and camera required using analog sticks. This made attacking with analog triggers as well as moving with a directional pad impossible. Since some people don't have two analog sticks on their controllers, and the XBox 360 gamepad has analog triggers (instead of shoulder buttons) this was quite an issue.

The problem lied in the way the Minecraft and lwjgl together handle the input. Lwjgl provides the Controller object which can give the state of all its inputs, but each kind of input is accessed by different methods with different signatures. Reading button's state gives you a boolean, reading a pov leaves you with an integer, while an axis returns a float. This forced the programmer to make certain assumptions about input handling, and either duplicate a lot of code, or stick to known input combinations.

In order to handle this kind of variety I added a bunch of abstraction. ControllerInputEvent interface which provides access to methods like isPressed() and getAnalogReading(), and a specific implementations for each kind of input event which do the work. This, together with the new format of the settings file string made possible to bind any action to any event.

Changing the controls by editing the settings file was complicated for many users, and an additional level of complexity was not making it any easier, so in order to take an advantage of the new architecture and still be accessible to the users I decided to implement the controller settings right into the game options screen.

While doing so I improved the way buttons are selected by the controller using all four directional buttons, so navigating the menus is now much easier. One thing that is still left to be finished is navigation through the lists, for example the "Select world" screen.

At the end I took some time for fun features, so I decided to implement visual in-game hints for the controls. Those can be disabled from the menu.

I also kinda reintroduced the "interact" feature, which currently acts as a way to open doors and switch levers without a risk of accidentally placing a block in hand.

Toggle-sneak is also now an option which you can turn off, going back to the standard Minecraft way of sneaking.

Changelog for version 0.11.3:

[update] updated the mod to the Minecraft 1.3.2

[add] added ability to map any mod feature to any input action. It's now possible for example to map the movement to D-Pad or jump to an axis. This was added mostly to support controllers with unsufficient amount of analog axes (i.e. pure digital controllers) and controllers which have an analog triggers in place of shoulder buttons (all XInput-compatible controlles, including an XBox360 controller)