2 #include "server/server_item.h"
3 #include "server/server_node.h"
4 #include "server/server_terrain.h"
5 #include "server/tree_physics.h"
7 static void use_dig(__attribute__((unused)) ServerPlayer *player, ItemStack *stack, bool pointed, v3s32 pos)
13 TerrainChunk *chunk = terrain_get_chunk_nodep(server_terrain, pos, &off, false);
16 TerrainChunkMeta *meta = chunk->extra;
17 terrain_lock_chunk(chunk);
19 TerrainNode *node = &chunk->data[off.x][off.y][off.z];
21 if (!(node_def[node->type].dig_class & item_def[stack->type].dig_class)) {
22 pthread_mutex_unlock(&chunk->mtx);
26 *node = server_node_create(NODE_AIR);
27 meta->tgsb.raw.nodes[off.x][off.y][off.z] = STAGE_PLAYER;
29 pthread_mutex_unlock(&chunk->mtx);
31 server_terrain_lock_and_send_chunk(chunk);
33 // destroy trees if they have no connection to ground
34 // todo: run in seperate thread to not block client connection
35 tree_physics_check(pos);
38 ServerItemDef server_item_def[COUNT_ITEM] = {