"Deobfuscated NMS"

Discussion in 'Plugin Development' started by Mrawesomecookie, Jun 12, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Mrawesomecookie

    Hi, I'm trying to change something like:
    Code:
        public int a(Random random) {
            return 0;
        }
    Into:
    Code:
        public int meow(Random loudness) {
            return 0;
        }
    I tried using MCP with craftbukkit, but it no work :(
     
  2. Offline

    sirantony

    Erm, I think you can't do that because it's not meant to.

    And if you think so badly it'll work, send me then a bit more code...
     
  3. Offline

    Garris0n

    Fork it, rename the field yourself, and compile?

    MCP de-obfuscates Minecraft, not CraftBukkit...
     
  4. Offline

    Cirno

    The closest I can think of getting to deobfuscate without modding CraftBukkit itself is to:
    1. Create a wrapper with a method named "meow"
    2. "meow" would call the internal method "a"
    3. When you want to have the mob meow (or whatever you're trying to do here), call "meow", which then calls "a".
    This is only if you don't want to mod CraftBukkit (as if you did and you released the plugin publicly, the chances of it working is just a micron from 0)
     
  5. Offline

    Europia79

    Mrawesomecookie

    Code:java
    1. public int meow(Random loudness) {
    2. return a(loudness);
    3. }


    you mean like that ? I have no idea why you'd want to do that tho... I'm sure you have your reasons tho.

    As far as reading obfuscated code and determining what's going on, I like to look at the return value, look at any mathematical operations. For example, consider the NMS Entity.class method e() for 1_7_R1

    Code:java
    1. public double e(Entity entity)
    2. {
    3. double d0 = this.locX - entity.locX;
    4. double d1 = this.locY - entity.locY;
    5. double d2 = this.locZ - entity.locZ;
    6.  
    7. return d0 * d0 + d1 * d1 + d2 * d2;
    8. }


    It accepts an Entity parameter. It returns a double which is equal to (d0 * d0 + d1 * d1 + d2 * d2); That's basically Xsquared + Ysquared + Zsquared... AKA distanceSquared. So, the meaning... it's basically an efficient way of comparing distances... without using the CPU expensive square root operation (to get the actual distance).

    That was an easy example.

    As far as your "question" about "I tried using MCP with craftbukkit, but it no work." Are these questions related ? Can you elaborate on your problem ?

    I'm not sure I understand... I've modded the client (dropped some class files in & deleted META-INF), but I've never done that to craftbukkit... why would modding it not work ? Because of class file conflicts with the same name ? Or what ? (just curious)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  6. Offline

    Mrawesomecookie

    Europia79
    The method I put there was a real method in NMS. (the void a). I just want to know what some of these do considering some look useless to me.
     
  7. Offline

    Cirno

    Most of the seemingly useless methods have different implementations for a different class. I don't have an example at hand, but for some reason, Mojang likes using one base class most of the time. Interfaces? Don't need them :p

    Let's say you have two JARs, the first one being the regular CraftBukkit JAR you get off of dl.bukkit.org. The second one being your own customized JAR file. The difference between the two is a class named "Worker" (this is a purely fictional class; I'm using it to explain). The class has a single method in it to, well, work. In the original JAR from dl.bukkit.org, the method is named "a" (because of Mojang's obfuscation and how Bukkit does not deobfuscate unless it's absolutely necessary). In your version, however, it's been renamed to "doWork" because "doWork" explains a lot more on what the method does rather than "a".
    Now if we consider the code:

    Code:java
    1. Worker worker = new Worker();
    2. worker.a();


    It would work on the vanilla version. However, when it runs on the custom JAR, it attempts to call "a", which is really "doWork" now. Then it throws a NoSuchMethodFoundException, your plugin breaks, and depending where the code was executed (as in, if it was executed by NMS or your own), you'll receive a wonderful stacktrace and a log file saying the server crashed and how it crashed.

    Again, I'm assuming that OP will release his plugin publicly. If he isn't go ahead and mod away, OP.
     
  8. Offline

    Ultimate_n00b

    Craftbukkit is built upon the Minecraft source. You can't just deobfuscate it. If you want to see the source, it's publically on github. If you want to deobfuscate the Minecraft source it uses, then just do that. There's no need to deobfuscate the craftbukkit jar.
     
  9. Offline

    Wolvereness Bukkit Team Member

    This sounds like the XY Problem.

    So, I'll just address what has been written, instead of the unstated problem you are actually trying to solve - because no one has any clue what you want.
    • We don't accept renames - there are plenty of reasons behind this, but I'm not in a position to explain why
    • There should never be a reason you rename something in NMS - net.minecraft.server (AKA, mc-dev)
    • Client modding is very different from working with CraftBukkit
      • Client mods are generally 'patching' the deobfuscated code - then compiled / adapted back to match the original format
      • CraftBukkit is an implementation of Bukkit, neither of which encourage changes (in fact, we can't help you make changes to them directly, as per our unofficial build policy) to accomplish a task, other than for purposes of improving the project (like, fixing issues reported to leaky, or adding new API)
      • Bukkit is an API for plugins - plugins that get compiled an execute code at runtime. Many of the features that developers need are provided using this API, including hooks (which we refer to as Events), and state manipulation (like the World, Block, or Entity classes).
      • If you want to change something for your server, write a plugin compiled against Bukkit; don't edit CraftBukkit.
    • You need to post what your end-goal is before asking for help - without knowing your purpose, you only confuse people and, in turn, receive no help.
     
    Europia79 likes this.
  10. Offline

    Mrawesomecookie

    Wolvereness Ultimate_n00b Europia79
    I'm not directly modding CraftBukkit/NMS.I think you mis-understood what I was saying. When I said I wanted to make "public void a()" into "public void meow()", I just meant making something that was completely non-human-friendly into something that was human friendly. I never meant to change code in CraftBukkit/NMS. As far as the XY problem was concerned, I'm asking for a better solution to my problem. I posted what I had tried so its evident that I have been trying other things.

    Show Spoiler

    Code:java
    1.  
    2. /**
    3. * The number of blocks (extra) +/- in each axis that get pulled out as cache for the pathfinder's search space
    4. */
    5. private AttributeInstance pathSearchRange;
    6. private boolean noSunPathfind;
    7.  
    8. /** Time, in number of ticks, following the current path */
    9. private int totalTicks;
    10.  
    11. /**
    12. * The time when the last position check was done (to detect successful movement)
    13. */
    14. private int ticksAtLastPos;
    15.  
    16. /**
    17. * Coordinates of the entity's position last time a check was done (part of monitoring getting 'stuck')
    18. */
    19. private Vec3 lastPosCheck = Vec3.createVectorHelper(0.0D, 0.0D, 0.0D);
    20.  
    21. /**
    22. * Specifically, if a wooden door block is even considered to be passable by the pathfinder
    23. */
    24. private boolean canPassOpenWoodenDoors = true;
    25.  
    26. /** If door blocks are considered passable even when closed */
    27. private boolean canPassClosedWoodenDoors;
    28.  
    29. /** If water blocks are avoided (at least by the pathfinder) */
    30. private boolean avoidsWater;
    31.  
    32. /**
    33. * If the entity can swim. Swimming AI enables this and the pathfinder will also cause the entity to swim straight
    34. * upwards when underwater
    35. */
    36. private boolean canSwim;
    37.  



    In NMS, the code above would look like:
    Show Spoiler

    Code:java
    1. private AttributeInstance e;
    2. private boolean f;
    3. private int g;
    4. private int h;
    5. private Vec3D i = Vec3D.a(0.0D, 0.0D, 0.0D);
    6. private boolean j = true;
    7. private boolean k;
    8. private boolean l;
    9. private boolean m;

     
Thread Status:
Not open for further replies.

Share This Page