2021-06-13 16:22:06 -04:00
|
|
|
package noppes.npcs.entity;
|
|
|
|
|
|
2022-01-13 05:28:20 -06:00
|
|
|
import net.minecraft.init.Blocks;
|
2021-06-13 16:22:06 -04:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
|
|
|
|
|
public abstract class EntityNPCFlying extends EntityNPCInterface {
|
|
|
|
|
|
2022-11-07 13:01:57 -06:00
|
|
|
public boolean flyLimitAllow = false;
|
|
|
|
|
|
2021-06-13 16:22:06 -04:00
|
|
|
public EntityNPCFlying(World world) {
|
|
|
|
|
super(world);
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-10 00:48:03 -04:00
|
|
|
@Override
|
|
|
|
|
public boolean canFly(){
|
|
|
|
|
return ai.movementType == 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void fall(float distance) {
|
|
|
|
|
if(!canFly())
|
|
|
|
|
super.fall(distance);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void updateFallState(double p_180433_1_, boolean p_180433_3_) {
|
|
|
|
|
if(!canFly())
|
|
|
|
|
super.updateFallState(p_180433_1_, p_180433_3_);
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-22 01:52:47 -06:00
|
|
|
@Override
|
|
|
|
|
public boolean isOnLadder(){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void moveEntityWithHeading(float p_70612_1_, float p_70612_2_)
|
2021-12-01 15:31:05 -06:00
|
|
|
{
|
2022-11-12 15:53:20 -06:00
|
|
|
if(!this.canFly() || this.hurtTime != 0 || !this.canBreathe()) {
|
2022-02-22 01:52:47 -06:00
|
|
|
super.moveEntityWithHeading(p_70612_1_, p_70612_2_);
|
2021-12-01 15:31:05 -06:00
|
|
|
return;
|
2021-07-10 00:48:03 -04:00
|
|
|
}
|
|
|
|
|
|
2022-11-04 23:56:09 -05:00
|
|
|
double heightOffGround = this.posY - this.worldObj.getTopSolidOrLiquidBlock((int) this.posX, (int) this.posZ);
|
2022-11-07 13:32:31 -06:00
|
|
|
if (heightOffGround > this.ai.flyHeightLimit && this.ai.hasFlyLimit || (heightOffGround < Math.ceil(this.height) && this.motionY == 0)) {
|
2022-11-07 13:01:57 -06:00
|
|
|
this.flyLimitAllow = false;
|
|
|
|
|
if (!this.getNavigator().noPath() && this.motionY > 0) {
|
|
|
|
|
this.motionY = 0;
|
|
|
|
|
} else {
|
|
|
|
|
super.moveEntityWithHeading(p_70612_1_, p_70612_2_);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-02-22 01:52:47 -06:00
|
|
|
}
|
2022-11-07 13:01:57 -06:00
|
|
|
this.flyLimitAllow = true;
|
2022-02-27 23:23:41 -06:00
|
|
|
|
|
|
|
|
double d3 = this.motionY;
|
|
|
|
|
super.moveEntityWithHeading(p_70612_1_, p_70612_2_);
|
|
|
|
|
this.motionY = d3;
|
|
|
|
|
|
2022-11-05 04:10:00 -05:00
|
|
|
if (this.getNavigator().noPath()) {
|
|
|
|
|
this.motionY = -Math.abs(this.ai.flyGravity);
|
|
|
|
|
}
|
2022-06-29 03:48:00 -05:00
|
|
|
|
|
|
|
|
this.velocityChanged = true;
|
2022-02-22 01:52:47 -06:00
|
|
|
}
|
2021-06-13 16:22:06 -04:00
|
|
|
}
|