BichBich
BichBich

Reputation: 11

How to edit the content of a .jar mod (1.8.9)

The mod creates an InputStream from a URL containing custom chat messages and I'd like to change those messages. To do so, I'd like to change the URL. How would I be able to do so?

The mod is under 1.8.9

I tried contacting the dev about it but I didn't get any answer. In addition, I decompiled the mod but after importing it into eclipse, I get alot of errors.

Thanks.

Upvotes: 0

Views: 2447

Answers (1)

Find the class file that contains the URL you want to change, then choose an option for how to change it.

Option 1: editing the jar

Extract the class file, and run a Java disassembler such as Krakatau on it (note: not javap, since you can't reassemble its output). Change the URL in the disassembly, then reassemble it (Krakatau can do this too). In the jar file, replace the class file you disassembled with the one you reassembled. (Remember, jar files are just renamed zip files.) Check the META-INF folder to make sure there isn't a signature/checksum that you invalidated.

Option 2: reflection

Even if a field is private, you can access it with reflection. Create a regular mod of your own that uses reflection to get the URL and change it. Note that this method won't work if the URL is hardcoded into the function or if it's static final.

Option 3: coremod

Coremods are a feature supported by Minecraft Forge to let you use ObjectWeb ASM to manipulate classes as they're being loaded. Create a coremod of your own. It should have a loading plugin and a class transformer. The loading plugin should set up the class transformer in the path of all loaded classes. The class transformer should use a ClassReader to read the class, then make the necessary change, then a ClassWriter to write it back out.

Upvotes: 1

Related Questions