mirror of
https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1.git
synced 2026-03-30 12:03:30 +00:00
Compare commits
2 Commits
470c28d83a
...
3cfa2d9ee7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3cfa2d9ee7 | ||
|
|
f016f00eab |
@@ -730,7 +730,6 @@ void Gui::renderDebugInfo() {
|
|||||||
|
|
||||||
// Position
|
// Position
|
||||||
float px = p->x, py = p->y - p->heightOffset, pz = p->z;
|
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 bx = (int)floorf(px), by = (int)floorf(py), bz = (int)floorf(pz);
|
||||||
int cx = bx >> 4, cz = bz >> 4;
|
int cx = bx >> 4, cz = bz >> 4;
|
||||||
|
|
||||||
|
|||||||
@@ -438,7 +438,7 @@ void LocalPlayer::tick() {
|
|||||||
{
|
{
|
||||||
if (std::abs(x - sentX) > .1f || std::abs(y - sentY) > .01f || std::abs(z - sentZ) > .1f || std::abs(sentRotX - xRot) > 1 || std::abs(sentRotY - yRot) > 1)
|
if (std::abs(x - sentX) > .1f || std::abs(y - sentY) > .01f || std::abs(z - sentZ) > .1f || std::abs(sentRotX - xRot) > 1 || std::abs(sentRotY - yRot) > 1)
|
||||||
{
|
{
|
||||||
MovePlayerPacket packet(entityId, x, y - heightOffset, z, xRot, yRot);
|
MovePlayerPacket packet(entityId, xxa, y - heightOffset, yya, xRot, yRot);
|
||||||
minecraft->raknetInstance->send(packet);
|
minecraft->raknetInstance->send(packet);
|
||||||
sentX = x;
|
sentX = x;
|
||||||
sentY = y;
|
sentY = y;
|
||||||
|
|||||||
@@ -406,36 +406,48 @@ void ServerSideNetworkHandler::onReady_RequestedChunks(const RakNet::RakNetGUID&
|
|||||||
void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, MovePlayerPacket* packet)
|
void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, MovePlayerPacket* packet)
|
||||||
{
|
{
|
||||||
if (!level) return;
|
if (!level) return;
|
||||||
|
|
||||||
//LOGI("MovePlayerPacket\n");
|
//LOGI("MovePlayerPacket\n");
|
||||||
if (Entity* entity = level->getEntity(packet->entityId))
|
if (Entity* entity = level->getEntity(packet->entityId)) {
|
||||||
{
|
|
||||||
ServerPlayer* player = (ServerPlayer*) getPlayer(source);
|
ServerPlayer* player = (ServerPlayer*) getPlayer(source);
|
||||||
|
|
||||||
float vectorDist = sqrt( (packet->x - entity->x) * (packet->x - entity->x) +
|
float vectorDist = sqrt( (packet->x - entity->x) * (packet->x - entity->x) +
|
||||||
(packet->z - entity->z) * (packet->z - entity->z));
|
(packet->z - entity->z) * (packet->z - entity->z));
|
||||||
float speed = vectorDist / (minecraft->getTicks() - player->getLastMoveTicks());
|
float speed = vectorDist / (minecraft->getTicks() - player->getLastMoveTicks());
|
||||||
|
|
||||||
player->xRot = packet->xRot;
|
|
||||||
player->yRot = packet->yRot;
|
|
||||||
|
|
||||||
packet->y += 1.62f;
|
if (speed < 1.f) {
|
||||||
|
LOGI("Packet: %f, %f, %f \n", packet->x, packet->y, packet->z);
|
||||||
if (speed < 2.5f) {
|
|
||||||
LOGI("Packet before: %f, %f, %f \n", packet->x, packet->y, packet->z);
|
|
||||||
LOGI("Entity before: %f, %f, %f \n", entity->x, entity->y, entity->z);
|
LOGI("Entity before: %f, %f, %f \n", entity->x, entity->y, entity->z);
|
||||||
LOGI("Delta: %f %f %f \n", packet->x - entity->x, packet->y - entity->y, packet->z - entity->z);
|
LOGI("OnGround: %d \n", entity->onGround);
|
||||||
player->xd = player->yd = player->zd = 0;
|
|
||||||
player->move(packet->x - entity->x, packet->y - entity->y, packet->z - entity->z);
|
// @note: packet->y contains y with subtracted entity->heightOffset
|
||||||
// player->travel(packet->x - entity->x, packet->z - entity->z);
|
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<AABB>& aABBs = level->getCubes(entity, entity->bb.expand(0, ya, 0));
|
||||||
|
|
||||||
|
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);
|
LOGI("Entity after: %f, %f, %f \n", entity->x, entity->y, entity->z);
|
||||||
// entity->lerpTo(packet->x, packet->y, packet->z, packet->yRot, packet->xRot, 3);
|
|
||||||
// broadcast this packet to other clients
|
// broadcast this packet to other clients
|
||||||
redistributePacket(packet, source);
|
redistributePacket(packet, source);
|
||||||
} else {
|
} // else {
|
||||||
MovePlayerPacket refuse(player->entityId, player->x, player->y, player->z, player->xRot, player->yRot);
|
//MovePlayerPacket refuse(player->entityId, player->x, player->y, player->z, player->xRot, player->yRot);
|
||||||
raknetInstance->send(refuse);
|
//raknetInstance->send(refuse);
|
||||||
}
|
// }
|
||||||
|
|
||||||
player->setLastMoveTicks(minecraft->getTicks());
|
player->setLastMoveTicks(minecraft->getTicks());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ public:
|
|||||||
virtual bool isHangingEntity();
|
virtual bool isHangingEntity();
|
||||||
|
|
||||||
virtual int getAuxData();
|
virtual int getAuxData();
|
||||||
|
virtual void checkFallDamage(float ya, bool onGround);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void setRot(float yRot, float xRot);
|
virtual void setRot(float yRot, float xRot);
|
||||||
@@ -137,7 +138,6 @@ protected:
|
|||||||
virtual void resetPos(bool clearMore);
|
virtual void resetPos(bool clearMore);
|
||||||
virtual void outOfWorld();
|
virtual void outOfWorld();
|
||||||
|
|
||||||
virtual void checkFallDamage(float ya, bool onGround);
|
|
||||||
virtual void causeFallDamage(float fallDamage2);
|
virtual void causeFallDamage(float fallDamage2);
|
||||||
virtual void markHurt();
|
virtual void markHurt();
|
||||||
|
|
||||||
|
|||||||
@@ -729,7 +729,6 @@ bool Mob::isWaterMob()
|
|||||||
void Mob::aiStep()
|
void Mob::aiStep()
|
||||||
{
|
{
|
||||||
//@todo? 30 lines of code here in java version
|
//@todo? 30 lines of code here in java version
|
||||||
|
|
||||||
TIMER_PUSH("ai");
|
TIMER_PUSH("ai");
|
||||||
if (isImmobile()) {
|
if (isImmobile()) {
|
||||||
jumping = false;
|
jumping = false;
|
||||||
|
|||||||
@@ -223,6 +223,9 @@ protected:
|
|||||||
double xc, yc, zc;
|
double xc, yc, zc;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
void setxxa(float xxa) { this->xxa = xxa; }
|
||||||
|
void setyya(float yya) { this->yya = yya; }
|
||||||
|
|
||||||
// Cape position accessors (for renderers)
|
// Cape position accessors (for renderers)
|
||||||
double getCapeX() const { return xCape; }
|
double getCapeX() const { return xCape; }
|
||||||
double getCapeY() const { return yCape; }
|
double getCapeY() const { return yCape; }
|
||||||
|
|||||||
Reference in New Issue
Block a user