FIX: Inventory change when cheating items (TODO: Linked slots)

This commit is contained in:
2026-03-27 17:05:50 +02:00
parent f9d9a0f0f9
commit 6957f144e1
3 changed files with 19 additions and 0 deletions

View File

@@ -386,6 +386,18 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& source, MovePlay
entity->lerpTo(packet->x, packet->y, packet->z, packet->yRot, packet->xRot, 3); entity->lerpTo(packet->x, packet->y, packet->z, packet->yRot, packet->xRot, 3);
} }
} }
void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& source, SendInventoryPacket* packet) {
if (!level) return;
// TODO: Linked slots
if (packet->entityId == minecraft->player->entityId) {
auto items = packet->items;
minecraft->player->inventory->replace(items);
}
}
void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& source, TakeItemPacket* packet) { void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& source, TakeItemPacket* packet) {
if (!level) return; if (!level) return;

View File

@@ -80,6 +80,7 @@ public:
virtual void handle(const RakNet::RakNetGUID& source, RemoveItemPacket* packet); virtual void handle(const RakNet::RakNetGUID& source, RemoveItemPacket* packet);
virtual void handle(const RakNet::RakNetGUID& source, TakeItemPacket* packet); virtual void handle(const RakNet::RakNetGUID& source, TakeItemPacket* packet);
virtual void handle(const RakNet::RakNetGUID& source, WantCreatePacket* packet); virtual void handle(const RakNet::RakNetGUID& source, WantCreatePacket* packet);
virtual void handle(const RakNet::RakNetGUID& source, SendInventoryPacket* packet);
private: private:

View File

@@ -7,6 +7,7 @@
#include "../world/inventory/BaseContainerMenu.h" #include "../world/inventory/BaseContainerMenu.h"
#include "network/packet/ContainerSetSlotPacket.h" #include "network/packet/ContainerSetSlotPacket.h"
#include "network/packet/RemoveBlockPacket.h" #include "network/packet/RemoveBlockPacket.h"
#include "network/packet/SendInventoryPacket.h"
#include "network/packet/UpdateBlockPacket.h" #include "network/packet/UpdateBlockPacket.h"
#include "network/packet/RemoveItemPacket.h" #include "network/packet/RemoveItemPacket.h"
#include "network/packet/TakeItemPacket.h" #include "network/packet/TakeItemPacket.h"
@@ -359,6 +360,7 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, MovePlay
//LOGI("MovePlayerPacket\n"); //LOGI("MovePlayerPacket\n");
if (Entity* entity = level->getEntity(packet->entityId)) if (Entity* entity = level->getEntity(packet->entityId))
{ {
entity->xd = entity->yd = entity->zd = 0; entity->xd = entity->yd = entity->zd = 0;
entity->lerpTo(packet->x, packet->y, packet->z, packet->yRot, packet->xRot, 3); entity->lerpTo(packet->x, packet->y, packet->z, packet->yRot, packet->xRot, 3);
@@ -477,6 +479,10 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, PlayerEq
if (slot < 0 && packet->itemId != 0) { if (slot < 0 && packet->itemId != 0) {
LOGW("PlayerEquipmentPacket: Remote player doesn't have his thing (or crafted it)!\n"); LOGW("PlayerEquipmentPacket: Remote player doesn't have his thing (or crafted it)!\n");
SendInventoryPacket newInventory (player, false);
raknetInstance->send(newInventory);
return; return;
} }