prevent players from dropping and losing items

This commit is contained in:
p2r3
2025-08-24 20:41:48 +03:00
parent ab9ed43a9b
commit 549745516f
6 changed files with 80 additions and 12 deletions

View File

@@ -572,6 +572,20 @@ uint8_t getItemStackSize (uint16_t item) {
void handlePlayerAction (PlayerData *player, int action, short x, short y, short z) {
// Re-sync slot when player drops an item
if (action == 3 || action == 4) {
sc_setContainerSlot(
player->client_fd, 0,
serverSlotToClientSlot(0, player->hotbar),
player->inventory_count[player->hotbar],
player->inventory_items[player->hotbar]
);
return;
}
// Ignore further actions not pertaining to mining blocks
if (action != 0 && action != 2) return;
// In creative, only the "start mining" action is sent
// No additional verification is performed, the block is simply removed
if (action == 0 && GAMEMODE == 1) {
@@ -579,9 +593,6 @@ void handlePlayerAction (PlayerData *player, int action, short x, short y, short
return;
}
// Ignore actions not pertaining to mining blocks
if (action != 0 && action != 2) return;
uint8_t block = getBlockAt(x, y, z);
// If this is a "start mining" packet, the block must be instamine