forked from mrkite/minutor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblockidentifier.h
78 lines (67 loc) · 1.63 KB
/
blockidentifier.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/** Copyright (c) 2013, Sean Kasun */
#ifndef BLOCKIDENTIFIER_H_
#define BLOCKIDENTIFIER_H_
#include <QString>
#include <QMap>
#include <QHash>
#include <QList>
class JSONArray;
class JSONObject;
// bit masks for the flags
#define BlockTransparent 1
#define BlockSolid 2
#define BlockLiquid 4
// mobs can't spawn on transparent, but need 2 blocks of transparent,
// non solid, non liquid above
class BlockInfo {
public:
BlockInfo();
bool isOpaque();
bool isLiquid();
bool doesBlockHaveSolidTopSurface(int data);
bool isBlockNormalCube();
bool renderAsNormalBlock();
bool canProvidePower();
// special blocks used during mob spawning detection
bool isBedrock();
bool isHopper();
bool isStairs();
bool isHalfSlab();
bool isSnow();
void setName(const QString &newname);
const QString &getName();
int id;
double alpha;
quint8 mask;
bool enabled;
bool transparent;
bool liquid;
bool rendernormal;
bool providepower;
bool spawninside;
quint32 colors[16];
private:
QString name;
// cache special blocks used during mob spawning detection
bool bedrock;
bool hopper;
bool stairs;
bool halfslab;
bool snow;
};
class BlockIdentifier {
public:
BlockIdentifier();
~BlockIdentifier();
int addDefinitions(JSONArray *, int pack = -1);
void enableDefinitions(int id);
void disableDefinitions(int id);
BlockInfo &getBlock(int id, int data);
private:
void clearCache();
void parseDefinition(JSONObject *block, BlockInfo *parent, int pack);
QMap<quint32, QList<BlockInfo *>> blocks;
QList<QList<BlockInfo*> > packs;
BlockInfo *cache[65536];
};
#endif // BLOCKIDENTIFIER_H_