Jump to content

FISH Bobbing


dragonz12345

Recommended Posts

Hello, I have just created a Fish Mob, And when It is swimming, it keeps bobbing up and down in the water...

Can anyone help me please?

 

Here is my EntityFish code:

 

 

public class EntityFish extends EntityWaterMob {

    private int randomMotionVecX;
	private int randomMotionSpeed;
	private int randomMotionVecY;
	private int randomMotionVecZ;

	public EntityFish(World par1World)
    {
     super(par1World);
     tasks.addTask(0, new EntityAIMoveToWater(this, this.worldObj));
     tasks.addTask(1, new EntityAISwimmingFish(this));
     tasks.addTask(2, new EntityAIPanic(this, 0.38F));
     tasks.addTask(3, new EntityAIWander(this, 0.3F));
    }
    
    protected void applyEntityAttributes()
    {
        super.applyEntityAttributes();
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(1D);
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(10.0D);
    }
    
    public boolean isAIEnabled()
    {
        return true;
    }

public boolean canBreatheUnderwater()
    {
        return true;
    }

protected boolean canDespawn()
    {
        return true;
    }

protected Item func_146068_u()
    {
        return Items.fish;
    }

public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
    {
        super.writeEntityToNBT(par1NBTTagCompound);
    }

public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
    {
        super.readEntityFromNBT(par1NBTTagCompound);
    }
    
    public boolean getCanSpawnHere()
    {
        return worldObj.checkNoEntityCollision(boundingBox);
    }
    
    public boolean isInWater()
    {
        return this.worldObj.handleMaterialAcceleration(this.boundingBox.expand(0.0D, -0.6000000238418579D, 0.0D), Material.water, this);
    }{
    
        if (!this.worldObj.isRemote)
        {
            this.motionX = (double)(this.randomMotionVecX * this.randomMotionSpeed);
            this.motionY = (double)(this.randomMotionVecY * this.randomMotionSpeed);
            this.motionZ = (double)(this.randomMotionVecZ * this.randomMotionSpeed);
}
}
}

Link to comment
Share on other sites

The Problem should be some of the AIs you are using. I guess EntityAIPanic, EntityAIWander or EntityAIMoveToWater try to swim on the water rather than diving in it so they wont drown.

PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.