Slightly improved flight pathing downwards.

This commit is contained in:
luisc committed 2022-02-22 01:52:47 -06:00
1 parent c2a669fbeb
commit 450e065e27
2 files changed
+28 -27

No files matched your search

@@ -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;
}
}