Chest open animation?

Discussion in 'Plugin Development' started by Innofly, May 25, 2014.

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

    Innofly

    Hey guys, I would like to know if there is a way to create a chest open animation without opening the GUI?
    Thanks :)
     
  2. Offline

    thecrystalflame

    theres no proper way to do this, maybe with packets. but the opening of the chest is actually handled client side.
     
  3. Offline

    xize

  4. Offline

    rsod

    Actually it should be possible, since animation is playing when another player opening chest, so it's not client side, but I don't know how to do that exactly so you need to do some research
     
  5. Offline

    xTigerRebornx

  6. Offline

    Innofly

    xTigerRebornx I've never used packets... Could someone teach me or do someone have a tutorial?
     
  7. Offline

    xTigerRebornx

    Innofly If you know Reflection, it'll help make your code work cross-versions. Basically, you can take a few different paths.
    Path 1: Directly use NMS (will break on every Revision change)
    For directly using NMS, you'll want to make a new PacketPlayOutBlockAction, the values for each parameter are on the link I posted in my first post. Then' you'll want to get the Handle of a CraftPlayer (invoking getHandle() on a CraftPlayer), then get the playerConnection field, and call sendPacket() on it, passing in the PacketPlayOutBlockAction.

    Path 2: Using Reflection to send the packet (Won't break unless the getHandle() method, playerConnection field, or constructor for the packet changes)
    You'll want to use reflection to access the versioned classpath for all of the needed classes (CraftPlayer, PacketPlayOutBlockAction), as well as use reflection to invoke getHandle, get the playerConnection field, and invoke sendPacket. Basically, mimic path one, but using reflection to dynamically get the version and its respective classes.

    NMS is tricky, and can be dangerous if you don't know what you are doing :p
    If any of the "NMS Pros" want to point out any problems with my post, feel free.
     
  8. Offline

    rsod

    xTigerRebornx He can actually use ProtocolLib for backward compability.
     
  9. Offline

    xTigerRebornx

    rsod He could, if he doesn't mind having a dependency.
     
  10. Offline

    Innofly

  11. Offline

    xTigerRebornx

    Innofly Honestly, if you don't mind the dependency, use ProtocolLib, it'll make it a massive amount easier.
     
    NathanWolf likes this.
  12. Offline

    Innofly

    xTigerRebornx I'll check that out.

    xTigerRebornx But I can't find the right packet using protocol lib. :l

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

    xTigerRebornx

  14. Offline

    Innofly

    xTigerRebornx When I do something like that nothing happen:

    Code:
    PacketContainer blockAction = new PacketContainer(PacketType.Play.Server.BLOCK_ACTION);
                blockAction.getBlocks().write(0, Material.CHEST);
                              try {
                                protocolManager.sendServerPacket(event.getPlayer(), blockAction);
                            } catch (InvocationTargetException e) {
                                e.printStackTrace();
                            }
     
  15. Offline

    xTigerRebornx

    Innofly It may be because you aren't giving the packet all of its required data, it requires 5 ints and a Block (As specified by PacketPlayOutBlockAction's constructor), where the ints are:
    x, y, z, "Byte 1", "Byte 2" where Byte 1 and 2 are defined by http://wiki.vg/Block_Actions
     
  16. Offline

    oasis9

    Anyone still here? Sorry about the necro.
     
Thread Status:
Not open for further replies.

Share This Page