[NMS] DataWatcher 'a' method confusion

Discussion in 'Spigot Plugin Development' started by Geekles, May 16, 2018 at 6:53 PM.

Thread Status:
Not open for further replies.
  1. I recently found a class created back in 2014 (I guess that was 1.8?) where it uses the DataWatcher class quite a bit for the packets (creator unknown unfortunately). This class was used to help create and manage an artificial human (npc) with packets of course. Now I haven't done a whole lot with NMS, although I'm familiar with it. I've been doing I believe fairly well at renaming the outdated methods and resolving a few parameter issues with those updated methods, however I'm running into an issue with figuring out what the parameters (int, byte) were being used for in the old 'a' method in the DataWatcher class. It's used quite a bit throughout the class, however the 'a' method in the DataWatcher class no longer takes those parameters and I'm not sure what to change here (unfortunately none of the code written in the class had any comments as to what was happening). I could get the 1.8 jar file from buildtools and look through the source code and hope that the class I'm updating was using spigot 1.8, however this could take hours. Hopefully someone recognizes my issue and may save me quite a bit of time here. (Using Spigot 1.12)

    Code (Text):
            DataWatcher d = new DataWatcher(null);
            d.a(0, (Object) (byte) 0);
            d.a(1, (Object) (short) 0);
            d.a(8, (Object) (byte) 0);
    Code (Text):
        @Deprecated
        public void setName(String s) {
            DataWatcher d = new DataWatcher(null);
            d.a(0, (byte) 0);
            d.a(1, (Object) (short) 0);
            d.a(8, (Object) (byte) 0);
            d.a(10, (Object) (String) s);
            // d.a(11, (Object) (byte) 0);
            PacketPlayOutEntityMetadata packet40 = new PacketPlayOutEntityMetadata(id, d, true);
            for (Player p : Bukkit.getOnlinePlayers()) {
                ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet40);
            }
        }
    Code (Text):
        public void hideForPlayer(Player p) {
            DataWatcher d = new DataWatcher(null);
            d.a(0, (Object) (byte) 32);
            d.a(1, (Object) (short) 0);
            d.a(8, (Object) (byte) 0);
            PacketPlayOutEntityMetadata packet40 = new PacketPlayOutEntityMetadata(id, d, true);
            ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet40);
        }
     
  2. Are you updating to 1.12 NMS?
     
  3. Yup.
    :p
     
  4. Sorry, was a bit hard to read the block of text.
    So what you could do is use MCP to decompile & deobfuscate Minecraft's source and check the mappings there. The classes are the same but the names are different. In MCP, DataWatcher is EntityDataManager. It should have all the variable and field names filled in.
     
  5. I'd recommend this, but don't do the whole process: it's way too much.
    just find the name in the previous version's mappings (it's just a HUGE csv), then match that name in the new one's and the respective obfuscated name
     
  6. Well if you deal with NMS a lot it might be worth it to decompile the whole thing.
    Where would you find those name mappings?
     
    • Funny Funny x 1
  7. Haha this is the 1.8 version, the other versions are also there though.
     
    #9 JanTuck, May 16, 2018 at 8:21 PM
    Last edited: May 16, 2018 at 8:28 PM
  8. It's in the downloadable zip
     
  9. @Geekles Did we answer your question?
     
  10. Well obviously we did, but it's whether or not it was acceptable :p
    (Sorry I'm tired)
     
  11. I somewhat anticipated that I would have to decompile and dig through classes. I might put this project on hold for now then, since I have yet gotten any luck. I think in the end it'll just be a lot of debugging and testing to see what values are for what etc.
     
Thread Status:
Not open for further replies.

Share This Page