From a0b5533d037547007ef08fb788bd5b297a8b0734 Mon Sep 17 00:00:00 2001 From: Lord_Cambion Date: Fri, 4 Dec 2026 18:16:51 +0100 Subject: [PATCH] Fix: Boat physic while not riding it on air --- Minecraft.World/Boat.cpp | 56 +++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/Minecraft.World/Boat.cpp b/Minecraft.World/Boat.cpp index 337aafd7..e6b61203 100644 --- a/Minecraft.World/Boat.cpp +++ b/Minecraft.World/Boat.cpp @@ -441,7 +441,6 @@ void Boat::tick() shared_ptr driver = rider.lock(); shared_ptr player = driver != nullptr ? dynamic_pointer_cast(driver) : nullptr; - bool steer = (player != nullptr) ? isLocallyDriven() : !level->isClientSide; if (player != nullptr) { @@ -455,7 +454,7 @@ void Boat::tick() inputLeft = inputRight = inputUp = inputDown = false; } - if (lSteps > 0 && !steer) + if (lSteps > 0 && !isLocallyDriven()) { double xt = x + (lx - x) / lSteps; double yt = y + (ly - y) / lSteps; @@ -468,25 +467,13 @@ void Boat::tick() setRot(yRot, xRot); } - if (steer) - { - if (player == nullptr && !level->isClientSide) setPaddleState(false, false); + if (!level->isClientSide && player == nullptr) + setPaddleState(false, false); - floatBoat(); + floatBoat(); + if (level->isClientSide) controlBoat(); - move(xd, yd, zd); - } - else - { - xd = 0.0; - yd = 0.0; - zd = 0.0; - - if (player != nullptr && !level->isClientSide) - { - setPaddleState(inputRight || inputUp, inputLeft || inputUp); - } - } + move(xd, yd, zd); const float paddleStroke = PI / 8.0f; const float paddleSplash = PI / 4.0f; @@ -495,18 +482,24 @@ void Boat::tick() { if (getPaddleState(side)) { - if (!level->isClientSide && fmod(paddlePositions[side], paddleCycle) <= paddleSplash && fmod(paddlePositions[side] + paddleStroke, paddleCycle) >= paddleSplash) + if (!level->isClientSide && + fmod(paddlePositions[side], paddleCycle) <= paddleSplash && + fmod(paddlePositions[side] + paddleStroke, paddleCycle) >= paddleSplash) { int sound = -1; - if (status == ON_LAND) sound = eSoundType_ENTITY_BOAT_PADDLE_LAND; - else if (status != IN_AIR) sound = eSoundType_ENTITY_BOAT_PADDLE_WATER; + + if (status == ON_LAND) + sound = eSoundType_ENTITY_BOAT_PADDLE_LAND; + else if (status != IN_AIR) + sound = eSoundType_ENTITY_BOAT_PADDLE_WATER; + if (sound >= 0) { double viewX = -Mth::sin(yRot * PI / 180); double viewZ = Mth::cos(yRot * PI / 180); double xOffset = side == 1 ? -viewZ : viewZ; double zOffset = side == 1 ? viewX : -viewX; - level->playSound(x + xOffset, y, z + zOffset, sound, 1.0f, 0.8f + 0.4f * random->nextFloat()); + level->playSound(x + xOffset,y,z + zOffset,sound,1.0f,0.8f + 0.4f * random->nextFloat()); } } paddlePositions[side] += paddleStroke; @@ -526,22 +519,27 @@ void Boat::tick() for (int j = 0; j < 2; j++) { int yy = Mth::floor(bb->y0) + j; - if (level->getTile(xx, yy, zz) == Tile::waterlily_Id) level->destroyTile(xx, yy, zz, true); + if (level->getTile(xx, yy, zz) == Tile::waterlily_Id) + level->destroyTile(xx, yy, zz, true); } } } + vector> *entities = level->getEntities(shared_from_this(), bb->grow(0.2f, -0.01f, 0.2f)); - vector > *entities = level->getEntities(shared_from_this(), bb->grow(0.2f, -0.01f, 0.2f)); if (entities != nullptr && !entities->empty()) { bool canMount = !level->isClientSide && player == nullptr; + for (auto &e : *entities) { - if (e == nullptr || hasRider(e) || e->riding.get() == this) continue; - if (!e->isPushable()) continue; + if (e == nullptr || hasRider(e) || e->riding.get() == this) + continue; - if (canMount && getPassengerCount() < 2 && e->riding == nullptr && e->bbWidth < bbWidth && e->instanceof(eTYPE_LIVINGENTITY) - && !e->instanceof(eTYPE_WATERANIMAL) && !e->instanceof(eTYPE_PLAYER)) + if (!e->isPushable()) + continue; + + if (canMount && getPassengerCount() < 2 && e->riding == nullptr && + e->bbWidth < bbWidth && e->instanceof(eTYPE_LIVINGENTITY) && !e->instanceof(eTYPE_WATERANIMAL) && !e->instanceof(eTYPE_PLAYER)) { e->ride(shared_from_this()); }