I'm using the fly/x-ray mod and I would like to rebind F for Fly to another key.
I'm talking about editing the java class files.
EDIT: I figured it out.
How to change key bindings in Minecraft:
0. Force-update to the latest version of Minecraft.
0a. Download any pre-made mods for that version that you would like to use (such as the X-ray + Fly mod).
0b. Install the mods, replacing the appropriate files inside your minecraft.jar file (or folder) and deleting the META-INF folder.
1. Download MCP
2. Follow the included instructions as written in MCP/docs/README-MCP.TXT, using your (optionally modded) minecraft.jar and minecraft_server.jar files:
Code: Select all
How to use:
===========
1) Prepare the files:
- Copy the "minecraft_server.jar" file into the "jars" folder.
- Copy the folders "bin" and "resources" from your "%APPDATA$\.minecraft" folder into the "jars" folder.
3. Open Terminal
4. Type cd and drag the MCP folder to the Terminal window so the path to that directory is inserted, then press Return
4a. UPDATE MCP: Paste this into Terminal and press Return:
Code: Select all
python runtime/updatemcp.py "$@"
- Open the MCP folder, then the conf folder, then the file mcp.conf.
- Find:
Code: Select all
CmdFernflower = %s -jar %s -din=0 -rbr=0 -dgs=1 -asc=1 -log=WARN {indir} {outdir}
Code: Select all
CmdFernflower = %s -Xmx2G -jar %s -din=0 -rbr=0 -dgs=1 -asc=1 -log=WARN {indir} {outdir}
Code: Select all
python runtime/decompile.py "$@"
7. When it is finished, open the src folder inside the MCP folder
Modding Key Bindings
Here is how you would change the key bindings of an existing mod, for example:
8. Reference this page for the Key Codes that you are looking for, and use the number of the key you want to find, then Find in the .class files this line, for example:
Code: Select all
if (this.checkKey(33))
9. Replace the key code with the code of the key you want instead.
10. Follow the instructions to recompile, test, and obfuscate the minecraft code.
Code: Select all
3) Modding
- Modify the sourcecode in the "src\minecraft" folder or in the "src\minecraft_server" folder.
4) Compile
- Start the "recompile.bat" script in this folder.
(or paste this into Terminal and press Return:)
python runtime/recompile.py "$@"
5) Testing (optional)
- To test the modified game, start the "startclient.bat" script
(or paste this into Terminal and press Return:)
python runtime/startclient.py "$@"
Note that in the test client (I didn't test the server, but it's probably basically the same principle), you don't log into the Minecraft Host, so you can only do a Single Player game, it defaults all the key bindings to WASD, etc., and you need to start a new world (it's like a new installation of Minecraft, but you can't login with your username and password).
- To test the modified server, start the "startserver.bat" script
(or paste this into Terminal and press Return:)
python runtime/startserver.py "$@"
6) Obfuscation
- Decompile the code, modify and recompile. (testing was optional)
- Start "reobfuscate.bat" to start the reobfuscation step, it will automatically detect changed classes and reobfuscate them.
(or paste this into Terminal and press Return:)
python runtime/reobfuscate.py "$@"
- Your obfuscated classes are now available in "reobf\minecraft" and "reobf\minecraft_server", ready to be injected in MC.
- Make sure to delete the META-INF folder in minecraft.jar, otherwise the game will just black-screen when you start it.
12. Now that you have installed your patch over your modified version of the game (the same modified version you decompiled with MCP), play and test your changes again in your primary installation of Minecraft.
---
So here are my new settings:
Code: Select all
if (this.checkKey(82))
{
xray = !xray;
XRayHelper.a();
}
if (this.checkKey(80))
{
rf = !rf;
XRayHelper.a();
}
if (this.checkKey(79))
{
nightLight = !nightLight;
XRayHelper.a();
}
if (this.checkKey(83))
{
fly = !fly;
}
if (this.checkKey(81))
{
coords = !coords;
}
Xray = 0 (82)
RF = 2 (80)
NightLight = 1 (79)
Fly = . (83)
Coords = 3 (81)
Upon obfuscation, the output file was atk.class, which is found in the X-ray installation rather than the Fly Mod installation, just as a point of curiosity.
Code: Select all
== MCP 7.23 (data: 7.23, client: 1.4.5, server: 1.4.5) ==
# found ff, ff patches, srgs, name csvs, doc csvs, param csvs, renumber csv, astyle, astyle config
> Creating Retroguard config files
== Reobfuscating client ==
> Cleaning reobf
> Generating md5s
> Packing jar
> Reobfuscating jar
> Extracting modified classes
> Modified class found : net/minecraft/src/GuiIngame
> Outputted net/minecraft/src/GuiIngame to reobf/minecraft as atk.class
- Done in 8.18 seconds
!! Can not find server md5s !!