summaryrefslogblamecommitdiffstats
path: root/src/Block.hpp
blob: 12d2907e0aca6e7ecaa43bfa8c9eb40d397f9517 (plain) (tree)
1
2
3
4
5
6
7
8
9

            

                     
              
                
 
                                                                                              
 
                 
 

                                

                            




                            

  

                                                        













                                                               
#pragma once

#include <functional>

struct Block {
	Block();

	Block(unsigned short id, unsigned char state, unsigned char light, unsigned char sky);

	~Block();

	unsigned short id : 13;
	unsigned char state : 4;
    unsigned char light : 4;
    unsigned char sky : 4;
};

struct BlockId {
    unsigned short id : 13;
    unsigned char state : 4;
};

bool operator==(const BlockId& lhs, const BlockId &rhs);

bool operator<(const BlockId& lhs, const BlockId &rhs);

namespace std {
    template <>
    struct hash<BlockId> {
        std::size_t operator()(const BlockId& k) const
        {
            size_t id = std::hash<unsigned short>()(k.id);
            size_t state = std::hash<unsigned char>()(k.state);

            return (id & state << 1);
        }
    };
}