Posted March 13, 201411 yr 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
March 13, 201411 yr 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.
March 14, 201411 yr 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 ):
March 14, 201411 yr 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.