Jump to content

Recommended Posts

Posted

hello, i am creating a mod with a mob,

I want the mob does not floats if he is on the water.

 

i thought lets look in the EntityLiving class

i found this part of code

 

        boolean flag1 = this.isInWater();

        boolean flag = this.handleLavaMovement();

 

        if (flag1 || flag)

        {

            this.isJumping = this.rand.nextFloat() < 0.8F;

        }

 

i tried to use this for my code:

 

protected void updateEntityActionState()

    {

        boolean flag1 = this.isInWater();

        boolean flag = this.handleLavaMovement();

 

        if (flag1 || flag)

        {

            this.isJumping = false;

        }

    }

 

but it doesnt work, does anyone know how to do this??

thanks for reading

Posted

This boolean is called when the mob jumps then it sets the yAxis motion, so when your mob is in water it jumps then you set isJumping to false, saying that your mob never jumps so it doesn't float. set it like vanilla does not to false.

Posted

hmm...

ok, i tried this:

   

    protected void updateEntityActionState()

    {

    if(this.isInWater() && this.isJumping)

    {

    this.isJumping = false;

    }

    }

 

so when is it in the water and when it is jumping, set jumping to false

but it doenst work ):

Posted

whatever people i fixed it :)

 

public boolean isInWater()

    {

        return this.worldObj.handleMaterialAcceleration(this.boundingBox.expand(0.0D, -0.6D, 0.0D), Material.water, this);

    }

 

ive found this in EntitySquid

and changed it to

 

public boolean isInWater()

    {

        return this.worldObj.handleMaterialAcceleration(this.boundingBox.expand(0.0D, -0.6D, 0.0D), Material.water, this) && (this.isJumping = false);

    }

 

it works perfectly, thanks for help

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.