Custom Entity Crashes Server

Discussion in 'Plugin Development' started by BaddCamden, Sep 8, 2021.

  1. Offline

    BaddCamden

    I am trying to make a custom cow hit players after they attack the cow, however it crashes the server every time the cow attacks the player because the cow doesn't have the attribute DAMAGE. How do i give the cow in the most recent version 1.17.1 of Bukkit an attack attribute?
    Code:
    public class CustomSeaCow extends EntityCow{
        public CustomSeaCow(Location loc) {
            super(EntityTypes.n, ((CraftWorld) loc.getWorld()).getHandle());
            this.setPosition(loc.getX(), loc.getY(), loc.getZ());
            this.setCustomName(new ChatComponentText(org.bukkit.ChatColor.DARK_GREEN + "Sea Cow"));
            this.setCustomNameVisible(true);
            this.getAttributeMap().a(GenericAttributes.e);
            this.getAttributeInstance(GenericAttributes.e).setValue(300.0D);
        }
        @Override
        public void initPathfinder() {
            this.bQ.a(0, new PathfinderGoalHurtByTarget(this));
           
           
            this.bP.a(1, new PathfinderGoalMeleeAttack(this, 1.0d, true));
            this.bP.a(2, new PathfinderGoalMoveTowardsTarget(this, 1, 1));
            this.bP.a(3, new PathfinderGoalRandomLookaround(this));
            this.bP.a(4, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F));
           
        }
    }
    
     
  2. Offline

    BaddCamden

  3. Offline

    BaddCamden

    last bump, hope someone can figure this out
     

Share This Page