From eed770b121aa4ce38f002db042d0137c24c6d344 Mon Sep 17 00:00:00 2001 From: ModMaker101 <119018978+ModMaker101@users.noreply.github.com> Date: Thu, 5 Mar 2026 17:07:47 -0500 Subject: [PATCH] Fixed boats falling and a TP glitch #266 (#615) --- Minecraft.World/Boat.cpp | 17 ++++---- Minecraft.World/LivingEntity.cpp | 68 +++++++++++++++++--------------- 2 files changed, 44 insertions(+), 41 deletions(-) diff --git a/Minecraft.World/Boat.cpp b/Minecraft.World/Boat.cpp index e39bd7f3..1811c209 100644 --- a/Minecraft.World/Boat.cpp +++ b/Minecraft.World/Boat.cpp @@ -87,7 +87,7 @@ Boat::Boat(Level *level, double x, double y, double z) : Entity( level ) double Boat::getRideHeight() { - return bbHeight * 0.0f - 0.3f; + return heightOffset; } bool Boat::hurt(DamageSource *source, float hurtDamage) @@ -283,11 +283,11 @@ void Boat::tick() // 4J Stu - Fix for #9579 - GAMEPLAY: Boats with a player in them slowly sink under the water over time, and with no player in them they float into the sky. // Just make the boats bob up and down rather than any other client-side movement when not receiving packets from server - if (waterPercentage < 1) - { - double bob = waterPercentage * 2 - 1; - yd += 0.04f * bob; - } + if (waterPercentage > 0) + { + double bob = waterPercentage * 2 - 1; + yd += 0.04f * bob; + } else { if (yd < 0) yd /= 2; @@ -307,15 +307,14 @@ void Boat::tick() return; } - if (waterPercentage < 1) + if (waterPercentage > 0) { double bob = waterPercentage * 2 - 1; yd += 0.04f * bob; } else { - if (yd < 0) yd /= 2; - yd += 0.007f; + yd = 0; } diff --git a/Minecraft.World/LivingEntity.cpp b/Minecraft.World/LivingEntity.cpp index ef5658c3..ce702676 100644 --- a/Minecraft.World/LivingEntity.cpp +++ b/Minecraft.World/LivingEntity.cpp @@ -1305,42 +1305,46 @@ void LivingEntity::teleportTo(double x, double y, double z) void LivingEntity::findStandUpPosition(shared_ptr vehicle) { - AABB *boundingBox; - double fallbackX = vehicle->x; - double fallbackY = vehicle->bb->y0 + vehicle->bbHeight; - double fallbackZ = vehicle->z; + const double vehicleX = vehicle->x; + const double vehicleY = vehicle->bb->y0 + vehicle->bbHeight; + const double vehicleZ = vehicle->z; + double fallbackX = vehicleX; + double fallbackY = vehicleY; + double fallbackZ = vehicleZ; + const double searchY = vehicleY; - for (double xDiff = -1.5; xDiff < 2; xDiff += 1.5) - { - for (double zDiff = -1.5; zDiff < 2; zDiff += 1.5) - { - if (xDiff == 0 && zDiff == 0) - { - continue; - } + for (double xDiff = -1.5; xDiff < 2; xDiff += 1.5) + { + for (double zDiff = -1.5; zDiff < 2; zDiff += 1.5) + { + if (xDiff == 0 && zDiff == 0) + { + continue; + } - int xToInt = (int) (x + xDiff); - int zToInt = (int) (z + zDiff); - boundingBox = bb->cloneMove(xDiff, 1, zDiff); + const int xToInt = static_cast(vehicleX + xDiff); + const int zToInt = static_cast(vehicleZ + zDiff); + AABB *boundingBox = bb->cloneMove(vehicleX + xDiff - x, searchY + 1 - y, vehicleZ + zDiff - z); - if (level->getTileCubes(boundingBox, true)->empty()) - { - if (level->isTopSolidBlocking(xToInt, (int) y, zToInt)) - { - teleportTo(x + xDiff, y + 1, z + zDiff); - return; - } - else if (level->isTopSolidBlocking(xToInt, (int) y - 1, zToInt) || level->getMaterial(xToInt, (int) y - 1, zToInt) == Material::water) - { - fallbackX = x + xDiff; - fallbackY = y + 1; - fallbackZ = z + zDiff; - } - } - } - } + if (level->getTileCubes(boundingBox, true)->empty()) + { + if (level->isTopSolidBlocking(xToInt, static_cast(searchY), zToInt)) + { + teleportTo(vehicleX + xDiff, searchY + 1, vehicleZ + zDiff); + return; + } + if (level->isTopSolidBlocking(xToInt, static_cast(searchY) - 1, zToInt) || + level->getMaterial(xToInt, static_cast(searchY) - 1, zToInt) == Material::water) + { + fallbackX = vehicleX + xDiff; + fallbackY = searchY + 1; + fallbackZ = vehicleZ + zDiff; + } + } + } + } - teleportTo(fallbackX, fallbackY, fallbackZ); + teleportTo(fallbackX, fallbackY, fallbackZ); } bool LivingEntity::shouldShowName()