4

I am opening a minecraft class folder with notepad++. But whenever I open it, it just has a bunch of boxes that say Nul, DC1, SO, SOH, FF, STX, ect... On guides I see that the class file opens just fine, what am I doing wrong?

Rubydesic
  • 3,386
  • 12
  • 27
Madison Young
  • 629
  • 3
  • 8
  • 15

3 Answers3

2

you cannot view the source of the file if it is still compiled, you have to decompile the class file to a java file and then you can read the file with notepad/eclipse, there is a program that people have made to decompile the minecraft source so you can edit it, its called mcp

http://mcp.ocean-labs.de/index.php/MCP_Releases

Just download this and continue as you're meant to, then you can freely edit the code

Sergey K.
  • 24,894
  • 13
  • 106
  • 174
Brandon
  • 1,158
  • 3
  • 12
  • 22
2

You are trying to edit a compiled Java class.

It's not a text file, so you can't edit it with a text editor. You want a .java file, and I don't believe Minecraft is open source.

Check your guides again, you've likely strayed from the path on which they were intending to lead you.

Borealid
  • 95,191
  • 9
  • 106
  • 122
0

If you want to open class file as is, use any binary editor. ghex is a good one. You can do:

ghex MyClass.class

javap is a built in tool to disassemble java class files. Here is an example:

javap -v MyClass.class

This will provide you with lots of information about your class, its byte code and even explanation to what it is doing

Another awesome tool for java class file decompilation is CFR: http://www.benf.org/other/cfr/ Example:

java -jar cfr.jar MyClass.class

Source:

import java.math.BigInteger;
import java.util.stream.Stream;

public class MyClass {

    public static void main(String[] args) {
        System.out.println(
                Stream.iterate(
                        new BigInteger[]{BigInteger.ZERO, BigInteger.ONE},
                        n -> new BigInteger[]{n[1], n[0].add(n[1])}
                )
                .limit(1001)
                .skip(1000)
                .findFirst()
                .get()[1]
        );
    }
}

CFR output:

import java.io.PrintStream;
import java.math.BigInteger;
import java.util.Optional;
import java.util.stream.Stream;

public class MyClass {
    public static void main(String[] arrstring) {
        System.out.println(Stream.iterate(new BigInteger[]{BigInteger.ZERO, BigInteger.ONE}, arrbigInteger -> new BigInteger[]{arrbigInteger[1], arrbigInteger[0].add(arrbigInteger[1])}).limit(1001L).skip(1000L).findFirst().get()[1]);
    }
}
Hasan Ammori
  • 373
  • 3
  • 9