[INFO] 1.7.x Protocol changes (Find the new packet names here!)

Discussion in 'Resources' started by CaptainBern, Dec 3, 2013.

Thread Status:
Not open for further replies.
  1. Hello all,
    As you know the protocol has been massively changed in 1.7. Many plugins that use packets are broken because most people don't know the new packet names. This thread should solve this problem.

    The List

    if you need any help with the packet names (eg: you're looking for a packet that isn't on the list) than feel free to ask below!

    Note: This is not a support thread! If you do not know how to use packets or send them than you probably shouldn't be here! Questions involving "how to send" will be ignored!

    Reserved.

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

    neol3108

    Haha, nice.. thanks allot! :D
     
  3. Offline

    BungeeTheCookie

    Packets. Yay
     
  4. Offline

    Dakary

    CaptainBern
    Do you know what Packet17EntityLocationAction is now? I don't see it on the list anywhere. Thanks. :)
     
  5. Dakary PacketPlayOutGameStateChange and PacketPlayOutBed. (PacketPlayOutBed is used to sleep)
     
  6. Could you list the parameters of the constructor's of each Packet?! I would like to know which parameters i've to use for PacketPlayOutRespawn!
    Or how I have to cast the enumdifficulty and the enumgamemode.
    Code:java
    1. PacketPlayOutRespawn ppor = new PacketPlayOutRespawn(p.getWorld().getEnvironment().getId(),
    2. (EnumDifficulty)p.getWorld().getDifficulty(),p.getWorld().getWorldType(),
    3. (EnumGamemode)EnumGamemode.valueOf(p.getGameMode().name()));
     
  7. Offline

    bobacadodl

    https://github.com/Bukkit/mc-dev/tree/master/net/minecraft/server
     
  8. bobacadodl Sadly that hasn't been updated yet so it won't really help him any further :/
    ysl3000 You're using the right parameters but the wrong way to get them. The parameters are NMS classes and you're getting bukkit classes (so it won't work). I don't really have looked at the EnumGamemode and EnumDifficulty classes so I won't know how they work or can be achieved, sorry :/
     
  9. Offline

    bobacadodl

    He can still look through the constructors for the old class, https://github.com/Bukkit/mc-dev/blob/master/net/minecraft/server/Packet9Respawn.java, and see what objects you need to pass into it.
     
  10. Offline

    kreashenz

    There doesn't seem to be a Packet205ClientCommand change, it must have been removed.. What might it have been replaced with?
     
  11. Offline

    Comphenix

    It's still there, and it's simply called PacketPlayInClientCommand.
     
    ice374, Garris0n and kreashenz like this.
  12. Offline

    ice374

    CaptainBern You, Sir, are a legend.

    Ok, so im getting a few errors:

    here is what im doing:
    Code:
            public static PacketPlayOutSpawnEntityLiving getMobPacket(String text, Location loc) {
                PacketPlayOutSpawnEntityLiving mobPacket = new PacketPlayOutSpawnEntityLiving();
                 
                    mobPacket.a = (int) ENTITY_ID;
                    mobPacket.b = (byte) EntityType.WITHER.getTypeId();
                    mobPacket.c = (int) Math.floor(loc.getBlockX() * 32.0D);
                    mobPacket.d = (int) Math.floor(loc.getBlockY() * 32.0D);
                    mobPacket.e = (int) Math.floor(loc.getBlockZ() * 32.0D);
                    mobPacket.f = (byte) 0;
                    mobPacket.g = (byte) 0;
                    mobPacket.h = (byte) 0;
                    mobPacket.i = (short) 0;
                    mobPacket.j = (short) 0;
                    mobPacket.k = (short) 0;
    and here is an example of the errors:

    DescriptionResourcePathLocationType
    The field PacketPlayOutSpawnEntityLiving.j is not visiblePackets.java/Christmas Tregmine/src/info/tregmine/christmasline 49Java Problem
    `
    Please Help asap :)

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

    Garris0n

    ice374 The values are private. Either create an EntityLiving and pass that to the constructor or use reflection to edit them.
     
  14. Offline

    ice374

  15. Offline

    ice374

    That's what I was using in 1.6.4 and are trying to update, but I'm getting the error that I posted above.

    CaptainBern Garris0n chasechocolate

    Here is the code i have atm (so you can pop it straight into an IDE

    Code:java
    1. import java.lang.reflect.Field;
    2. import java.util.HashMap;
    3.  
    4. import net.minecraft.server.v1_7_R1.DataWatcher;
    5. import net.minecraft.server.v1_7_R1.EntityPlayer;
    6. import net.minecraft.server.v1_7_R1.Packet;
    7.  
    8. import net.minecraft.server.v1_7_R1.PacketPlayInClientCommand;
    9. import net.minecraft.server.v1_7_R1.PacketPlayOutSpawnEntityLiving;
    10. import net.minecraft.server.v1_7_R1.PacketPlayOutEntityDestroy;
    11. import net.minecraft.server.v1_7_R1.PacketPlayOutEntityMetadata;
    12.  
    13. import org.bukkit.Location;
    14. import org.bukkit.craftbukkit.v1_7_R1.entity.CraftPlayer;
    15. import org.bukkit.entity.EntityType;
    16. import org.bukkit.entity.Player;
    17. import org.bukkit.plugin.Plugin;
    18. import org.bukkit.scheduler.BukkitRunnable;
    19.  
    20. //Thanks to the amazing ChaseChocolate!
    21.  
    22. public class Packets {
    23. public static final int ENTITY_ID = 1234;
    24.  
    25. private static HashMap<String, Boolean> hasHealthBar = new HashMap<String, Boolean>();
    26.  
    27. public static void sendPacket(Player player, Packet packet){
    28. EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
    29.  
    30. entityPlayer.playerConnection.sendPacket(packet);
    31. }
    32.  
    33. public static PacketPlayOutSpawnEntityLiving getMobPacket(String text, Location loc) {
    34. PacketPlayOutSpawnEntityLiving mobPacket = new PacketPlayOutSpawnEntityLiving();
    35.  
    36. mobPacket.a = (int) ENTITY_ID;
    37. mobPacket.b = (byte) EntityType.WITHER.getTypeId();
    38. mobPacket.c = (int) Math.floor(loc.getBlockX() * 32.0D);
    39. mobPacket.d = (int) Math.floor(loc.getBlockY() * 32.0D);
    40. mobPacket.e = (int) Math.floor(loc.getBlockZ() * 32.0D);
    41. mobPacket.f = (byte) 0;
    42. mobPacket.g = (byte) 0;
    43. mobPacket.h = (byte) 0;
    44. mobPacket.i = (short) 0;
    45. mobPacket.j = (short) 0;
    46. mobPacket.k = (short) 0;
    47.  
    48. DataWatcher watcher = getWatcher(text, 300);
    49.  
    50. try{
    51. Field t = PacketPlayOutSpawnEntityLiving.class.getDeclaredField("t");
    52.  
    53. t.setAccessible(true);
    54. t.set(mobPacket, watcher);
    55. } catch(Exception e){
    56. e.printStackTrace();
    57. }
    58.  
    59. return mobPacket;
    60. }
    61.  
    62. public static PacketPlayOutEntityDestroy getDestroyEntityPacket(){
    63. PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy();
    64.  
    65. packet.a = new int[]{ENTITY_ID};
    66.  
    67. return packet;
    68. }
    69.  
    70. public static PacketPlayOutEntityMetadata getMetadataPacket(DataWatcher watcher){
    71. PacketPlayOutEntityMetadata metaPacket = new PacketPlayOutEntityMetadata();
    72.  
    73. metaPacket.a = (int) ENTITY_ID;
    74.  
    75. try{
    76. Field b = PacketPlayOutEntityMetadata.class.getDeclaredField("b");
    77.  
    78. b.setAccessible(true);
    79. b.set(metaPacket, watcher.c());
    80. } catch(Exception e){
    81. e.printStackTrace();
    82. }
    83.  
    84. return metaPacket;
    85. }
    86.  
    87. public static PacketPlayInClientCommand getRespawnPacket(){
    88. PacketPlayInClientCommand packet = new PacketPlayInClientCommand();
    89.  
    90. packet.a = (int) 1;
    91.  
    92. return packet;
    93. }
    94.  
    95. public static DataWatcher getWatcher(String text, int health){
    96. DataWatcher watcher = new DataWatcher();
    97.  
    98. watcher.a(0, (Byte) (byte) 0x20);
    99. watcher.a(6, (Float) (float) health);
    100. watcher.a(10, (String) text);
    101. watcher.a(11, (Byte) (byte) 1);
    102.  
    103. return watcher;
    104. }
    105.  
    106.  
    107. public static void displayTextBar(String text, final Player player, Plugin main) {
    108. PacketPlayOutSpawnEntityLiving mobPacket = getMobPacket(text, player.getLocation());
    109.  
    110. sendPacket(player, mobPacket);
    111. hasHealthBar.put(player.getName(), true);
    112.  
    113. new BukkitRunnable(){
    114. @Override
    115. public void run(){
    116. PacketPlayOutEntityDestroy destroyEntityPacket = getDestroyEntityPacket();
    117.  
    118. sendPacket(player, destroyEntityPacket);
    119. hasHealthBar.put(player.getName(), false);
    120. }
    121. }.runTaskLater(main, 400L);
    122. }
    123. }


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  16. ice374 Any errors on this one?
     
  17. Offline

    ice374

  18. ice374 Copy the source of the gist I gave you. It is updated. If you have any errors with it then it's probably something with the datawatcher.
     
  19. Offline

    xGhOsTkiLLeRx

    Will save a lot of work searching the new names.
    Maybe make a google spreadsheet?

    Much easier to have tables there! :)
     
  20. Offline

    daniel0916

    I needed some packets they aren't in your list:
    Packet102WindowClick --> PacketPlayInWindowClick
    Packet14BlockDig --> PacketPlayInBlockDig
    Packet15Place --> PacketPlayInBlockPlace
    Packet19EntityAction --> PacketPlayInEntityAction
    Packet7UseEntity --> PacketPlayInUseEntity

    Please add it to your list for other developers.
     
  21. Offline

    xTrollxDudex

    ice374
    Those fields are private, use reflection.
     
  22. Offline

    totokaka

  23. xGhOsTkiLLeRx Made a spreadsheet :)

    I will add all packets very soon.

    daniel0916 Yes I'm aware of those. Like I said, the list only includes the packets that are send by the server to the client. However I've updated the list and added all packets that are part of the PLAY protocol.

    All packets have been added to the list! There are still a few packets (the login and status packets) which I didn't had time for to figure out their old name. If someone already knows those than please let me know.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
    xGhOsTkiLLeRx likes this.
  24. Offline

    ccrama

    Nerp CaptainBern

    [​IMG]
    Hovering over PlayerAnimation has no mention of import or anything, just wants me to change it to PlayerAnimationEvent :l
     
  25. Offline

    Garris0n

    Is the plugin in your build path...
     
  26. ccrama Usage is like this: PlayerAnimation.ARM_SWING.play(player);
     
  27. Offline

    thepaperboy99

    Thanks for this. :)
     
    CaptainBern likes this.
  28. Offline

    ccrama

Thread Status:
Not open for further replies.

Share This Page