Odd mob gear Issue

Discussion in 'Plugin Development' started by mncat77, Oct 30, 2012.

Thread Status:
Not open for further replies.
  1. I messed around a little bit with geared mobs and got an odd Issue: I tried to spawn a zombie with a colored chestplate and got one with colored pants. I have no idea what I have done wrong...

    Code:

    Spawning the Zombie and giving him Equipment:
    Code:
                    Entity entity = player.getWorld().spawnEntity(location, EntityType.ZOMBIE);
                    setWeapon(entity, new CraftItemStack(267));  //You can ignore this
                    CraftItemStack chestplate = new CraftItemStack(Material.LEATHER_CHESTPLATE);
                    CraftItemStack cchestplate = colorArmor(chestplate,255,0,0);
                    setChestplate(entity, cchestplate);
    The coloring method:
    Code:
        private CraftItemStack colorArmor(CraftItemStack item, int r, int g, int b){
            int color = (r << 16) | (g << 8) | b;
            NBTTagCompound nbttag = new NBTTagCompound();
            NBTTagCompound tag = new NBTTagCompound();
            NBTTagCompound display = new NBTTagCompound();
            nbttag.setCompound("tag", tag);
            nbttag.setCompound("display", display);
            display.set("color", new NBTTagInt("color", color));
            item.getHandle().tag = nbttag;
            return item;
        }

    The setChestplate method:
    Code:
    public static void setChestplate(Entity entity, CraftItemStack item){
        EntityLiving lEntity = ((CraftLivingEntity)entity).getHandle();
        net.minecraft.server.ItemStack itemStack = item.getHandle();
        lEntity.setEquipment(2, itemStack);
    }
    Well apparently bukkit knows that it's a chestpiece and does the stuff right but sends the client packets with wrong info.... Hopefully this will get fixed until the RB...

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 29, 2016
Thread Status:
Not open for further replies.

Share This Page