This commit is contained in:
2026-09-21 00:37:41 +01:00
parent 30d04c6c71
commit b952c1542b
6 changed files with 38 additions and 4 deletions
@@ -11,7 +11,7 @@ public class FlyCommand extends Command {
public FlyCommand(String name) { public FlyCommand(String name) {
super(name); super(name);
this.description = "Toggles the server-side flight check exemption for yourself"; this.description = "Toggles server-side flight for yourself";
this.usageMessage = "/fly"; this.usageMessage = "/fly";
} }
@@ -31,10 +31,10 @@ public class FlyCommand extends Command {
player.flightAllowed = !player.flightAllowed; player.flightAllowed = !player.flightAllowed;
if (player.flightAllowed) { if (player.flightAllowed) {
sender.sendMessage(ChatColor.GREEN + "Flight check exemption enabled."); sender.sendMessage(ChatColor.GREEN + "Flight enabled.");
sender.sendMessage(ChatColor.YELLOW + "A compatible client-side flight mod is required to fly."); sender.sendMessage(ChatColor.YELLOW + "Look up to rise, look down or sneak to descend.");
} else { } else {
sender.sendMessage(ChatColor.YELLOW + "Flight check exemption disabled."); sender.sendMessage(ChatColor.YELLOW + "Flight disabled.");
} }
return true; return true;
@@ -187,6 +187,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
return; return;
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
boolean serverFlight = this.applyServerFlight(packet10flying);
this.i = true; this.i = true;
double d0; double d0;
@@ -441,8 +442,41 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
this.player.onGround = packet10flying.g; this.player.onGround = packet10flying.g;
this.minecraftServer.serverConfigurationManager.d(this.player); this.minecraftServer.serverConfigurationManager.d(this.player);
this.player.b(this.player.locY - d0, packet10flying.g); this.player.b(this.player.locY - d0, packet10flying.g);
// A Beta client has no flight-ability packet. Keep its local position in
// sync with the server-controlled vertical movement while flying.
if (serverFlight) {
this.player.fallDistance = 0.0F;
this.sendPacket(new Packet13PlayerLookMove(this.player.locX, this.player.locY + 1.6200000047683716D, this.player.locY, this.player.locZ, this.player.yaw, this.player.pitch, false));
} }
} }
}
/**
* Converts a normal Beta movement packet into server-side flight movement.
* Looking up rises, looking down descends, and sneaking always descends.
* The client still supplies horizontal movement, so its normal movement keys
* continue to work without a modified client.
*/
private boolean applyServerFlight(Packet10Flying packet10flying) {
if (!this.player.flightAllowed || !packet10flying.h || this.player.vehicle != null || this.player.isSleeping()) {
return false;
}
double verticalSpeed = 0.0D;
if (this.player.isSneaking() || packet10flying.pitch > 25.0F) {
verticalSpeed = -0.32D;
} else if (packet10flying.pitch < -25.0F) {
verticalSpeed = 0.32D;
}
packet10flying.y = this.player.locY + verticalSpeed;
packet10flying.stance = packet10flying.y + 1.6200000047683716D;
packet10flying.g = false;
this.player.motY = 0.0D;
this.player.fallDistance = 0.0F;
return true;
}
public void a(double d0, double d1, double d2, float f, float f1) { public void a(double d0, double d1, double d2, float f, float f1) {
// CraftBukkit start - Delegate to teleport(Location) // CraftBukkit start - Delegate to teleport(Location)
Binary file not shown.
Binary file not shown.