Packet40EntityMetadata CB 1.6.1

Discussion in 'Plugin Development' started by cnaude, Jul 8, 2013.

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

    cnaude

    Does anyone happen to know how sitting works in 1.6.1? In 1.5.2 and previous versions I was able to use Packet40EntityMetadata with packet byte 4 to make a player sit. In version 1.6.1 this no longer works.
     
  2. Offline

    microgeek

    What does 'not work' mean? You're doing the equivalent of bringing your car to the shop and saying "Fix it it's broken". What's not working, and what have you tried?
     
  3. Offline

    cnaude


    Prior to 1.6 I was able to do this to make a player sit.

    Code:java
    1. Packet40EntityMetadata packet = new Packet40EntityMetadata(p.getPlayer().getEntityId(), new ChairWatcher((byte) 0), false);
    2.  
    3. public class ChairWatcher extends DataWatcher {
    4.  
    5. private byte metadata;
    6.  
    7. public ChairWatcher(byte i) {
    8. this.metadata = i;
    9. }
    10.  
    11. @Override
    12. public ArrayList<WatchableObject> b() {
    13. ArrayList<WatchableObject> list = new ArrayList<WatchableObject>();
    14. WatchableObject wo = new WatchableObject(0, 0, Byte.valueOf(this.metadata));
    15. list.add(wo);
    16. return list;
    17. }
    18. }
    19.  
    20. private void sendPacketToPlayers(Packet40EntityMetadata packet, Player p) {
    21. for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
    22. if (onlinePlayer.canSee(p)) {
    23. if (onlinePlayer.getWorld().equals(p.getWorld())) {
    24. try {
    25. ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet);
    26. } catch (Exception ex) {
    27. // Nothing here
    28. }
    29. }
    30. }
    31. }
    32. }
    33.  
    34.  
    35.  
     
  4. Offline

    microgeek

    Have you looked to see see if the protocol has changed?
     
  5. Offline

    cnaude


    That is the million dollar question. Do you you know if the protocol changes are documented somewhere?

    I found this site which documents these things. http://wiki.vg/Protocol

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

    DarkBladee12

    cnaude They simply changed "DataInputStream" and "DataOutputStream" to "DataInput" and "DataOutput":

    Old version:

    Code:java
    1. import java.io.DataInputStream;
    2. import java.io.DataOutputStream;
    3. import java.util.List;
    4.  
    5. public class Packet40EntityMetadata extends Packet {
    6.  
    7. public int a;
    8. private List b;
    9.  
    10. public Packet40EntityMetadata() {}
    11.  
    12. public Packet40EntityMetadata(int i, DataWatcher datawatcher, boolean flag) {
    13. this.a = i;
    14. if (flag) {
    15. this.b = datawatcher.c();
    16. } else {
    17. this.b = datawatcher.b();
    18. }
    19. }
    20.  
    21. public void a(DataInputStream datainputstream) {
    22. this.a = datainputstream.readInt();
    23. this.b = DataWatcher.a(datainputstream);
    24. }
    25.  
    26. public void a(DataOutputStream dataoutputstream) {
    27. dataoutputstream.writeInt(this.a);
    28. DataWatcher.a(this.b, dataoutputstream);
    29. }
    30.  
    31. public void handle(Connection connection) {
    32. connection.a(this);
    33. }
    34.  
    35. public int a() {
    36. return 5;
    37. }
    38. }


    New version:

    Code:java
    1. import java.io.DataInput;
    2. import java.io.DataOutput;
    3. import java.util.List;
    4.  
    5. public class Packet40EntityMetadata extends Packet {
    6.  
    7. public int a;
    8. private List b;
    9.  
    10. public Packet40EntityMetadata() {}
    11.  
    12. public Packet40EntityMetadata(int i, DataWatcher datawatcher, boolean flag) {
    13. this.a = i;
    14. if (flag) {
    15. this.b = datawatcher.c();
    16. } else {
    17. this.b = datawatcher.b();
    18. }
    19. }
    20.  
    21. public void a(DataInput datainput) {
    22. this.a = datainput.readInt();
    23. this.b = DataWatcher.a(datainput);
    24. }
    25.  
    26. public void a(DataOutput dataoutput) {
    27. dataoutput.writeInt(this.a);
    28. DataWatcher.a(this.b, dataoutput);
    29. }
    30.  
    31. public void handle(Connection connection) {
    32. connection.a(this);
    33. }
    34.  
    35. public int a() {
    36. return 5;
    37. }
    38. }
     
    cnaude likes this.
  7. Offline

    cnaude


    Thanks!!
    Edit: I really wish github had side by side diff review. ;)
     
Thread Status:
Not open for further replies.

Share This Page