Hello. My name is Max. I made a tool which injects modifications while loading an executable jar file. It supports two kinds of modifications: Plugins and Hacks. This tool, ModInjector, was made for Minecraft 1.8; although, it should work with any version of Minecraft, even any executable jar at all given the right modifications and java security clearance (which is by default OK). If I did something terribly wrong, cut me some slack: I'm new to java, and this is my first post.
In case minecraftforum decides to eat up the post, visit this link I maintain of this post's BBCode.
Download both necessary files, ModInjector.jar and asm-all-5.0.3.jar. These can be found under the Downloads spoiler.
Navigate to the Minecraft game files.
The Windows default is %APPDATA%/.minecraft./
The OSX default is ~/Library/Application Support/minecraft
The Unix-Like default should be HOME/.minecraft
Paste asm-all-5.0.3.jar in DIR/libraries/org/ow2/asm/asm-all/5.0.3, where DIR is the Minecraft game files folder. You should have to create some folders.
Navigate to DIR/versions.
Create a copy of the folder 1.8 and its contents, and name it ModInjector.
- Substitute the full path to the original 1.8.jar for the XXXXXXXXX. This should be DIR/versions/1.8/1.8.jar, where DIR is the full path to the game files folder.
- Make sure you use either solidi ('/') or two reverse solidi ('\\') in your path, because the reverse solidus ('\') is interpreted as the escape key.
- Here are two examples of the injectorIn argument, for Windows with a user named Max:
Run the Minecraft Launcher, but do not click Play.
Click New Profile near the bottom left.
Name your profile whatever you want, I named mine ModInjector.
(Optional)(I recommend specifying a separate Game Directory.)
Uncheck the box which asks Mojang for assistance with fixing crashes.
(Optional)(If you want to see the lovely console messages, set Launcher Visibility accordingly.)
Where it says "Use version: " select from the drop down "release ModInjector".
Click Save Profile near the bottom right of this window.
Now you can select the new profile from the drop down menu near the bottom left of your Launcher. When you want to play with ModInjector, make sure the right profile is selected before you press Play.
Click Play.
Open your Launcher. (I recommend running the game with ModInjector at least once)
With ModInjector as the active profile, click Edit Profile.
Click Open Game Directory.
Find the plugins folder, or if you haven't yet run the game, create it.
Place all of the plugins you wish to have in that folder.
Open your Launcher. (I recommend running the game with ModInjector at least once)
With ModInjector as the active profile, click Edit Profile.
Click Open Game Directory.
Find the hacks folder, or if you haven't yet run the game, create it.
Place all of the hacks you wish to have in that folder.
Please don't redistribute nontrivial Mojang code, as it is explicitly against their End User License Agreement. (I feel like they won't care about trivial code, but officially I believe it is a violation.)
I'm no expert, but distributing hacks in general is frowned upon.
You may notice files called order.txt in the hacks and plugins folder. (Alternatively you can make them yourself).
If you need certain modifications to be loaded before other modifications of the same type, you may specify the order by writing the name of each modification file on a new line. The top line is the first to be loaded. Any modifications not explicitly listed will be added after the files in the list, but in no definite order. Invalid entries will be logged, and ignored (if the file exists it will be loaded after the list, in no definite order).
Hacks will always overwrite plugins.
Command line arguments are specified in the ModInjector.json file, on line 6. For help, pass
-injectorHelp
Both hacks and plugins are types of modification. Hacks = whole modified files, while plugins are more like the differences between the source and the modified file. I'm definitely not qualified to make any real statements about the legality, but as far as I'm aware hacks are generally a legally dark-dark-grey area when you distribute modified versions of someone else's code. Making hacks for yourself is certainly less enforceable if someone has a problem with it, assuming you keep them to singleplayer.
This is just a rebranded zipfile containing modified .class files and other resources to be injected on the classpath.
Plugins are rebranded zipfiles. These contain compiled classes, however none of the classes can have the same qualified name as another class on the classpath (a feature limited to hacks), or the whole .plugin will fail the rule check. To modify a class, you must first have a method somewhere in your code with the following signature:
public static byte[] dump(byte[] bytes)
This function is passed the bytes of a class, and must return a modified class's bytes. The supported way of doing this is via the ASM library, although if you want to do it another way go ahead (Note: you may have to have users add additional libraries to their .json files).
To have ModInjector call that dump(), you must annotate your CLASS with the @Modifies annotation. The qualified name of Modifies is name.maxshen.modinjector.Modifies; you can obtain it by adding ModInjector.jar to the classpath when building. To use the @Modifies annotation, you must specify a base class to modify like so:
I went through the entire instalation once again. Step by step. Still the same error.
...
I'm sorry to hear that. No need to step through installation any more.
This error is being thrown because the class net.minecraft.client.main.Main.class is not being found by my custom java ClassLoader. There is a chance that the path code on my end may be Windows specific, which I will check tomorrow. I assume the file "/home/myname/.minecraft/versions/1.8/1.8.jar" does actually exist.
If you can view the internal contents of your original 1.8.jar, please verify that the class net.minecraft.client.main.Main.class exists.
Please try running:
After grabbing a fresh 1.8.jar (delete the versions/1.8 folder and run the game vanilla, then run ModInjector)
With a tilde on line 6 of ModInjector.json:
\"~/.minecraft/versions/1.8/1.8.jar\"
(The next suggestions will not solve your problem, but might provide me with information.)
Without the plugin installed. (Is it a problem with the plugin?)
With ExampleHack installed. (Is it a problem with ModInjector itself?)
If ExampleHack fails, try with ExampleHack installed as you would a non-ModInjector mod.
Make a copy of the versions/1.8 folder.
Rename the new folder to "Test".
Rename the contents of versions/Test to Test.jar and Test.json.
Open Test.json, and on line 2 change "1.8" to "Test".
Rename ExampleHack.hack to ExampleHack.zip.
Extract ExampleHack.zip to a temporary directory.
Open Test.jar with a zip-decompressing file viewer.
Overwrite the contents of ExampleHack.zip (from the temporary directory) into Test.jar.
()(Delete the temporary directory)
Make a new profile in the Launcher using release Test, and see if that works.
How would I go about installing ModInjector alongside LiteLoader, which already uses its own json notations/profile ?
For the moment, I'm really just interested in the lightless redstone plugin, so I'd prefer if there'd be a way to convert it into a standalone mod or a LiteLoader plugin. (Every other mod needing another loader or launcher makes modding often rather hard to impossible it seems. Magic Launcher works with a couple of them, but getting Forge to work with anything else is already a pain. I wish developers concentrated on one plugin/modding API, which of course would need to be as versatile as possible.)
And if anyone knows of a bukkit/spigot plugin that can disable lighting updates caused by redstone, or prevent any redstone from acting as an active light source altogether, please let us know..
In case minecraftforum decides to eat up the post, visit this link I maintain of this post's BBCode.
Example Plugin
Example Hack
- Make sure you use either solidi ('/') or two reverse solidi ('\\') in your path, because the reverse solidus ('\') is interpreted as the escape key.
- Here are two examples of the injectorIn argument, for Windows with a user named Max:
I'm no expert, but distributing hacks in general is frowned upon.
You may notice files called order.txt in the hacks and plugins folder. (Alternatively you can make them yourself).
If you need certain modifications to be loaded before other modifications of the same type, you may specify the order by writing the name of each modification file on a new line. The top line is the first to be loaded. Any modifications not explicitly listed will be added after the files in the list, but in no definite order. Invalid entries will be logged, and ignored (if the file exists it will be loaded after the list, in no definite order).
Hacks will always overwrite plugins.
Command line arguments are specified in the ModInjector.json file, on line 6. For help, pass
Both hacks and plugins are types of modification. Hacks = whole modified files, while plugins are more like the differences between the source and the modified file. I'm definitely not qualified to make any real statements about the legality, but as far as I'm aware hacks are generally a legally dark-dark-grey area when you distribute modified versions of someone else's code. Making hacks for yourself is certainly less enforceable if someone has a problem with it, assuming you keep them to singleplayer.
This is just a rebranded zipfile containing modified .class files and other resources to be injected on the classpath.
Plugins are rebranded zipfiles. These contain compiled classes, however none of the classes can have the same qualified name as another class on the classpath (a feature limited to hacks), or the whole .plugin will fail the rule check. To modify a class, you must first have a method somewhere in your code with the following signature:
This function is passed the bytes of a class, and must return a modified class's bytes. The supported way of doing this is via the ASM library, although if you want to do it another way go ahead (Note: you may have to have users add additional libraries to their .json files).
To have ModInjector call that dump(), you must annotate your CLASS with the @Modifies annotation. The qualified name of Modifies is name.maxshen.modinjector.Modifies; you can obtain it by adding ModInjector.jar to the classpath when building. To use the @Modifies annotation, you must specify a base class to modify like so:
DoneLeave Bed button when you are sleeping: Download DoneButton v1.0 for Minecraft 1.8Another plugin which causes the background music to always play: Download MusicLoop v1.0 for Minecraft 1.8
Another plugin. This one disables light emission from redstone torches and repeaters: Download DarkRedstone v1.0 for Minecraft 1.8
Nice job.
I think the problem is line 6 of your ModInjector.json. Specifically, the argument:
You needed to replace the XXXXXXX with the full path of the 1.8 jar. For me (on Windows), this is:
Note the solidi: reverse solidi will be interpreted as escape characters. Therefore I could also use:
I've updated the instructions reflect this information.
I'm sorry to hear that. No need to step through installation any more.
This error is being thrown because the class net.minecraft.client.main.Main.class is not being found by my custom java ClassLoader. There is a chance that the path code on my end may be Windows specific, which I will check tomorrow. I assume the file "/home/myname/.minecraft/versions/1.8/1.8.jar" does actually exist.
If you can view the internal contents of your original 1.8.jar, please verify that the class net.minecraft.client.main.Main.class exists.
Please try running:
For the moment, I'm really just interested in the lightless redstone plugin, so I'd prefer if there'd be a way to convert it into a standalone mod or a LiteLoader plugin. (Every other mod needing another loader or launcher makes modding often rather hard to impossible it seems. Magic Launcher works with a couple of them, but getting Forge to work with anything else is already a pain. I wish developers concentrated on one plugin/modding API, which of course would need to be as versatile as possible.)
And if anyone knows of a bukkit/spigot plugin that can disable lighting updates caused by redstone, or prevent any redstone from acting as an active light source altogether, please let us know..