Stop the mount reset clearing a flying npc's flying flag every tick

This commit is contained in:
KAMKEEL committed 2026-10-01 03:03:19 -04:00
1 parent 9a7758a27b
commit 5712541cae
1 file changed
+21 -5
@@ -26,7 +26,7 @@ public final class NPCMountUtil {
public static boolean handleMountedMovement(EntityNPCInterface npc, MountState state, float strafe, float forward) {
if (npc.advanced.role != EnumRoleType.Mount || !(npc.roleInterface instanceof RoleMount)) {
resetMountedFlightState(npc, state);
resetWithoutRider(npc, state);
return false;
}
if (npc.riddenByEntity != null && !(npc.riddenByEntity instanceof EntityPlayer)) {
@@ -34,7 +34,7 @@ public final class NPCMountUtil {
return false;
}
if (!(npc.riddenByEntity instanceof EntityPlayer)) {
resetMountedFlightState(npc, state);
resetWithoutRider(npc, state);
return false;
}
@@ -233,14 +233,15 @@ public final class NPCMountUtil {
}
public static void applyUnriddenFlightDescent(EntityNPCInterface npc, MountState state, RoleMount mount) {
// A flying npc's own movement sets its flying flag.
if (npc.canFly()) {
return;
}
if (mount == null || !mount.isFlyingMountEnabled()) {
npc.setNpcFlyingState(false);
npc.setNpcJumpingState(false);
return;
}
if (npc.canFly()) {
return;
}
if (npc.onGround) {
npc.motionY = 0.0D;
npc.setNpcFlyingState(false);
@@ -314,6 +315,21 @@ public final class NPCMountUtil {
return state.flightMode;
}
/**
* Reset for an npc with no player on it. A flying npc sets its flying flag right after this,
* so clearing it here would flip it every tick and resend the npc's data every tick.
*/
private static void resetWithoutRider(EntityNPCInterface npc, MountState state) {
if (!npc.canFly()) {
resetMountedFlightState(npc, state);
return;
}
state.flightMode = false;
state.jumpPressed = false;
state.flightToggleTimer = 0;
npc.setNpcJumpingState(false);
}
public static void resetMountedFlightState(EntityNPCInterface npc, MountState state) {
state.flightMode = false;
state.jumpPressed = false;