Entity textures not updating correctly

Discussion in 'Plugin Development' started by Reflxction, Sep 29, 2017.

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

    Reflxction

    Hello,
    so I've been messing a bit with NMS and creating random entities. One thing is that the entity textures are messed up.
    It appears as a zombie texture
    [​IMG]

    But it's supposed to be a chicken texture, when I hit the entity the chicken sound comes, and the behavior is the chicken's, but the texture is a zombie.

    Code:
    Code:
    package net.xtechno.punchbags;
    
    import org.bukkit.entity.Chicken;
    
    import net.md_5.bungee.api.ChatColor;
    import net.minecraft.server.v1_11_R1.EntityChicken;
    import net.minecraft.server.v1_11_R1.EntityCow;
    import net.minecraft.server.v1_11_R1.PathfinderGoalNearestAttackableTarget;
    import net.minecraft.server.v1_11_R1.World;
    
    public class Punchbags extends EntityChicken {
    
        public Punchbags(World world) {
            super(world);
            Chicken chicken = (Chicken) this.getBukkitEntity();
            chicken.setMaxHealth(50);
            this.setHealth(50);
            this.setCustomName(ChatColor.GOLD + "Punchbag");
            this.setCustomNameVisible(true);
            this.targetSelector.a(0,
                    new PathfinderGoalNearestAttackableTarget<EntityCow>(this, EntityCow.class, true));
            this.getWorld().addEntity(this);
        }
    }
    
    It works well when it's a zombie

    Any help would be much appreciated. Thanks

    PS: One more thing, if it's an entity like a pig or a wolf, it becomes invisible and appears after the server is restarted.
     
  2. Offline

    flo077

    I dont know how it is working in 1.11, i know 1.12 and 1.10, do you register this entity somewhere?
     
  3. Offline

    Reflxction

    @flo077 Yes it's registered, and all of them are registering it as a chicken.
     
  4. Offline

    flo077

    can you show your registering code then?
     
  5. Offline

    Reflxction

    Sorry, I was registering it as "54" which appears to be zombie and not a chicken :p
    On a side note, is it possible to make the chicken target and attack players? I tried setting its target to EntityPlayer.class but didn't work. Any idea?
     
  6. Offline

    flo077

    Did it worked with the EntityCow.class,in the code you posted?
     
  7. Offline

    Reflxction

    @flo077 Nope, if it extends EntityChicken it doesn't target, but if it extends EntityZombie it does. Probably cause of chickens not targeting any entity due to minecraft's physics :/
     
  8. Offline

    flo077

    I knew it couldn't work as you wrote in the code, i wanted to be sure.
    It doesn't work because the Chicken doesn't have any pathfinger using the targeted entity set by your
    PathfinderGoalNearestAttackableTarget.
    There is this line in the EntityZombie.class:
    goalSelector.a(2, new PathfinderGoalZombieAttack(this, 1.0D, false));

    in facts, PathfinderGoalZombieAttack extends PathfinderGoalMelleAttack,
    you can just use this second one.
    that should be your code to initiate it:
    goalSelector.a(0, new PathfinderGoalMeleeAttack(this, 1.0D, false));

    But i dont know how many damages the chicken will do.
     
    1 person likes this.
  9. Offline

    Reflxction

    @flo077 Thanks for those information, but the chicken is still not targeting zombies
     
Thread Status:
Not open for further replies.

Share This Page