Solved Fake player no overlay (1.15 & 1.16)

Discussion in 'Spigot Plugin Development' started by Streampy, Jun 30, 2020 at 11:41 PM.

  1. So as my title saids, I am currectly updating my fake player (npc) script it uses reflect but I can't make it work for 1.15 & 1.16. Can anyone tell me what I am doing wrong?

    I read already:
    https://www.spigotmc.org/threads/packetplayoutbed-in-1-14.372214/#post-3860874 -> This one fixes my issue for 1.13 & 1.14
    https://www.spigotmc.org/threads/npc-spawning-1-15.411692/ -> This didn't fix anything because its not really explained as in why its got fixed because of it or what the problem was? (And its hard too change my code over that, so I want to have other suggestions first)

    Code (Java):
                //DataWatcher
                Class<?> dataWatcherClass = reflect.getNMSClass("DataWatcher");
                Class<?> entityClass = reflect.getNMSClass("Entity");
                Constructor<?> dataWatcherConstr = dataWatcherClass.getConstructor(entityClass);
                Object dataWatcherObj = dataWatcherConstr.newInstance(new Object[]{null});
             
             
                Class<?> dataWatcherObjectClass = reflect.getNMSClass("DataWatcherObject");
                Method registerMethod = dataWatcherClass.getMethod("register", dataWatcherObjectClass, Object.class);
                Class<?> dataWatcherSerializerClass = reflect.getNMSClass("DataWatcherSerializer");
                Constructor<?> dataWatcherObjectConstr = dataWatcherObjectClass.getConstructor(int.class, dataWatcherSerializerClass);
                Class<?> dataWatcherRegistry = reflect.getNMSClass("DataWatcherRegistry");

                //overlay still doesn't work on 1.15 & 1.16
                Object a = dataWatcherRegistry.getField("a").get(null);
                Object dataWatcherObjectObjA = dataWatcherObjectConstr.newInstance((reflect.newRecipeSystem() && !reflect.getVersion().equals("v1_13_R1") ? 15 : 13), a);
                registerMethod.invoke(dataWatcherObj, dataWatcherObjectObjA, (byte) 79);
             
                Constructor<?> PacketPlayOutEntityMetadataConstructor = reflect.getNMSClass("PacketPlayOutEntityMetadata").getConstructor(int.class ,dataWatcherClass, boolean.class);
                Object PacketPlayOutEntityMetadata =  PacketPlayOutEntityMetadataConstructor.newInstance(reflect.getNMSClass("EntityPlayer").getMethod("getId").invoke(rec.npc), dataWatcherObj, true);
                sendPacket.invoke(reflect.getConnection(player), PacketPlayOutEntityMetadata);
    Would love too hear suggestion what its causing not too work or what I am doing wrong.

    Things I tried:
    increasing the number for datapackage too change from 15 to 16 etc (Didn't change anything)
    increasing the value of the number from 79 to 127 (Didn't change anything)
     
  2. For those that can't help because I use reflect (NMS)


    Code (Java):
    PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;      
            connection.sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER, (EntityPlayer) rec.npc));
            connection.sendPacket(new PacketPlayOutNamedEntitySpawn( (EntityPlayer) rec.npc));
            connection.sendPacket(new PacketPlayOutEntityHeadRotation( (EntityPlayer) rec.npc, (byte) ((rec.loc.getYaw() * 256.0F) / 360.0F)));  
           
            DataWatcher watcher = ((EntityPlayer) rec.npc).getDataWatcher(); //new DataWatcher(null) //((EntityPlayer) rec.npc).getDataWatcher()
            //watcher.register(new DataWatcherObject<>(6, DataWatcherRegistry.c), (float) 20F);
            watcher.register(new DataWatcherObject<>(15, DataWatcherRegistry.a), (byte) 79); //70 = Alles behalve cape //79 = Alles
           
            connection.sendPacket(new PacketPlayOutEntityMetadata( ((EntityPlayer)rec.npc).getId(), watcher, true));
     
  3. values changes everytime xd
     
  4. Yeah but this is just annoying xD
    For 1.12 & 1.13 overlay a value is 13,
    for 1.14 its 15
    for 1.15 & 1.16 its 16
    (This will probably help people that are using overlay and can't figure it out, No problem!)
     
    • Informative Informative x 1