Resource {NMS Tutorials} 1. Introduction to NMS

Discussion in 'Spigot Plugin Development' started by Arektor, Dec 28, 2016.


Are these tutorials a good idea?

  1. Yeah, ofc!

    748 vote(s)
  2. Yup, but I already know enough about that.

    26 vote(s)
  3. Maybe. I don't know.

    23 vote(s)
  4. Nah, people should try and learn by themselves.

    3 vote(s)
  5. No, you're bad at explaining things.

    3 vote(s)
  6. Apple pen.

    98 vote(s)
  1. So, I know, there is already tutorials introducing you to NMS. But this is just the first of a long chain of many others.
    But let's start that tutorial already!

    Chapter 1. Introduction to NMS
    You are here

    Chapter 2. Custom NMS entities
    Can be found here

    Chapter 3. GameProfiles
    Can be found here

    Chapter 4. DataWatchers
    Can be found here

    Chapter 5. Fake Players, with skins and stuff!
    Writing in progress

    Chapter 6. Looking into NMS sources
    Writing in progress

    1. What does NMS stand for? Why using it?

    NMS is the abreviation for the package net.minecraft.server. It is where the minecraft server sources are located.

    There is several reasons for using NMS, like:
    • Saving server resources by directly adding code in the sources, instead of using schedulers for example.
    • The ability of doing way more things that Bukkit / Spigot allows it
    • Optimization in some cases: if things are well done, using NMS will be faster than usual ways.
    • And much more.

    2. Then why almost nobody uses it?

    Because, it may be powerful, but it's also unsafe, dangerous.
    Saying it like that may sounds to you like "IT CAN DELETE THE SERVER?!" but.. nah, nothing THIS dangerous. The worst that can happend is world / player data corruption in 1st place, and server crash in 2nd.
    But it's still a thing and this shouldn't be ignored.

    Another problem with NMS is that it is, in almost all the cases, not cross-version compatible.
    There is a way for you to make a plugin use NMS and work with several different versions but we're not going to see that right now.
    But to make it clear, the NMS package looks like this:
    • net.minecraft.server.v1_8_R1
    • net.minecraft.server.v1_8_R2
    • net.minecraft.server.v1_8_R3
    • net.minecraft.server.v1_9_R2
    • net.minecraft.server.v1_11_R1
      And I think you've understood the thing.
    When a Minecraft update comes out, it can - and it does almost all the time - have some "major" changes in the way it works.
    That's why the NMS package version changed from R1 to R2 between 1.8.2 and 1.8.3, and from R2 to R3 between 1.8.3 and 1.8.4.

    However, in the two latest major updates, 1.10 and 1.11, there has been no NMS package version change. At least for 1.10, but 1.11.2 came out with new items and cool things, and yet the package version has not changed.

    3. That's all? If you can "bypass" the package version check, where's the problem?

    Because NMS code is obfuscated.
    Well, it is in the minecraft_server jar, but it has been partially deobfuscated in the spigot and craftbukkit jars.

    But yet, almost all the methods will be called a, b, c, d, e, and the fields called aU, aV, aW, aX, aY, aZ...
    In other words, methods and fields will have names that do not have any meaning.

    And this is the biggest problem people will have to deal with when using NMS: this is probably the thing that makes them abandon the idea of using NMS.

    But don't worry: after reading all of my tutorials, you'll read through NMS easier than before, and learn some tricks to understand wtf is going on.

    Hey there! I don't know if these NMS tutorials will be helpful or not, so give me your opinion! If you have any suggestion on how could I improve myself at explaining things, feel free to tell me!

    And finally, if you have any specific NMS subject you wish me to talk about, ask me to!
    I'm already planning to talk about:
    • Custom NMS entities
    • GameProfile and player skins
    • DataWatchers
    • Packets
    #1 Arektor, Dec 28, 2016
    Last edited: Feb 19, 2018
    • Like x 16
    • Informative x 8
    • Useful x 6
    • Winner x 3
    • Agree x 1
  2. Very nicely explained! Let me know when you release a new tutorial!

    Sent from my iPhone using Tapatalk
    • Agree Agree x 1
    • Funny Funny x 1
  3. Really interesting, keep it up!
  4. #4 Arektor, Dec 31, 2016
    Last edited: Jan 1, 2017
  5. good job, but there's already like three of these..
  6. As stated in the first line:

    But after loooong researches for tutorials talking about GameProfiles, and other things other than custom entities...
    There is none of them. None.
    • Agree Agree x 1
  7. I'd be interested in a GameProfile tutorial :O
  8. Me also.
    But also on datawatchers. I litterally dont know what they are
    • Agree Agree x 1
  9. It is planned, but because registering custom entities in 1.11 is completely different now, it is the second chapter.
    But I'm thinking about GameProfiles for third one.

    Then DataWatchers as fourth. Can't do everything at the same time :p

    I've messed around with them for a server project, so I know enough to at least try to make a tutorial on them.
  10. Okx


    This looks really promising!
    I can only do basic NMS myself, and I have barely used it, so I feel these tutorials will be of great use to me xD
    • Agree Agree x 1
  11. Really cool resource,well explained. Looking forward to see more tutorials from you!
  12. mark cool resource