mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-13 05:27:37 +00:00
Fixed odd NPC bobbing and NPCs with fly height limits not being able to path
This commit is contained in:
1 parent
267bc8b239
commit
a1eb8ff91b
2 files changed
+13
-14
No files matched your search
@@ -4,6 +4,7 @@ import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.EntityMoveHelper;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import noppes.npcs.entity.EntityNPCFlying;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class FlyingMoveHelper extends EntityMoveHelper{
|
||||
@@ -37,21 +38,11 @@ public class FlyingMoveHelper extends EntityMoveHelper{
|
||||
double d5 = MathHelper.sqrt_double(d4);
|
||||
speed = Math.min(d5/5.0D,speed);
|
||||
|
||||
double heightOffGround = 0;
|
||||
if(this.entity.ai.hasFlyLimit) {
|
||||
for (int blockY = (int) this.posY; blockY > 0; blockY--) {
|
||||
heightOffGround = this.posY - blockY;
|
||||
if (this.entity.worldObj.getBlock((int) this.posX, blockY, (int) this.posZ) != Blocks.air || heightOffGround > this.entity.ai.flyHeightLimit){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.entity.hurtTime == 0 && d4 > 0.5D) {
|
||||
this.entity.motionX += (speed * (d0 / d5) - this.entity.motionX) * speed;
|
||||
this.entity.motionZ += (speed * (d2 / d5) - this.entity.motionZ) * speed;
|
||||
|
||||
if (heightOffGround < this.entity.ai.flyHeightLimit || !this.entity.ai.hasFlyLimit) {
|
||||
if (((EntityNPCFlying)this.entity).flyLimitAllow || !this.entity.ai.hasFlyLimit) {
|
||||
this.entity.motionY = verticalSpeed * (d1 / d5);
|
||||
if (this.entity.motionY > 0) {
|
||||
this.entity.motionY += 0.1D;
|
||||
|
||||
@@ -5,6 +5,8 @@ import net.minecraft.world.World;
|
||||
|
||||
public abstract class EntityNPCFlying extends EntityNPCInterface {
|
||||
|
||||
public boolean flyLimitAllow = false;
|
||||
|
||||
public EntityNPCFlying(World world) {
|
||||
super(world);
|
||||
}
|
||||
@@ -39,10 +41,16 @@ public abstract class EntityNPCFlying extends EntityNPCInterface {
|
||||
}
|
||||
|
||||
double heightOffGround = this.posY - this.worldObj.getTopSolidOrLiquidBlock((int) this.posX, (int) this.posZ);
|
||||
if (heightOffGround > this.ai.flyHeightLimit && this.ai.hasFlyLimit || heightOffGround < this.height) {
|
||||
super.moveEntityWithHeading(p_70612_1_,p_70612_2_);
|
||||
return;
|
||||
if (heightOffGround > this.ai.flyHeightLimit && this.ai.hasFlyLimit || (heightOffGround < this.height && this.motionY == 0)) {
|
||||
this.flyLimitAllow = false;
|
||||
if (!this.getNavigator().noPath() && this.motionY > 0) {
|
||||
this.motionY = 0;
|
||||
} else {
|
||||
super.moveEntityWithHeading(p_70612_1_, p_70612_2_);
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.flyLimitAllow = true;
|
||||
|
||||
double d3 = this.motionY;
|
||||
super.moveEntityWithHeading(p_70612_1_, p_70612_2_);
|
||||
|
||||
Reference in new issue
Block a user