Set proper pose once flying finishes

This commit is contained in:
Moulberry 2021-09-14 17:50:19 +08:00
parent 1933914bbc
commit ee435f43f2
2 changed files with 14 additions and 11 deletions

View File

@ -1069,6 +1069,8 @@ public class Entity implements Viewable, Tickable, TagHandler, PermissionHandler
* @param pose the new entity pose
*/
public void setPose(@NotNull Pose pose) {
System.out.println("Set pose: " + pose);
this.entityMeta.setPose(pose);
}

View File

@ -1682,17 +1682,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
* @param flying should the player fly
*/
public void setFlying(boolean flying) {
if(this.flying != flying) {
Pose pose = getPose();
if(this.isSneaking() && pose == Pose.STANDING) {
setPose(Pose.SNEAKING);
} else if(pose == Pose.SNEAKING) {
setPose(Pose.STANDING);
}
}
this.flying = flying;
refreshFlying(flying);
refreshAbilities();
}
@ -1705,6 +1695,17 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
* @see #setFlying(boolean) instead
*/
public void refreshFlying(boolean flying) {
//When the player starts or stops flying, their pose needs to change
if(this.flying != flying) {
Pose pose = getPose();
if(this.isSneaking() && pose == Pose.STANDING) {
setPose(Pose.SNEAKING);
} else if(pose == Pose.SNEAKING) {
setPose(Pose.STANDING);
}
}
this.flying = flying;
}