Cut wasted NPC tick work and stop the flying flag flipping every tick

This commit is contained in:
KAMKEEL committed 2026-10-01 02:58:31 -04:00
1 parent cf1e34b4a7
commit 9a7758a27b
3 files changed
+13 -5

No files matched your search

@@ -46,7 +46,7 @@ public abstract class EntityNPCFlying extends EntityNPCInterface {
return;
if (!this.canFly() || this.hurtTime != 0 || !this.canBreathe()) {
setNpcFlyingState(false);
super.moveEntityWithHeading(p_70612_1_, p_70612_2_);
moveWithoutMountHandling(p_70612_1_, p_70612_2_);
return;
}
@@ -70,7 +70,7 @@ public abstract class EntityNPCFlying extends EntityNPCInterface {
} else if (heightOffGround < Math.ceil(this.height) && this.motionY == 0) {
this.flyLimitAllow = false;
setNpcFlyingState(false);
super.moveEntityWithHeading(p_70612_1_, p_70612_2_);
moveWithoutMountHandling(p_70612_1_, p_70612_2_);
return;
}
this.flyLimitAllow = true;
@@ -81,7 +81,7 @@ public abstract class EntityNPCFlying extends EntityNPCInterface {
desiredMotionY = -Math.abs(this.ais.flyGravity);
}
this.motionY = desiredMotionY;
super.moveEntityWithHeading(p_70612_1_, p_70612_2_);
moveWithoutMountHandling(p_70612_1_, p_70612_2_);
this.motionY = desiredMotionY;
this.updateLimbSwing();
@@ -434,7 +434,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
if (this.ticksExisted % 20 == 0)
faction = getFaction();
if (!worldObj.isRemote) {
if (!isKilled() && this.ticksExisted % 20 == 0) {
if (this.ticksExisted % 20 == 0 && !isKilled()) {
if (this.getHealth() < this.getMaxHealth()) {
if (stats.healthRegen > 0 && !isAttacking())
heal(stats.healthRegen);
@@ -1423,7 +1423,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
}
public void onCollide() {
if (!isEntityAlive() || ticksExisted % 4 != 0)
if (ticksExisted % 4 != 0 || !isEntityAlive())
return;
AxisAlignedBB axisalignedbb = null;
@@ -2277,6 +2277,11 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
if (handleMountedMovement(strafe, forward)) {
return;
}
moveWithoutMountHandling(strafe, forward);
}
/** Normal movement, for callers that already ran the mount handling this tick. */
protected void moveWithoutMountHandling(float strafe, float forward) {
double d0 = this.posX;
double d1 = this.posY;
double d2 = this.posZ;
@@ -140,6 +140,9 @@ public class DataTimers implements ITimers {
}
public void update() {
// Runs every tick for every npc and player. Most have no timers, so skip the copy.
if (this.timers.isEmpty())
return;
Iterator<DataTimers.Timer> var1 = (new ArrayList<>(this.timers.values())).iterator();
while (var1.hasNext()) {