Skip to content
clonejo edited this page Mar 18, 2012 · 6 revisions

Server structure

Core processes ran as gen_server

  • mc_erl_chunk_manager
  • mc_erl_entity_tracker
  • mc_erl_tcp_listener
  • mc_erl_event_passer
  • mc_erl_player_sup

Data formats

  • chunk_location -> {X, Z}
  • block_location -> {X, Y, Z}
  • entity_position -> {X, Y, Z, Yaw, Pitch}
  • chunk_column_data -> {chunk_column_data, full_column, chunks=[], add_data=[], biome=Binary}
  • chunk_data -> {chunk_data, types=<<…>>>, metadata=<<…>>, block_light=<<…>>, sky_light=<<…>>}
  • block_data -> {Type, Metadata, Block_light, Sky_light, Biome}

Message formats

mc_erl_chunk_manager

  • Call {get_chunk, Chunk_location} - looks chunk up in storage or generates it. Returns #chunk_column_data.
  • Call {get_compressed_chunk, Chunk_location} - fetches a chunk in a get_chunk-like action, encodes it, stashes result in its private cache and returns raw binary chunk data.
  • Cast {set_block, Block_location, Block_data} - sets a block in the world.

mc_erl_entity_tracker

  • Call {register_entity, Type, Supervisor} - Type is player, mob or drop. Registers entity with entity_location_update message destination Supervisor and returns Eid. Supervisor may be none.
  • Call '{register_entity, Type, Supervisor, Entity_position}` - same as above, but also initializes it with starting position.
  • Cast {update_entity, Eid, Entity_position} - Updates entity position and broadcasts this to each Supervisor of entities nearby.
  • Message format for entity_tracker's casts to supervisors: {entity_location_update, Eid, NewLocation}

Clone this wiki locally