ProtocolLib disguise entity

Discussion in 'Spigot Plugin Development' started by Bolt, May 17, 2015.

  1. I was wondering if there was a way to disguise an entity as something else in protocol lib or to make an entity invisible. Could someone please explain how?
     
  2. Either block their outgoing spawn packet (spawn invisible entity), or send a DestroyEntity packet with their ID (make entity invisible)
     
  3. @DarkSeraphim Sorry I'm still quite new to using ProtocolLib. How would I do this?
     
  4. @DarkSeraphim I've got this code:
    Code (Text):
    PacketContainer hideArrow = Main.protocol.
                            createPacket(PacketType.Play.Server.ENTITY_DESTROY);


                    try {
                        Main.protocol.sendServerPacket(player, hideArrow);
                    } catch (InvocationTargetException e1) {
                        throw new RuntimeException(
                            "Cannot send packet " + hideArrow, e1);
                    }
    I don't know what to put after I create the packet though. How would I add the entity ID?
     
  5. Open Spigot in a decompiler, find the packet class, and check the fields. Then fill the fields accordingly (ex. the first int can be modified by getting the Integer StructureModifier (getIntegers()) and calling write(0, newValue) on that). For more information regarding specific fields, you can also check http://wiki.vg/protocol.

    Alternatively, you can check PacketWrapper, a utility to make packet sending easier ;).
     
  6. @DarkSeraphim Hey, sorry for bringing this up again. I'm doing what you said though I don't think I did it right since it's not working. Here is my code:
    Code (Text):
    PacketContainer hideArrow = Main.protocol.
                            createPacket(PacketType.Play.Server.ENTITY_DESTROY);
                   
                    hideArrow.getIntegers().write(0, arrow.getEntityId());
                    WrapperPlayServerEntityDestroy p = new WrapperPlayServerEntityDestroy(hideArrow);
                    p.sendPacket(player);