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

99 lines
2.5 KiB
Java
Raw Normal View History

2021-06-13 16:22:06 -04:00
package noppes.npcs.entity;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
2021-06-13 16:22:06 -04:00
import net.minecraft.init.Blocks;
import net.minecraft.util.MathHelper;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider;
public abstract class EntityNPCFlying extends EntityNPCInterface {
public EntityNPCFlying(World world) {
super(world);
}
// FLY CHANGE [WIP]
@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_);
}
public void onLivingUpdate()
{
if(!canFly()){
super.onLivingUpdate();
return;
}
this.motionY *= 0.6000000238418579D;
double d1;
double d3;
double d5;
if (!this.worldObj.isRemote && this.getAttackTarget() != null)
{
Entity entity = this.getAttackTarget();
if (entity != null)
{
if (this.posY < entity.posY)
{
if (this.motionY < 0.0D)
{
this.motionY = 0.0D;
}
this.motionY += (0.5D - this.motionY) * 0.6000000238418579D;
}
double d0 = entity.posX - this.posX;
d1 = entity.posZ - this.posZ;
d3 = d0 * d0 + d1 * d1;
if (d3 > 9.0D)
{
d5 = (double)MathHelper.sqrt_double(d3);
this.motionX += (d0 / d5 * 0.5D - this.motionX) * 0.6000000238418579D;
this.motionZ += (d1 / d5 * 0.5D - this.motionZ) * 0.6000000238418579D;
this.motionX *= this.ai.getWalkingSpeed()/10.0D;
this.motionZ *= this.ai.getWalkingSpeed()/10.0D;
}
}
}
if (this.motionX * this.motionX + this.motionZ * this.motionZ > 0.05000000074505806D)
{
this.rotationYaw = (float)Math.atan2(this.motionZ, this.motionX) * (180F / (float)Math.PI) - 90.0F;
}
super.onLivingUpdate();
}
@Override
public boolean isOnLadder(){
return false;
}
2021-06-13 16:22:06 -04:00
}