forked from EXTERNAL/bareiron
support placing blocks on containers while sneaking
This commit is contained in:
@@ -95,6 +95,7 @@ typedef struct {
|
|||||||
uint8_t craft_count[9];
|
uint8_t craft_count[9];
|
||||||
// 0x01 - attack cooldown
|
// 0x01 - attack cooldown
|
||||||
// 0x02 - has not spawned yet
|
// 0x02 - has not spawned yet
|
||||||
|
// 0x04 - sneaking
|
||||||
uint8_t flags;
|
uint8_t flags;
|
||||||
} PlayerData;
|
} PlayerData;
|
||||||
|
|
||||||
|
@@ -49,6 +49,7 @@ int sc_systemChat (int client_fd, char* message, uint16_t len);
|
|||||||
int cs_interact (int client_fd);
|
int cs_interact (int client_fd);
|
||||||
int sc_entityEvent (int client_fd, int entity_id, uint8_t status);
|
int sc_entityEvent (int client_fd, int entity_id, uint8_t status);
|
||||||
int sc_removeEntity (int client_fd, int entity_id);
|
int sc_removeEntity (int client_fd, int entity_id);
|
||||||
|
int cs_playerInput (int client_fd);
|
||||||
int sc_registries (int client_fd);
|
int sc_registries (int client_fd);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -335,6 +335,10 @@ void handlePacket (int client_fd, int length, int packet_id) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 0x2A:
|
||||||
|
if (state == STATE_PLAY) cs_playerInput(client_fd);
|
||||||
|
break;
|
||||||
|
|
||||||
case 0x34:
|
case 0x34:
|
||||||
if (state == STATE_PLAY) cs_setHeldItem(client_fd);
|
if (state == STATE_PLAY) cs_setHeldItem(client_fd);
|
||||||
break;
|
break;
|
||||||
|
@@ -490,6 +490,11 @@ int cs_useItemOn (int client_fd) {
|
|||||||
int sequence = readVarInt(client_fd);
|
int sequence = readVarInt(client_fd);
|
||||||
sc_acknowledgeBlockChange(client_fd, sequence);
|
sc_acknowledgeBlockChange(client_fd, sequence);
|
||||||
|
|
||||||
|
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);
|
uint8_t target = getBlockAt(x, y, z);
|
||||||
if (target == B_crafting_table) {
|
if (target == B_crafting_table) {
|
||||||
sc_openScreen(client_fd, 12, "Crafting", 8);
|
sc_openScreen(client_fd, 12, "Crafting", 8);
|
||||||
@@ -498,6 +503,7 @@ int cs_useItemOn (int client_fd) {
|
|||||||
sc_openScreen(client_fd, 14, "Furnace", 7);
|
sc_openScreen(client_fd, 14, "Furnace", 7);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (face) {
|
switch (face) {
|
||||||
case 0: y -= 1; break;
|
case 0: y -= 1; break;
|
||||||
@@ -509,9 +515,6 @@ int cs_useItemOn (int client_fd) {
|
|||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerData *player;
|
|
||||||
if (getPlayerData(client_fd, &player)) return 1;
|
|
||||||
|
|
||||||
uint16_t *item = &player->inventory_items[player->hotbar];
|
uint16_t *item = &player->inventory_items[player->hotbar];
|
||||||
uint8_t *count = &player->inventory_count[player->hotbar];
|
uint8_t *count = &player->inventory_count[player->hotbar];
|
||||||
uint8_t block = I_to_B(*item);
|
uint8_t block = I_to_B(*item);
|
||||||
@@ -1028,6 +1031,21 @@ int sc_removeEntity (int client_fd, int entity_id) {
|
|||||||
return 0;
|
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)
|
// S->C Registry Data (multiple packets) and Update Tags (configuration, multiple packets)
|
||||||
int sc_registries (int client_fd) {
|
int sc_registries (int client_fd) {
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user