Solved [NMS] Trouble disguising player as a mob

Discussion in 'Spigot Plugin Development' started by eccentric, Jan 24, 2020.

  1. I'm trying to disguise players as various mobs, all is going well - the disguises are applied and are visible to other players.
    The issue arises when I want to disguise, for example, a player as a specific coloured sheep - the disguise is applied but the sheep is always the default white colour.

    My disguise constructor is here:
    The sheep colouring is:
    Code (Text):
    case SHEEP:
        EntitySheep sheep = (EntitySheep) entity;
    Where o is an instance of org.bukkit.DyeColor
    AFAIK setColor() sets the datawatcher object for the entity.

    The disguise is being sent to players with PacketPlayOutSpawnEntityLiving packets - relevant code is here:
    I call my API method:
    Code (Text):
    public void disguise(EntityType entityType, Player player, Object[] options) {
        new TARDISDisguiser(entityType, player, options).disguiseToAll();
    I've added some debug output to the console to check the entity after the disguise options have been applied and when the packet is being sent and the output says that the sheep is the correct colour...

    What else do I need to do?
  2. As far as I can see, you are not sending any Metadata values, is that correct?
    If so, you also have to send those (the packet is called something like PacketPlayOutEntityMetadata or something. Should take the entity‘s datawatcher)
    #2 Schottky, Jan 24, 2020
    Last edited: Jan 24, 2020
    • Winner Winner x 1
  3. Perfect, that did the trick, thank you very much.