adding potion effects to player npc's

Discussion in 'Plugin Development' started by ResultStatic, May 1, 2014.

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

    ResultStatic

    so i want to add an invisibility potions to a npc that i created that works great. the whole point is so clients can still attack them and i can catch forcefielders, but normal players wont notice them. here is what i tried, it does not create any errors and it doesnt seem to do anything. i also tried PotionEffect and it didnt work either. fyi i know setting the private fields does the same thing as the parameter i tried with and without it.


    Code:
    public void addPotionEffect(MobEffect m) {
     
        byte type = (byte) m.getEffectId();
        short duration = (short) m.getDuration();
        byte amp = (byte) m.getAmplifier();
        PacketPlayOutEntityEffect potion = new PacketPlayOutEntityEffect(id,m);
        setPrivateField(PacketPlayOutEntityEffect.class, potion, "a", id);
        setPrivateField(PacketPlayOutEntityEffect.class, potion, "b", type);
        setPrivateField(PacketPlayOutEntityEffect.class, potion, "c", amp);
        setPrivateField(PacketPlayOutEntityEffect.class, potion, "d", duration);
        for (Player all : Bukkit.getOnlinePlayers()) {
        ((CraftPlayer) all).getHandle().playerConnection.sendPacket(potion);
        }
        }
     
  2. Offline

    t7seven7t

    ResultStatic Been a while since I actually played the game but won't the invisibility potion cause the npc to emit particles for everyone to see?

    Also from what I can tell you are only sending a packet with potion related information and not specifying the actual entity. Where have you assigned id and it is the entity's id? It would be much simpler if you just used the bukkit API to do this.
     
  3. Offline

    ResultStatic

    t7seven7t invis 2 doesnt show particles and the id system does work. sending other packet updates with the same id works. o and pretty sure u cant path entities with the bukkit api
     
  4. Offline

    ResultStatic

Thread Status:
Not open for further replies.

Share This Page