diff --git a/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java b/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java index b754b2514..f47667a08 100644 --- a/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java +++ b/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java @@ -52,13 +52,13 @@ public class FlyingMoveHelper extends EntityMoveHelper{ this.entity.motionZ += (d2 / d5 * speed - this.entity.motionZ) * speed; if (heightOffGround < this.entity.ai.flyHeightLimit || !this.entity.ai.hasFlyLimit) { - this.entity.motionY = ((d1 / d5) * speed); - if(this.entity.motionY < 0 && this.entity.motionY > -6 * this.entity.ai.getWalkingSpeed()/5.0D) - this.entity.motionY *= 5; + this.entity.motionY += (d1 / d5 * speed - this.entity.motionY) * speed; } + + this.entity.velocityChanged = true; } - this.entity.rotationYaw = this.limitAngle(this.entity.rotationYaw,(float) ((Math.atan2(-d0, -d2) + Math.PI) * -(180F / Math.PI)),30.0F); + this.entity.rotationYaw = this.limitAngle(this.entity.rotationYaw,(float) ((Math.atan2(-d0, -d2) + Math.PI) * -(180F / Math.PI)),18.0F); } } diff --git a/src/main/java/noppes/npcs/entity/EntityNPCFlying.java b/src/main/java/noppes/npcs/entity/EntityNPCFlying.java index d8dd7e23f..79322b806 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCFlying.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCFlying.java @@ -3,9 +3,12 @@ package noppes.npcs.entity; import net.minecraft.entity.Entity; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAISwimming; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.util.MathHelper; import net.minecraft.world.World; +import noppes.npcs.constants.EnumRoleType; +import noppes.npcs.roles.RoleCompanion; public abstract class EntityNPCFlying extends EntityNPCInterface { @@ -30,17 +33,21 @@ public abstract class EntityNPCFlying extends EntityNPCInterface { super.updateFallState(p_180433_1_, p_180433_3_); } - public void onLivingUpdate() + @Override + public boolean isOnLadder(){ + return false; + } + + public void moveEntityWithHeading(float p_70612_1_, float p_70612_2_) { - super.onLivingUpdate(); - if(!canFly()){ + if(!this.canFly() || this.hurtTime != 0) { + super.moveEntityWithHeading(p_70612_1_, p_70612_2_); return; } - int blockY = (int) this.posY; double heightOffGround = 0; if(this.ai.hasFlyLimit) { - for (blockY = (int) this.posY; blockY > 0; blockY--) { + for (int blockY = (int) this.posY; blockY > 0; blockY--) { heightOffGround = this.posY - blockY; if (this.worldObj.getBlock((int) this.posX, blockY, (int) this.posZ) != Blocks.air || heightOffGround > this.ai.flyHeightLimit){ break; @@ -48,24 +55,18 @@ public abstract class EntityNPCFlying extends EntityNPCInterface { } } - if (!this.onGround && !this.velocityChanged && this.motionY < 0 && this.hurtTime == 0) - { - if(heightOffGround >= this.ai.flyHeightLimit && this.ai.hasFlyLimit){ - this.motionY *= 0.8D; - this.velocityChanged = true; - } else { - this.motionY *= this.ai.flyGravity; - this.velocityChanged = true; - } + if(this.getNavigator().noPath()) + this.motionY = 0.0D; + + if(heightOffGround < this.ai.flyHeightLimit || !this.ai.hasFlyLimit) { + double d3 = this.motionY; + super.moveEntityWithHeading(p_70612_1_, p_70612_2_); + this.motionY = d3; + + this.fallDistance = 0.0F; + this.velocityChanged = true; + } else { + super.moveEntityWithHeading(p_70612_1_,p_70612_2_); } } - - @Override - public boolean isOnLadder(){ - return false; - } - - - - }