Files
CustomNPC-Plus/src/main/java/noppes/npcs/entity/EntityNPCFlying.java
T

65 lines
1.7 KiB
Java
Raw Normal View History

2021-06-13 16:22:06 -04:00
package noppes.npcs.entity;
import net.minecraft.init.Blocks;
2021-06-13 16:22:06 -04:00
import net.minecraft.world.World;
public abstract class EntityNPCFlying extends EntityNPCInterface {
public EntityNPCFlying(World world) {
super(world);
}
@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_)
{
2022-02-22 01:52:47 -06:00
if(!this.canFly() || this.hurtTime != 0) {
super.moveEntityWithHeading(p_70612_1_, p_70612_2_);
return;
}
double heightOffGround = 0;
if(this.ai.hasFlyLimit) {
2022-02-22 01:52:47 -06:00
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;
}
}
}
2022-05-15 01:21:06 -05:00
if (heightOffGround > this.ai.flyHeightLimit && this.ai.hasFlyLimit) {
2022-02-22 01:52:47 -06:00
super.moveEntityWithHeading(p_70612_1_,p_70612_2_);
return;
2022-02-22 01:52:47 -06:00
}
double d3 = this.motionY;
super.moveEntityWithHeading(p_70612_1_, p_70612_2_);
this.motionY = d3;
if(this.getNavigator().noPath())
this.motionY = 0.0D;
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
}