From 3cfa2d9ee7e9567503228e7e8f7a1384e7a9a43c Mon Sep 17 00:00:00 2001 From: InviseDivine Date: Sun, 29 Mar 2026 16:53:46 +0200 Subject: [PATCH] FIX IT AHTUNG AHTUNG ALL DOESNT WORK FIX IT FIX IT FIX IT FIX IT BIG WARNING BIG WARNING --- src/client/gui/Gui.cpp | 1 - src/network/ServerSideNetworkHandler.cpp | 41 ++++++++++++++---------- src/server/ServerPlayer.cpp | 1 - src/world/entity/Entity.h | 2 +- src/world/entity/Mob.cpp | 1 - 5 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/client/gui/Gui.cpp b/src/client/gui/Gui.cpp index ccc9c26..7685813 100755 --- a/src/client/gui/Gui.cpp +++ b/src/client/gui/Gui.cpp @@ -730,7 +730,6 @@ void Gui::renderDebugInfo() { // Position float px = p->x, py = p->y - p->heightOffset, pz = p->z; - posTranslator.to(px, py, pz); int bx = (int)floorf(px), by = (int)floorf(py), bz = (int)floorf(pz); int cx = bx >> 4, cz = bz >> 4; diff --git a/src/network/ServerSideNetworkHandler.cpp b/src/network/ServerSideNetworkHandler.cpp index 1981b87..40ac4a1 100755 --- a/src/network/ServerSideNetworkHandler.cpp +++ b/src/network/ServerSideNetworkHandler.cpp @@ -406,38 +406,45 @@ void ServerSideNetworkHandler::onReady_RequestedChunks(const RakNet::RakNetGUID& void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, MovePlayerPacket* packet) { if (!level) return; - + //LOGI("MovePlayerPacket\n"); - if (Entity* entity = level->getEntity(packet->entityId)) - { + if (Entity* entity = level->getEntity(packet->entityId)) { ServerPlayer* player = (ServerPlayer*) getPlayer(source); float vectorDist = sqrt( (packet->x - entity->x) * (packet->x - entity->x) + (packet->z - entity->z) * (packet->z - entity->z)); float speed = vectorDist / (minecraft->getTicks() - player->getLastMoveTicks()); - - player->xRot = player->xRotO = packet->xRot; - player->yRot = player->yRotO = packet->yRot; - // packet->y += 1.62f; - - // if (speed < 2.5f) { - LOGI("Packets: %f, %f, %f \n", packet->x, packet->y, packet->z); + if (speed < 1.f) { + LOGI("Packet: %f, %f, %f \n", packet->x, packet->y, packet->z); LOGI("Entity before: %f, %f, %f \n", entity->x, entity->y, entity->z); LOGI("OnGround: %d \n", entity->onGround); - //player->xd = player->yd = player->zd = 0; - player->setxxa(packet->x); - player->setYya(packet->z); - // player->move(packet->x - entity->x, packet->y - entity->y, packet->z - entity->z); + // @note: packet->y contains y with subtracted entity->heightOffset + float ya = packet->y - entity->y - entity->heightOffset; + + LOGI("y: %f \n", ya); + + float yaOrg = ya; + + // @BIGWARNING @fixme: blocks around work as shit + std::vector& aABBs = level->getCubes(entity, entity->bb.expand(0, ya, 0)); - // player->travel(packet->x - entity->x, packet->z - entity->z); - // entity->lerpTo(packet->x, packet->y, packet->z, packet->yRot, packet->xRot, 3); + for (unsigned int i = 0; i < aABBs.size(); i++) + ya = aABBs[i].clipYCollide(entity->bb, ya); + + bool og = yaOrg != ya && yaOrg < 0; + + entity->onGround = og; + entity->checkFallDamage(ya, og); + entity->xd = entity->yd = entity->zd = 0; + entity->lerpTo(packet->x, packet->y, packet->z, packet->yRot, packet->xRot, 3); + LOGI("Entity after: %f, %f, %f \n", entity->x, entity->y, entity->z); // broadcast this packet to other clients redistributePacket(packet, source); - // } else { + } // else { //MovePlayerPacket refuse(player->entityId, player->x, player->y, player->z, player->xRot, player->yRot); //raknetInstance->send(refuse); // } diff --git a/src/server/ServerPlayer.cpp b/src/server/ServerPlayer.cpp index 085fa8b..9f4f1dc 100755 --- a/src/server/ServerPlayer.cpp +++ b/src/server/ServerPlayer.cpp @@ -49,7 +49,6 @@ void ServerPlayer::stopSleepInBed(bool forcefulWakeUp, bool updateLevelList, boo void ServerPlayer::aiStep() { updateAttackAnim(); super::aiStep(); - Mob::aiStep(); } void ServerPlayer::tick() { diff --git a/src/world/entity/Entity.h b/src/world/entity/Entity.h index 23c229f..b865902 100755 --- a/src/world/entity/Entity.h +++ b/src/world/entity/Entity.h @@ -129,6 +129,7 @@ public: virtual bool isHangingEntity(); virtual int getAuxData(); + virtual void checkFallDamage(float ya, bool onGround); protected: virtual void setRot(float yRot, float xRot); @@ -137,7 +138,6 @@ protected: virtual void resetPos(bool clearMore); virtual void outOfWorld(); - virtual void checkFallDamage(float ya, bool onGround); virtual void causeFallDamage(float fallDamage2); virtual void markHurt(); diff --git a/src/world/entity/Mob.cpp b/src/world/entity/Mob.cpp index aed03dd..614ccdd 100755 --- a/src/world/entity/Mob.cpp +++ b/src/world/entity/Mob.cpp @@ -728,7 +728,6 @@ bool Mob::isWaterMob() void Mob::aiStep() { - printf("%f %f \n", xxa, yya); //@todo? 30 lines of code here in java version TIMER_PUSH("ai"); if (isImmobile()) {