понедељак, 07. мај 2012.

Playing Minecraft in split screen on PC and other funny stories

A few weeks ago I felt a sudden urge to play some Minecraft with my brother. We both have accounts on minecraft.net, but my PC is the only one in our household capable of running it smoothly. Besides, we prefer the same-room multiplayer, preferably hot-seat (like in Worms) or split screen (so many hours lost on Left 4 Dead), so regular Minecraft multiplayer was out of the question.

I started looking into available options. Minecraft didn't have a split screen option, unlike the upcoming XBox 360 version. Searching for mods that added the functionality revealed no results. Then I remembered of a method of playing another game, Borderlands, in semi-splitscreen. It was based on running two instances of a game in a window, and connecting to each other in LAN. Add a bunch of scripts, boarder-less (no pun intended) windows, and you have yourself a playable game.

So, if I could run and control two instances of Minecraft, after connecting to the same server I would have some real world, first class, same room multiplayer fun. I could even connect a second monitor and play it really comfortably.

The quest was on finding a way to control both instances separately. Minecraft didn't support joypad input, and I haven't found a mod that does that neither. Other possible solutions included programs like Joy2Key and xpadder to map the joypad buttons and axes into keyboard and mouse input. But doing so would not resolve the problem because only one window can receive keyboard and mouse input at a time, and having two windows open, only one would be focused. Having found no available solution to the problem, I decided to try and develop one myself.

UPDATE: This post is outdated and should be treated only as a curiosity and a piece of (my) history. If  you're interested in downloading and installing the Minecraft Joypad / Split Screen mod, please head to the mod page, or the Minecraft Forums thread.

Thanks to the hard work of guys and gals at the Minecraft Coder Pack, everyone who is interested in modifying Minecraft to suit their needs with basic knowledge of Java and game development can jump right in. They provide the facilities to decompile and deobfuscate the Minecraft classes, an Eclipse workspace with the debug profile set and ready, and utilities to pack everything back. I really couldn't be impressed more. Everything works out of the box, and the level of de-obfuscation is admirable. Not all method and field names are mapped though, so be prepared for a healthy dose of debugging. Although there are some resources on the net regarding Minecraft modding, if you stray a bit from the known waters (adding blocks, mobs, textures) you're pretty much on your own. I plan an additional blog post regarding the technicalities about what I have learned on Minecraft insides, but for now I present you the 

Minecraft Joypad Mod

The mod allows you to control the Minecraft using the standard OS-recognizable joypad (should work an all OSes). It's in a very rough state, but with a bit of luck and determination on your side it should let you play Minecraft with a joypad. It receives a global joypad input, so it works even if the window has no focus. This effectively lets you play Minecraft in a "split screen". Just run two instances of it, one using the keyboard and mouse, other with a joypad. Resize and/or arrange the windows the way you want to, and rock away. Windows' 7 Snap feature helps a bit, although not as much as the second monitor ;). You can also use software like Auto Window Manager if you wish to. If you want to play locally run the server beforehand. You can also connect to any multiplayer game.

Here's how it looks like:

Basic feature list:

- plays Minecraft using a joypad
- works in both single and multi player
- provides basic means of configuration through the config file
- allows for unlimited (?) number of joypads - yes you should get that 6-player split screen going
- compatible with Minecraft 1.2.5
- all basic features of Minecraft work (including Mining and crafting ;)) - movement, destroying and placing blocks, inventory, chests, crafting, furnace, brewing etc
- lots of fun

UPDATE: It's has been updated to 1.3.2: http://retro-hack.blogspot.com/2012/09/minecraft-joypad-mod-v0113.html


- a bit hard to set up ;)
- requires a joypad with 2 analog sticks, d-pad and a few buttons.
- broken keyboard input - you can't use keyboard and joypad for the input at the same time
- main menu not working - you'll need the help from the second player to start the game
- camera sometimes runs in circles by itself at the beginning of the game (stops when you move the analog stick)
- probably not compatible with other mods

I plan on improving upon all of the above, if there is enough public interest.

Setting up

First of all you need a 4-axis joypad which is registered by the OS (check the control panel), and a PC that can handle multiple instances of Minecraft running simultaneously.

Next, you need to prepare a separate portable copy of Minecraft, so you don't screw over you regular Minecraft copy with my mod. You'll need a launcher jar, and this bat file. In case the bat file is unavailable here are it's contents:

java -cp bin\minecraft.jar net.minecraft.LauncherFrame

Create an empty directory on the desktop. Place a bat file inside it. Create an empty directory named 'bin' alongside the bat file, and copy the launcher jar to it. Run the bat file. Log in to minecraft.net. It will download a copy of Minecraft to your folder on the desktop. Afterwards, you can always run the bat file to play it.

So, now you have a clean working copy of Minecraft. Download my mod, and apply it to your copy. Installation is pretty straightforward, as far as mod installation on Minecraft goes - open minecraft.jar with the 7-zip, add my modified classses, remove META-INF. Only difference being that the minecraft.jar is located in Desktop/yourdir/.minecraft/bin instead of %APPDATA%/.minecraft/bin.

Run 'run.bat' it should start the game. It'll print the information about the detected joypads and their layout to the console. The typical output should look like:

Loading: net.java.games.input.DirectAndRawInputEnvironmentPlugin
Minecraft joypad mod v0.6 by Ljubomir Simin
Found 1 controller(s) in total.
Found controller XUSB Gamepad (Controller) (0)
It has  10 buttons.
Button 0, Button 0
Button 1, Button 1
Button 2, Button 2
Button 3, Button 3
Button 4, Button 4
Button 5, Button 5
Button 6, Button 6
Button 7, Button 7
Button 8, Button 8
Button 9, Button 9
It has  5 axes.
Axis 0, Y Axis
Axis 1, X Axis
Axis 2, Y Rotation
Axis 3, X Rotation
Axis 4, Z Axis
Loading configuration file, using joypad no. 0 XUSB Gamepad (Controller)

You can read your joypad name and index (in parenthesis), button and axes counts and names. 

Start the game, create a new world. Walk around, test the controls. They'll probably be suboptimal. Don't worry, you can change them in the file named 'options.txt' in the .minecraft dir.

There's the meaning of button mapping:

joyNo:0 // number of joypad, -1 == no joypad, 0 = first joypad
joyCameraAxisX:3 // axis used for camera movement
joyCameraAxisY:2 // axis used for camera movement
joyMovementAxisX:1 // axis used for player movement
joyMovementAxisY:0 // axis used for player movement
joyCameraSensitivity:20 // camera sensitivity, between 1 and a few hundreds. Other values should provide funny results.
joyCameraInvertY:false // invert camera
joy_joy.attack:5 // attack. normally left mouse click
joy_joy.use:4 // use. normally right click
joy_joy.jump:0 //jump
joy_joy.sneak:8 //sneak
joy_joy.drop:6 //drop one item
joy_joy.inventory:7 // open/close the inventory
joy_joy.interact:2 //interact. like right clicking but without placing blocks
joy_joy.guiLeftClick:5 //used for left click in inventory. might be same as attack. normally left click
joy_joy.guiRightClick:4 //used for right click in inventory. might be same as use. normally right click
You can tweak the settings to match your preference.

UPDATE: Configuration has been simplified in the newest version: http://retro-hack.blogspot.com/2012/09/minecraft-joypad-mod-v0113.html

Notable improvements

When I first started to work on joypad support for Minecraft my goal was to implement it the quick 'n dirty way. As I worked on it though it became obvious there is no quick way. So I took some time and developed a few improvements specific to controller input. 

Firstly, all GUI screens support d-pad navigation. It means you can interact with all containers in game, be it player inventory, crafting bench, furnace, etc. This is not done by mouse emulation, it's hooked into game logic for selecting items, and hand-tweaked for each GUI screen to achieve sensible controls.

Secondly, I've added the 'interact' functionality. Back at the day one could burn own house down while trying to open the chest with a bucket full of lava. Nowadays it's not an issue anymore but it can still be a bit inconvenient if you miss a mob or lever and place a block instead of interacting with an entity. That's why I have added the 'interact' functionality. I behaves like a right mouse click, but can't be used for placing blocks. Think of it like an 'use' button in many other games, used for opening the doors, activating switches and interacting with the mobs. I usually map it to the "square" button on my controller.

Final words

Try it out it you think it's interesting. It's a bit tricky to set up, but I hope that won't be an obstacle to many. This is my first Minecraft mod and contribution, and I'll try to improve it as much as my free time allows it. I depend on your feedback though, so please feel free to comment it, and show to all your friends ;)

Wish you loads of fun.


58 коментара:

  1. I think you should add all controls and make it more custimizable... or at least add Xbox 360 controller support. When I use it...everything works except that the D-pad doesnt work in inventory or crafting.

  2. Have you tried the version 0.8? I've added some potential improvements for the Xbox controller in gui screens.

  3. How can I change which controller it uses because the game wont launch as it defaults to controller 0 and needs to be controller 6.

    1. By editing or adding (if there is none) the following setting to the options.txt file:

      joyNo: 6

      (it's zero-based, so 6 means seventh controller)




    1. If you run the bat file and login screen appears, all you have to do is fill in your username and password and press 'Login'.

      What is the exact nature of the problem are you having?

  5. Hello!
    Thanks for the mod, very good but when I start up my game, the console didn't detect any controllers. I have an Logitech Gamepad F310 tried both XInput and DInput, but nothing works!:(
    Please help me!

  6. No question now,solved it by force updating minecraft and modding again!

  7. I tried using it with my Mac and have written a pair of .sh scripts, one for automatic downloading and automatic modding a new minecraft.jar and another .sh file for starting the game.

    It comes to the launcher and after i have logged in it gives me the error :
    java.io.IOException: Cannot run program "javaw": error=2, No such file or directory

    Like if i havn't installed java but java is already built in on mac.

    It works flawlessly with the same script on my laptop with Ubuntu 12.04 :/

    If you help me, i can share my .sh files so it works for both linux and mac too

    1. I have no clue why would it be so, I've never used OSX :(. Good to hear it works on Linux though :)

  8. The mod Crashes with java.lang.NoSuchMethodError: yw.getCurrentPlayerStrVsBlock (Lpb;I)F launching the game with MinecraftForge mods

  9. Thanks for the mod.
    It's okay, I think it is pretty enough to play split screen with friends on the same computer.

    It works perfectly without some mods.

    Maybe in a future we can do it. xDDD

    1. I'll see what can be done, but it modifies a lot of classes, including the main Minecraft.class (input handling in Minecraft is scattered around). I'll browse through the modloader documentation and see if it's possible to make it work.

    2. Don't worry about it. I think that is better to center your priority on the GUI controls, like Main Menu, Death Menu, Enchant Table to solve the mouse help from the other player.

      Don't push youself too hard. Take it easy.

      And good work with your mod.

  10. Hey!
    Could you make it to work with mineshafter, so the second player don't have to be named "Player"?
    I can share my minecraft.jar from .minecraft/bin
    LINK: http://www.4shared.com/file/Kvl26Uwz/minecraft.html
    And one more: Could you make the controls as Minecraft 360 defaultly?
    Cause I'm mining with RB and not with RT and sometimes I'm a bit confused!

    1. I'm working on XBox360-alike controls.
      The second player won't be named "Player" if you log in with your minecraft.net credentials.

    2. Hey!
      Sorry for my bad english, I have only 1 copy of minecrfat and my friend don't have one he has a cracked one but you've already did goof work!:)

  11. Одговори
    1. The link works fine, try to change your ip, reseting your router.

      Proba a resetear o teu router para cambiar a tua ip.

  12. Enchanted Table Tips and Notes for users.

    If the player who is using the mod want to use a Enchanted Table he needs to push "left" on upper left corner in item box, or push "up" in the upper right corner to select the enchant box.

    Note: If the item is droped in any other position non visible will make a out of array error and crash the game.

    To select the enchantment he needs the same help as Main Menu o Death Menu mouse help.

    1. Which version of the mod are you referring to? Have you checked 0.9? I was fixing the very same issue there. If it persists, please let me know.


    2. It's the 0.9, I check it now and confirm.

    3. All right, I'll fix it next time. Thanks a lot for the hint.

    4. Take it easy. Don't push yourself.

  13. Hello, I have a problem and its when I open the bat file after putting everything in order I can't download the game because I dont have an account, but I still have a version which is playable (1.2.5) but its just to play offline, what can I do?

  14. I can't navigate in the inventory ( PS3 Controller ) all the other functions are good.
    But i cant craft. =P

    1. D-pad navigation is not working? Is dpad recognized when you open the joypad in a windows control panel?

    2. Аутор је уклонио коментар.

  15. How the heck do i link my xbox360 controller to my pc?
    And could you give me better instructions on installation?

  16. What joysticks does it support and how do i link them to my pc?

  17. Excellent Work !
    Now if you can integrate a virtual mouse to interact with inventory, and integrate the keyboard of the Xbox360 Controller it will be awesome.
    Thanks for your job

  18. Works great with my PS2 controller.

    I had a nifty idea for the Linux users. Multiseat system with Linux. That way you can use two keyboards and mice.

    1. Glad to hear that it works for you.

      Yes, with multiple monitors and multiple X sessions you could have a "splitscreen" without modifications to the Minecraft.

  19. How can i download minecraft with the bat file if i dont have a premium account?

  20. I got it working - but my character walks around in circles - as if my Xbox 360 joypad is constantly pushing right... Any clues?

    1. It happens sometimes, but goes away when you move the axis a bit. Try moving the analog sticks, pressing the triggers and buttons, maybe it resets.

      Can you move the character at all, or is it stuck circling? It that case maybe the axis number configured for movement is not correct, and it is reading an non-existing axis. Check out the options.txt file, and see the existing axis id's in the test utility I have provided.

  21. El postoji sanse da ovo radi na krekovan acc :D ?

    1. Poenta je samo da imas cistu kopiju da ne pregazis svoj redovan minecraft. Da li imas ili nemas premium je nebitno.

  22. moze li da ovo radi na crackovan acc,jer ja sam uspio napravit da se spojim ja server s dva MC ali kako da se krecu u isto vreme odvojeno? :)

  23. DUDE i want this mod in 1.3.2 soooo bad ive been waiting like a month please please update this mod!!

  24. HI um I have a problem I can't use keyboard+mouse on the first window because it uses the same .jar file so if I put the controller files in the .jar file the two windows run with the same controller so please if you know something help me BTW I can't use your run.bat becuase it's not working it can't find that net. frame thingy so I just launched two minecraft with different player names...

    1. First of all make sure you're running the newest version of the mod (currently 0.11.3).
      The best way to play splitscreen is to have two separate copies - one unmodded and one modded. If you can't do that, you can always try the following.

      Install the mod, run the game, configure it. After the first player has entered the world, open the file "options.txt" inside the minecraft directory, find the option "joyNo", change it to -1, save the file, then run the second copy of minecraft - it should use the keyboard.

  25. I want this mod to be compatible with Forge or at least Modloader. I can't put any mods in it. I want to play with my mods in LAN with my friend. But for now, we are stuck with the Vanilla MC, wich is boring :/

  26. gostaria de jogar minecraft 1.4.2 pc split screen
    teclado e comtrole esse posiveu com mo creature,
    aguardando anciosamente uma resposta um muito obrigado ja antecipado!

  27. just as I run the batch file a black screen that says:
    'java' is not recognized as an internal or external command, operable program or batch file.

    C: \Users\User\Desktop\portable mc installation>pause
    press any key to continue...

    then the cmd window exits and nothing happens, any solutions? :/

    1. You need to add Java to the system Path.

  28. Анониман15. јун 2013. 20:13

    I have a problem ?
    when i open the bat file it says

    A:/users?Owner?Documents/Bat file>set APPDATA=A:/Users/Owner/Documents/Bat file

    A:/Users/Owner/Documents/Bat file>java -cp bin/Minecraft.jar net.minecraft.LauncherFrame
    Error: Could not find or load main class net.minecraft.LauncherFrame

    A:/Users/Owner/Documents/Bat file>pause
    Press any key to continue...

  29. Анониман17. јул 2013. 07:45

    it dont want to download :/ when i type user(or email) and password its says "Login Failed" what to do bro help needed

  30. I have a question, i have an account on minecraft.net but my brother not, he doesn't want to create 1 and my account its not premium, sooooo, we have to download some pirate versions u.u how could i install the mod for the pirate versions?? thanks for your time and sorry for my errors i am Venezolan

  31. I have a problem, my mom dont let my buy the game, sooooo, i have to download a pirate version u.u what do i have to do for install the game in the pirate version?? Thanks for your time and sorry for my bad english :D

  32. I just like the helpful information you supply for your articles.

    I will bookmark your weblog and check once more here
    regularly. I'm relatively certain I'll be informed many new stuff
    right right here! Good luck for the next!

    My blog

  33. What do you wanna define about the Minecraft???