NMS Cant change a zombie into a villager zombie

Discussion in 'Plugin Development' started by NortherKnight, Oct 17, 2015.

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

    NortherKnight

    I'm trying to get a zombie villager but it always just spawns a normal villager :/
    I tryed overriding 2 methods:
    Code:
    @Override
    public boolean isVillager()
    {
        return true;
    }
       
    @Override
    public void setVillager(boolean flag)
    {
        getDataWatcher().watch(13, Byte.valueOf((byte)(1)));
    }
     
  2. Offline

    teej107

  3. Offline

    Xerox262

    Did you try calling setVillager(true); on your zombie? Without overriding the methods
     
  4. @NortherKnight
    When the new entity is created you need to set the value in the datawatcher, because no external source will call setVillager() when the entity is spawned.
     
  5. Offline

    NortherKnight

    1. I tryed to set it as a Villager with the bukkit API still gives me only a normal villager
    Code:
    for(Entity e : loc.getChunk().getEntities())
    {
        if(e.getType().equals(EntityType.ZOMBIE)
        {
            Zombie z = (Zombie) e;
            z.setVillager(true);
        }
    }
    And i tryed setting the difficulty to hard but still only a villager
    2. I dont know what you mean by setting the date watcher when the entity spawns maybe this:
    Code:
    @Override
        public void a(EntityLiving entityliving)
        {
            super.a(entityliving);
           
             EntityInsentient entityinsentient = (EntityInsentient)entityliving;
             EntityZombie entityzombie = new EntityZombie(this.world);
             
             entityzombie.m(entityliving);
             this.world.kill(entityliving);
             entityzombie.prepare(this.world.E(new BlockPosition(entityzombie)), null);
             entityzombie.setVillager(true);
             if (entityliving.isBaby()) {
               entityzombie.setBaby(true);
             }
             entityzombie.k(entityinsentient.ce());
             if (entityinsentient.hasCustomName())
             {
               entityzombie.setCustomName(entityinsentient.getCustomName());
               entityzombie.setCustomNameVisible(entityinsentient.getCustomNameVisible());
             }
             this.world.addEntity(entityzombie, CreatureSpawnEvent.SpawnReason.INFECTION);
             this.world.a(null, 1016, new BlockPosition((int)this.locX, (int)this.locY, (int)this.locZ), 0);
           
        }
     
Thread Status:
Not open for further replies.

Share This Page