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;
|
2021-12-01 15:31:05 -06:00
|
|
|
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]
|
|
|
|
|
|
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_);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-01 15:31:05 -06:00
|
|
|
public void onLivingUpdate()
|
|
|
|
|
{
|
|
|
|
|
if(!canFly()){
|
|
|
|
|
super.onLivingUpdate();
|
|
|
|
|
return;
|
2021-07-10 00:48:03 -04:00
|
|
|
}
|
|
|
|
|
|
2021-12-01 15:31:05 -06:00
|
|
|
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;
|
|
|
|
|
}
|
2021-07-10 00:48:03 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-01 15:31:05 -06:00
|
|
|
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;
|
2021-07-10 00:48:03 -04:00
|
|
|
}
|
|
|
|
|
|
2021-12-01 15:31:05 -06:00
|
|
|
super.onLivingUpdate();
|
2021-07-10 00:48:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isOnLadder(){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2021-06-13 16:22:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|