Solved Colored glowing on client-side entities

Discussion in 'Spigot Plugin Development' started by horgeon, Apr 30, 2017.

  1. I'm currently trying to add a colored glowing to a fake living entity using ProtocolLib.

    So far, I am successfully able to spawn the entity with the glowing effect.
    To add a color, I created a team using packets, and added both the player and the entity to it.
    The team is correctly registered client-side since no collisions occurs between the player and the fake entity (as specified), and the player has the team prefix correctly applied.

    However, the entity still shows a white glow, despite (apparently) setting team colors correctly.

    Here is the code I used to create the team:
    Code (Text):

    PacketContainer packet = protocolManager.createPacket( PacketType.Play.Server.SCOREBOARD_TEAM );
            packet.getIntegers().write( 1, 0 ); // Mode
            packet.getStrings().write( 0, "testteam" ); // Name
            packet.getIntegers().write( 0, 6 ); // Color
            packet.getStrings().write( 2, "ยง6" ); // Prefix
            packet.getStrings().write( 5, "never" ); // Collision rule
            packet.getSpecificModifier(Collection.class).write( 0, Arrays.asList( new String[]{ player.getName(), entityUuid.toString() } ) ); // Players/Entities
            try {
                protocolManager.sendServerPacket( player, packet );
            } catch ( InvocationTargetException ex ) {
                throw new RuntimeException( "Cannot send packet " + packet, ex );
    Am I missing something ? What do I need to do to make this entity have a colored glow, without others players seeing it ?
  2. I do know this, but since the entity is spawned only using packets (so that it is client-side only), I can't use the Spigot API for this.

    Also, sending an entity effect packet just tells the client that an entity has a potion effect, and does nothing more, so I actually have to make the entity glowing by myself using another packet. Still no colors, though, which is a pity.
  3. I did this a while ago and I'm on my phone so I'm going off of memory here, but first thing you have to do is:
    Call the setFlag() method on the entity with ththe int parameter as 6 and the Boolean as true.
    Then send a PacketPlayOutEntityMetadata with the parameters of the entity DataWatcher object(entity.getDataWatcher) as the first parameter and the second parameter as true (to update the entity I believe)
    Sorry if I got stuff wrong.
  4. My wording may have been a bit wrong here, my problem is not to make the entity glow, which I currently am able to do, but rather color that glowing so it isn't white, which I haven't succeeded.
  5. Oh. Sorry about that. You can use the spigot API for this pretty easily:
    Each player can have their own scoreboard which is pretty much the same thing as using packets for client specific things, but the server knows about it and you have API methods. Just make a new scoreboard object and set the player's scoreboard (player.setScoreboard()), then create teams with the prefix set to the color you want, then add the client side entity uuid as an entry to the player specific scoreboard.
    Sorry if my writing sucks. Still on my phone.
  6. Well, I've played a bit with the Spigot API and packets, and haven't got any success.
    The teams are correctly registered, but the entity glow is just not colored, no matter what I try, even with Spigot Scoreboards.
    I'm pretty sure I need to send additional informations, but at the moment, I can't put my finger on what I've missed.
  7. Can I see what you've tried? I got it working for me on an armorstand.
  8. Basically, my latest attempt using only the Spigot API was this:
    Code (Text):
    Scoreboard sb = Bukkit.getScoreboardManager().getNewScoreboard();
    Team team = sb.registerNewTeam( "testteam11" );
    team.setOption( Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER );
    team.setPrefix( ChatColor.GOLD + "" );
    team.addEntry( player.getName() );
    team.addEntry( entityUuid.toString() );
    player.setScoreboard( sb );
    I've set collision rule to never, so that I can test if the entity is effectively added to the team (which it does, because there is no collisions at all).
  9. What kind of entity is it?
    Also, you may need to add a dummy objective and set that to display slot sidebar. I think that's what I had to do.
  10. It is an entity created only using packets. But I've found my problem ! And it's kind of a lame one, I haven't sent the UUID in my packets... No wonder why it wasn't working.

    It works well now! With the Spigot API and with packets, using precisely the code I posted in my first post.
    Thanks for your help!