Solved Packet entity (npc) right click

Discussion in 'Spigot Plugin Development' started by dentoffe, Jan 13, 2020.

  1. So I'm making this NPC plugin where I use packets instead of Entity's.
    So of course the Player Interact with entity event won't work

    But is there a way to making it so I can detect whether the npc packet is being clicked?

    I don't want to use entities for performance reasons.

    I did some research but couldn't find the answer.

    => Using Protocolib
    Code (Text):
    private void packetRegister() {
            plugin.getProtocolManager().addPacketListener(new PacketAdapter(this.plugin, ListenerPriority.NORMAL, PacketType.Play.Client.USE_ENTITY) {
                public void onPacketReceiving(PacketEvent event) {
                    if (event.getPacketType() == PacketType.Play.Client.USE_ENTITY) {
                        event.getPlayer().sendMessage("You clicked a packed");

    #1 dentoffe, Jan 13, 2020
    Last edited: Jan 14, 2020
  2. why wouldnt interacting with it work? the client thinks theres an entity, so it sends a packet that it hit an entity. find the incoming packet related to a client hitting an entity and do what you need to do, since it just gets ignored otherwise.
  3. I don't think there is an entity? I only sent the packet of the entity instead of spawning the entity.. When I right click a pig for example it works but when clicking my npc it doesn't do anything
  4. thats not what im getting at. the client THINKS theres an entity, so it sends a packet that it hit the entity. the packet gets ignored because its not valid but you should be able to monitor the incoming packets and find that "invalid" packet that refers to the packet entity you sent.

    /e the client has 0 information that the server does. regardless or not the server has an object for the entity, if you send a packet to spawn the entity, thats all the client knows. the client doesnt magically know if theres an object in the server or not. a packet is a packet
    • Useful Useful x 1
  5. FrostedSnowman

    Resource Staff

    • Like Like x 1
  6. nah. it should be obvious if you look at the protocols wiki but if not you can list all packet values, print the name of the packet, filter the ones that spam the console, and just spam interact with an entity and see what packet shows up

    /e or have someone who knows reply