Help with PacketPlayOutSetSlot!

Discussion in 'Plugin Development' started by Paxination, Jan 11, 2014.

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

    Paxination

    xTrollxDudex

    Code:java
    1. CraftPlayer p = (CraftPlayer) getPlayer();
    2. net.minecraft.server.v1_7_R1.ItemStack item = new net.minecraft.server.v1_7_R1.ItemStack(net.minecraft.server.v1_7_R1.Item.d(262));
    3.  
    4. PacketPlayOutSetSlot packet = new PacketPlayOutSetSlot();
    5. try {
    6. Field field = packet.getClass().getDeclaredField("a");
    7. field.setAccessible(true);
    8. field.setInt(packet, 0);
    9. field.setAccessible(false);
    10. field = packet.getClass().getDeclaredField("b");
    11. field.setAccessible(true);
    12. field.setInt(packet, 9);
    13. field.setAccessible(false);
    14. field = packet.getClass().getDeclaredField("c");
    15. field.setAccessible(true);
    16. field.set(packet, item);
    17. field.setAccessible(false);
    18. } catch (NoSuchFieldException e) {
    19. // TODO Auto-generated catch block
    20. e.printStackTrace();
    21. } catch (SecurityException e) {
    22. // TODO Auto-generated catch block
    23. e.printStackTrace();
    24. // TODO Auto-generated catch block
    25. e.printStackTrace();
    26. // TODO Auto-generated catch block
    27. e.printStackTrace();
    28. }
    29. p.getHandle().playerConnection.sendPacket(packet);


    I dont get any errors with this. I am trying to put a fake arrow in the players inventory. Probably doing the Item wrong. But the class methods that i get in eclipse for that packet dont match up with what's in mc-dev

    I am setting the fields manually because the jar file that i have (latest one) doesnt have the same constructors as on that link.

    What am I doing wrong here?
     
  2. Offline

    ResultStatic

    Paxination im not really sure if you are getting an item with that by id but you can use items. instead of item
    for instance:
    net.minecraft.server.v1_7_R1.ItemStack item = new net.minecraft.server.v1_7_R1.ItemStack(net.minecraft.server.v1_7_R1.Items.LEASH

    they changed it from item.LEASH to items.LEASH or in your case an arrow
     
  3. Offline

    Paxination

    I was wandering where it was. But that didnt help tho. Still no arrow in my inventory.
     
  4. Offline

    xTrollxDudex

  5. Offline

    Paxination

    xTrollxDudex

    I tried, eclipse is giving me errors over it and not giving me the option to import its package or what ever.

    I just tried importing org.bukkit.entity.Item and that didnt help either.


    ARROW cannot be resolved or is not a field
     
  6. Offline

    xTrollxDudex

    Paxination
    Sorry, I was looking at the outdated version. Why don't you use the constructor indtead of manually setting the fields?
     
  7. Offline

    Paxination

    xTrollxDudex

    xTrollxDudex

    Ok I was building against the latest build of spigot. I switched to the latest build of bukkit 1.7.2.R0.3 and the constructor is there. But its still not working.

    Code:java
    1. CraftPlayer cPlayer = (CraftPlayer) getPlayer();
    2. PacketPlayOutSetSlot packet = new PacketPlayOutSetSlot(0,1,new net.minecraft.server.v1_7_R1.ItemStack(net.minecraft.server.v1_7_R1.Items.ARROW));
    3. cPlayer.getHandle().playerConnection.sendPacket(packet);


    Current code!

    *EDIT* btw, getPlayer() is a custom method that gets the player instance for me.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
Thread Status:
Not open for further replies.

Share This Page