1
0
mirror of https://github.com/p2r3/bareiron.git synced 2025-10-02 07:35:08 +02:00

support placing blocks on containers while sneaking

This commit is contained in:
p2r3
2025-08-23 04:24:06 +03:00
parent 77c68c4dbc
commit ee69d3ab9b
4 changed files with 34 additions and 10 deletions

View File

@@ -490,13 +490,19 @@ int cs_useItemOn (int client_fd) {
int sequence = readVarInt(client_fd);
sc_acknowledgeBlockChange(client_fd, sequence);
uint8_t target = getBlockAt(x, y, z);
if (target == B_crafting_table) {
sc_openScreen(client_fd, 12, "Crafting", 8);
return 0;
} else if (target == B_furnace) {
sc_openScreen(client_fd, 14, "Furnace", 7);
return 0;
PlayerData *player;
if (getPlayerData(client_fd, &player)) return 1;
// Check interaction with containers when not sneaking
if (!(player->flags & 0x04)) {
uint8_t target = getBlockAt(x, y, z);
if (target == B_crafting_table) {
sc_openScreen(client_fd, 12, "Crafting", 8);
return 0;
} else if (target == B_furnace) {
sc_openScreen(client_fd, 14, "Furnace", 7);
return 0;
}
}
switch (face) {
@@ -509,9 +515,6 @@ int cs_useItemOn (int client_fd) {
default: break;
}
PlayerData *player;
if (getPlayerData(client_fd, &player)) return 1;
uint16_t *item = &player->inventory_items[player->hotbar];
uint8_t *count = &player->inventory_count[player->hotbar];
uint8_t block = I_to_B(*item);
@@ -1028,6 +1031,21 @@ int sc_removeEntity (int client_fd, int entity_id) {
return 0;
}
// C->S Player Input
int cs_playerInput (int client_fd) {
uint8_t flags = readByte(client_fd);
PlayerData *player;
if (getPlayerData(client_fd, &player)) return 1;
// Set or clear sneaking flag
if (flags & 0x20) player->flags |= 0x04;
else player->flags &= ~0x04;
return 0;
}
// S->C Registry Data (multiple packets) and Update Tags (configuration, multiple packets)
int sc_registries (int client_fd) {