Citizens NPC set invisible?

Discussion in 'Plugin Development' started by ZomBlade_Shadow, Jun 12, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    ZomBlade_Shadow

    Hello.
    I'm using the Citizens API, I made NPC players but can't find out how to make the NPC's invisible.

    Code:
                            final NPC bat1 = registry.createNPC(EntityType.PLAYER, p.getName());
                              final NPC bat2 = registry.createNPC(EntityType.PLAYER, p.getName());
                              final NPC bat3 = registry.createNPC(EntityType.PLAYER, p.getName());
                              bat1.spawn(p.getLocation().add(2, 0, 0));
                              bat2.spawn(p.getLocation().add(0, 0, 2));
                              bat3.spawn(p.getLocation().add(0, 2, 0));
                             
                    bat1.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 100, 1));
    I tried different ways like
    Code:
    bat1.getBukkitEntity().addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 100, 1));
    Code:
    ((LivingEntity) bat1).addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 100, 1));
    EDIT: Even throwing invisibility potions doesn't work, so I'll have to play with packets maybe?
    Or maybe do like bat1.showPlayer() or hidePlayer()?
    I have no clue as it's the first time I use Citizens, and i've been looking for hours.

    Nevermind, works perfect with this.
    https://bukkit.org/threads/entity-shown-only-to-specific-player-s.155715/
    @Comphenix You're a god when it comes to developing, thanks!

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

Share This Page