Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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

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.

  • Author

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 ):

  • Author

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.