mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 13:07:29 +00:00
EntityNPCFlying:
-Fixed fly height limit
This commit is contained in:
1 parent
51b412a0bf
commit
69afa29e9c
1 file changed
+14
-2
@@ -1,6 +1,7 @@
|
||||
package noppes.npcs.entity;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class EntityNPCFlying extends EntityNPCInterface {
|
||||
@@ -40,8 +41,19 @@ public abstract class EntityNPCFlying extends EntityNPCInterface {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean aboveLimit = false;
|
||||
double heightOffGround = this.posY - this.worldObj.getTopSolidOrLiquidBlock((int) this.posX, (int) this.posZ);
|
||||
if (heightOffGround > this.ai.flyHeightLimit && this.ai.hasFlyLimit || (heightOffGround < Math.ceil(this.height) && this.motionY == 0)) {
|
||||
if (heightOffGround < 0) {
|
||||
Vec3 pos = Vec3.createVectorHelper(this.posX,this.posY,this.posZ);
|
||||
Vec3 posLimit = Vec3.createVectorHelper(this.posX,this.posY - this.ai.flyHeightLimit,this.posZ);
|
||||
MovingObjectPosition mob = this.worldObj.rayTraceBlocks(pos,posLimit,true);
|
||||
if (mob == null || mob.typeOfHit == MovingObjectPosition.MovingObjectType.MISS) {
|
||||
aboveLimit = true;
|
||||
}
|
||||
} else if (heightOffGround > this.ai.flyHeightLimit) {
|
||||
aboveLimit = true;
|
||||
}
|
||||
if (aboveLimit && this.ai.hasFlyLimit || (heightOffGround < Math.ceil(this.height) && this.motionY == 0)) {
|
||||
this.flyLimitAllow = false;
|
||||
if (!this.getNavigator().noPath() && this.motionY > 0) {
|
||||
this.motionY = 0;
|
||||
|
||||
Reference in new issue
Block a user