NMS in Spigot

Discussion in 'Spigot Plugin Development' started by MartinStone, Apr 19, 2017.

  1. I was in the process of making some AI goals for my entity but since all the tutorials and stuff regarding the fields are old I figured I might aswell use MCP do decompile the MC 1.11 jar and have a look at the fields myself using the map viwer included.

    However I stumbled uppon the surprise that the code produced by BuildTools inside the Spigot and Craftbukkit folders relating to NMS (I checked the .patch files too) has some discrepancies with the original NMS. For example the BuildTools produced still uses PathFinderSelector and has no trace of the new EntityAITask which is located in every EntityLiving the decompiled NMS. And my IDE tell me the same about the accessible (without reflection obiously) methods and fields.

    What I am asking is that if there's an issue on my end like an import maybe that I am not doing right or is it that Spigot just patches new versions for minimal functionality and not implement the new NMS made from the creators.

    Any help on this subject would be appreciate. Thanks
     
  2. Some things are modified, look for the original decompiled files in the /work folder in buildtools. In the end, you just have to mess with the classes used by spigot until you are familiar with them.
     
    • Like Like x 1
  3. electronicboy

    IRC Staff

    Spigots build system setup is designed in a way that only changes made by spigot will actually be in the source folder, the rest of the decompiled files is inside the work/decompile-xxx folder in buildtools. (the build process compiles spigot and replaces the classes changed by spigot during that process over the MC server)

    Worth noting that MCP is best used as a guide, MCP has many changes compared to the direct decompile that Spigot uses from the server, MCP generally has patches that improve readability and add documentation, don't expect stuff to match up at all in some cases, and don't expect that something is a completely different method because it looks a bit off.
     
  4. I looked throught the work folder aswell but didn't find any answers there either. What I mean for example is that according to MCP LivingEntity has a field of type EntityAITask for MC 1.11. However when looking for it anywhere in Spigot, it's not there or any reference to it. Not even as a .java file. So is it possible it's so heavly obfsucated that EntityLiving member fields get changes?. I wouldn't hink so.

    Also I am not accessing a method in this particular case but a field. If the case that I stated (Spigot updates their own code without taking as base the original NMS release after each update) is there even a way to decompile that?. MCP clearly stats that they don't work with Spigot builds so it's even darker to work with. Or maybe know in which MC version they decided to branch off?
     
  5. Choco

    Moderator

    MCP has no relation to Spigot whatsoever. Their mappings are completely different, including the names of many of the classes. It may be EntityAITask in MCP, but I believe what you're looking for in Spigot's NMS would be PathfinderGoal
     
    • Like Like x 1
  6. electronicboy

    IRC Staff

    in Spigot, look at
    EntityInsentient -> PathfinderGoalSelector fields

    MCP and Spigot are both based on the exact same code and even literally decompile the server in front of you as you watch, they just handle renaming differently.
    MCP is also not compatible with Spigot, because Spigot uses their own mappings, which is what causes field names to be out between the two. different mappings would mean that the patch files wouldn't work properly, especially in cases where the class itself has been renamed.
     
    • Like Like x 1
  7. Thanks alot those where the answers I was looking for. So basically when using Spigot NMS I gotta work throught the obfuscation without MCP and it has no relation whatsoever to MCP.
     
  8. Choco

    Moderator

    Correct. Though the mappings are certainly clearer in MCP due to the fact that more methods and fields are deobfuscated. If you know what method you're looking for, by all means, view MCP's decompiled code to get a better idea of what it does. As long as you're aware that various features of the decompiled code is going to be different, you'll be fine.