ProtocolLib

3M Downloads

Team packet 1.15 broken

Chasewhip8 opened this issue · 9 comments

commented

Describe the bug
The packer for SCOREBOARD_TEAM has not changed on the protocol wiki however it does not work when tested in-game.

To Reproduce
Steps to reproduce the behavior:
Send a team update packet to add entities to an already created team.

Expected behavior
The team on the entity changes for the client. A color can be used with the glowing effect on the entity to point this out further

Screenshots
If applicable, add screenshots to help explain your problem.

Version Info
Provide your ProtocolLib install info with /protocol dump through Pastebin.

Additional context
The code worked on 13 and 14.

commented

Code used to color the fake entity

PacketContainer packet = protocolManager.createPacket(PacketType.Play.Server.SCOREBOARD_TEAM);

    packet.getStrings()
            .write(0, getColor().toString());
    packet.getIntegers().write(0, 3);

    packet.getSpecificModifier(Collection.class)
            .write(0, getEntityUUIDs()); // List of uuid's of the fake entities to add to the team

    try {
        protocolManager.sendServerPacket(getOwner(), packet);
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    }

`

Code used to spawn a magma cube in the center of a block defined by dx and dz
`

    double dx;
    double dz;

    dx = x + 0.5;
    dz = z + 0.5;

    PacketContainer packet = protocolManager.createPacket(PacketType.Play.Server.SPAWN_ENTITY_LIVING);

    int EntityID = VisualizeUtils.generateRandomID(getOwner());
    UUID uuid = VisualizeUtils.getRandomUUID(getOwner());

    packet.getIntegers()
            .write(0, EntityID)
            .write(1, 41);//38  //Entity id //1.14: 40
    packet.getUUIDs()
            .write(0, uuid);
    packet.getDoubles() //Cords
            .write(0, dx)
            .write(1, (double) y)
            .write(2, dz);

    addEntity(EntityID, uuid.toString());
    entityLocations.put(EntityID, new Location(getOwner().getWorld(), dx, (double) y, dz));

    PacketContainer metaDataPacket = protocolManager.createPacket(PacketType.Play.Server.ENTITY_METADATA);

    WrappedDataWatcher watcher = new WrappedDataWatcher();

    watcher.setObject(0, byteSerializer, (byte) (0x20 | 0x40)); // Glowing Invisible
    watcher.setObject(15, integerSerializer, 2); //Slime size : 12

    metaDataPacket.getIntegers()
            .write(0, EntityID);
    metaDataPacket.getWatchableCollectionModifier()
            .write(0, watcher.getWatchableObjects());

    try {
        protocolManager.sendServerPacket(getOwner(), packet);
        protocolManager.sendServerPacket(getOwner(), metaDataPacket);
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    }

`

commented

So what happens? Is there a client/server error? or does it just not work?

commented

I would suspect it not working on an update but it seems the protocol didn’t change so that’s where I’m getting tripped up.

commented

Can you provide some code?

commented

Still can't seem to get a working implementation of this packet, ether it's my mess up, protocol libs or an undocumented change in this protocol.

commented

My guess would be that it's an undocumented change in the protocol. The guys at the wiki are pretty good, but sometimes things slip past. I can't think of anything that would point to it being something on PL's end.

commented

To clarify how I can tell when the team changes, the above code spawns in a magma cube that is invisible and glowing, when there is no team set they render as white and when a team is set they are rendered as the color the team is set up as. To update the team, the above code sends the list of fake entity UUIDs to the player along with the team name needed for the packet. I can see the teams not applying because the glowing effect on the entity does not change colors. Thanks, MiniDigger for pointing out my horrible explanation.

commented

I've now checked in NMS and there is no change to how the team packet for mode 3 (update) is handled.
`

    packetdataserializer.a(this.a);
    packetdataserializer.writeByte(this.i);
    if (this.i == 0 || this.i == 2) {
        packetdataserializer.a(this.b);
        packetdataserializer.writeByte(this.j);
        packetdataserializer.a(this.e);
        packetdataserializer.a(!com.destroystokyo.paper.PaperConfig.enablePlayerCollisions ? "never" : this.f); // Paper
        packetdataserializer.a((Enum) this.g);
        packetdataserializer.a(this.c);
        packetdataserializer.a(this.d);
    }
    if (this.i == 0 || this.i == 3 || this.i == 4) {
        packetdataserializer.d(this.h.size());
        Iterator iterator = this.h.iterator();

        while (iterator.hasNext()) {
            String s = (String) iterator.next();

            packetdataserializer.a(s);
        }
    }

`

commented

Turns out to be something else, not protocol libs fault