Play bow draw packet

Discussion in 'Plugin Development' started by crolemol, Oct 18, 2014.

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

    crolemol

    Hey,

    I would like to know which packet I have to send to play the draw bow animation. I know it is the entity metadata one but I don't understand how it does work can somebody help me?

    PS did already read Comphenix thread but still don't understand it
     
  2. Offline

    mine-care

    Umm what you mean the draw bow, when?
    I don't know the solution about packets I never liked nms code and the only reason I used packets was for particle effects :3
    Sorry I'm not that helpfull...
     
  3. Offline

    Assist

    mine-care
    He wants to play the "draw bow" animation. This is the animation that plays when you get ready to shoot with a bow, the string draws and stretches.
     
  4. Offline

    mine-care

    Yeah I understood that but I didn't understood when, when they right click with a bow? When? ( I might be interested on that that's why I ask mostly :3) Assist
    =]
     
  5. Offline

    xTrollxDudex

    I haven't been able to find anything for pulling back the bow, my guess is the information about where the arrow should be shot is sent after the client renders the bow pullback on its own, if that is the case, you'd have to modify the client in order to make it appear like the player is pulling the bow back.
     
    FerusGrim likes this.
  6. Offline

    FerusGrim

    I'm fairly certain that xTrollxDudex is right. The bow pull-back is just one of those things that the client doesn't natively send or receive updates about.
     
  7. Offline

    crolemol

    xTrollxDudex FerusGrim

    Comphenix said that the client sends a metadata packet to the server which cause that the server to show a drawwed Bow

    What is that packet?
     
  8. Offline

    xTrollxDudex

    He was most likely referring to http://wiki.vg/Protocol#Entity_Metadata or PacketPlayOutEntityMetadata (I may be wrong), but nothing indicates it could be used to show the bow drawback.
     
  9. Offline

    crolemol

    xTrollxDudex
    He was indeed referring to that. But it how does the server handle that animation if it is client side. Is there another way to make an npc fire a bow?
     
  10. Offline

    xTrollxDudex

    Hm, you're correct on that one. I'm still digging for it right now.

    Edit: https://forums.bukkit.org/threads/bukkit-send-player-bow-drawback-packet.153347/

    Try that. If all else fails, use protocol lib to listen for metadata packets and intercept them when you're drawing a bow.
     
  11. Offline

    crolemol

    xTrollxDudex
    thanks, I know how it is handled. when a player start drawing the bow the client sends a entity metadata packet to the server and when the player releases his bow it sends another packet which clears the metadata.
    I don't know anything about packets so I don't know which packets I have to send
     
  12. Offline

    xTrollxDudex

    PacketPlayOutEntityMetadata
     
  13. Offline

    crolemol

    xTrollxDudex
    Thanks, Already found that but I don't understand comphenix's post. Which metadata packet do I have to send and which data must be in there?

    Edit: thanks and which data must have it?ps i am trying to make an npc draw a bow
     
  14. Offline

    xTrollxDudex

    I haven't been able to find the right click data yet, but could you point me to his post?
     
  15. Offline

    Dudemister1999

    To my knowledge, it was called by PlayerAnimationEvent, maybe check where that's called? I can dig up some code if required.
     
  16. Offline

    crolemol

    Last edited by a moderator: Jun 14, 2016
  17. Offline

    crolemol

    xTrollxDudex Dudemister1999 Comphenix
    Did listen for the entity metadata event and did notice that a packet with the id 804 is send every time a draw or release my bow. the data of it declares the state. this is my code
    EDIT: it's not always 804 it changes every reload? to what is it declared
    Code:java
    1.  
    2. DataWatcher data = new DataWatcher(getNPC());
    3. data.add(16, 0);
    4. PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(804, data, true);
    5. for(Player player : Coc.getPlugin().getServer().getOnlinePlayers()){
    6. CraftPlayer cp = (CraftPlayer) player;
    7. cp.getHandle().playerConnection.sendPacket(packet);
    8. }

    When I run it the server kicks my out with an exception. any ideas?
    exception:
    Code:
    sander lost connection: Internal Exception: net.minecraft.util.io.netty.handler.codec.EncoderException: java.lang.NullPointerException
    edit : my packet looked up with potocollib
    Code:
    [20:07:51 INFO]: [ProtocolLib] Sent PacketPlayOutEntityMetadata[28, legacy: 40] to sander:
    { a = 804, b = ([16: null (Byte)]) }
    Edit: longer exception
    Code:
    [20:07:51 INFO]: [ClashOfClans] 393.0
    [20:07:51 WARN]: net.minecraft.util.io.netty.handler.codec.EncoderException: java.lang.RuntimeException: An internal error occured.
    [20:07:51 WARN]:    at net.minecraft.util.io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:129)
    [20:07:51 WARN]:    at com.comphenix.protocol.injector.netty.ChannelInjector$3.write(ChannelInjector.java:217)
    [20:07:51 WARN]:    at net.minecraft.util.io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644)
    [20:07:51 WARN]:    at net.minecraft.util.io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698)
    [20:07:51 WARN]:    at net.minecraft.util.io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:688)
    [20:07:51 WARN]:    at net.minecraft.util.io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:717)
    [20:07:51 WARN]:    at net.minecraft.util.io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:893)
    [20:07:51 WARN]:    at net.minecraft.util.io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:239)
    [20:07:51 WARN]:    at com.comphenix.protocol.injector.netty.ChannelProxy.writeAndFlush(ChannelProxy.java:269)
    [20:07:51 WARN]:    at net.minecraft.server.v1_7_R4.QueuedProtocolSwitch.run(SourceFile:143)
    [20:07:51 WARN]:    at com.comphenix.protocol.injector.netty.ChannelInjector$5$2.run(ChannelInjector.java:273)
    [20:07:51 WARN]:    at net.minecraft.util.io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354)
    [20:07:51 WARN]:    at net.minecraft.util.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:348)
    [20:07:51 WARN]:    at net.minecraft.util.io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
    [20:07:51 WARN]:    at java.lang.Thread.run(Thread.java:745)
    [20:07:51 WARN]: Caused by: java.lang.RuntimeException: An internal error occured.
    [20:07:51 WARN]:    at com.comphenix.protocol.reflect.accessors.DefaultMethodAccessor.invoke(DefaultMethodAccessor.java:20)
    [20:07:51 WARN]:    at com.comphenix.protocol.injector.netty.ChannelInjector.encode(ChannelInjector.java:403)
    [20:07:51 WARN]:    at com.comphenix.protocol.injector.netty.ChannelInjector$3.encode(ChannelInjector.java:212)
    [20:07:51 WARN]:    at net.minecraft.util.io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:111)
    [20:07:51 WARN]:    ... 14 more
    [20:07:51 WARN]: Caused by: java.lang.NullPointerException
     
Thread Status:
Not open for further replies.

Share This Page