Block Tracking

Discussion in 'Spigot Plugin Development' started by DiamondDagger590, Apr 27, 2017.

  1. So, mcmmo does a great job at tracking how blocks are placed, yet I can not find the code for it (I believe it is hidden) Im working on a plugin where this would be useful but I dont want a list of locations per chunk really unless this is the only way due to the possibility of having every block stored. (about 65024 blocks) What would be the best way to compress the data into a yml file? use base64 encoding?
     
  2. Could you clarify your question? I'm not sure I understood "tracking how blocks are placed".
     
    • Agree Agree x 1
  3. As far as I know, base64 compresses pretty bad, and with tens of thousands of blocks you probably don't want to be having a normal like .yml file, you need to use something like SQLite. Also, don't store blocks not placed in every chunk, that's a giant space waister, just store the blocks placed by players, then check the database if an entry with the same X Y and Z coords exist, if not, it was a natural block.
     
  4. You could store the block data as bytes and then check against sql db. Using @RubbaBoy approach
     
  5. Yea, what I had meant is that it had to handle the possibility of every block in a chunk being placed. And if SQLLite was used, then how does mcmmo do it for servers without it? Id like to have options for both flatfile and SQL

    And @_diam my question is what is the most effective and efficient way to track if a block is natural or not and have that tracking persist over server restarts. McMMO does a great job at it by loading things in as the chunks load but Im trying to figure out the best way to track blocks without having a large drag by reading a massive yml file.
     
  6. YML is a go to for more of a configurable type of config and what you are trying to do is store big data dumps and the parse them for checkings.

    Here is a benchmark of YML to other serialization formats, you can see the significant difference:https://gist.github.com/eirc/1300627

    I'd recommend a binary serialization format since they are the fastest. A good choice would be BSON which is a binary serialization implementation of JSON. You can either make your own parser and serializer using bytes or choose a more suitable already made one that does the job for you. However YML is a no go.
     
  7. WAS

    WAS

    In the example you show, BSON is much slower than YAML... YAML is 3rd in speed.

    Update: Nope. Yaji through me off. Lol damn dyslexia.

    However BSON seems to be just about as bad.