mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +00:00
Add command to disable Gravity (#1955)
Allow disabling gravity (flying) for servers that allow this. /move gravity: show gravity handling status /move gravity on: enable gravity handling (falling) /move gravity off: disable gravity handling (flying) Co-authored-by: ORelio <ORelio@users.noreply.github.com>
This commit is contained in:
parent
288994aeec
commit
8795aab810
6 changed files with 33 additions and 14 deletions
|
|
@ -21,21 +21,24 @@ namespace MinecraftClient.Mapping
|
|||
/// <returns>Updated location after applying gravity</returns>
|
||||
public static Location HandleGravity(World world, Location location, ref double motionY)
|
||||
{
|
||||
Location onFoots = new Location(location.X, Math.Floor(location.Y), location.Z);
|
||||
Location belowFoots = Move(location, Direction.Down);
|
||||
if (location.Y > Math.Truncate(location.Y) + 0.0001)
|
||||
if (Settings.GravityEnabled)
|
||||
{
|
||||
belowFoots = location;
|
||||
belowFoots.Y = Math.Truncate(location.Y);
|
||||
Location onFoots = new Location(location.X, Math.Floor(location.Y), location.Z);
|
||||
Location belowFoots = Move(location, Direction.Down);
|
||||
if (location.Y > Math.Truncate(location.Y) + 0.0001)
|
||||
{
|
||||
belowFoots = location;
|
||||
belowFoots.Y = Math.Truncate(location.Y);
|
||||
}
|
||||
if (!IsOnGround(world, location) && !IsSwimming(world, location))
|
||||
{
|
||||
while (!IsOnGround(world, belowFoots) && belowFoots.Y >= 1)
|
||||
belowFoots = Move(belowFoots, Direction.Down);
|
||||
location = Move2Steps(location, belowFoots, ref motionY, true).Dequeue();
|
||||
}
|
||||
else if (!(world.GetBlock(onFoots).Type.IsSolid()))
|
||||
location = Move2Steps(location, onFoots, ref motionY, true).Dequeue();
|
||||
}
|
||||
if (!IsOnGround(world, location) && !IsSwimming(world, location))
|
||||
{
|
||||
while (!IsOnGround(world, belowFoots) && belowFoots.Y >= 1)
|
||||
belowFoots = Move(belowFoots, Direction.Down);
|
||||
location = Move2Steps(location, belowFoots, ref motionY, true).Dequeue();
|
||||
}
|
||||
else if (!(world.GetBlock(onFoots).Type.IsSolid()))
|
||||
location = Move2Steps(location, onFoots, ref motionY, true).Dequeue();
|
||||
return location;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue