forked from mrkite/minutor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
blockidentifier.h
94 lines (77 loc) · 2.16 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/** Copyright (c) 2013, Sean Kasun */
#ifndef BLOCKIDENTIFIER_H_
#define BLOCKIDENTIFIER_H_
#include <QString>
#include <QMap>
#include <QHash>
#include <QList>
#include <QColor>
class JSONArray;
class JSONObject;
class BlockInfo {
public:
BlockInfo();
bool hasVariants() const;
// special block attribute used during mob spawning detection
bool isOpaque() const;
bool isLiquid() const;
bool doesBlockHaveSolidTopSurface() const;
bool isBlockNormalCube() const;
bool renderAsNormalBlock() const;
bool canProvidePower() const;
// special block type used during mob spawning detection
bool isBedrock();
bool isHopper();
bool isStairs();
bool isHalfSlab();
bool isSnow();
// special blocks with Biome based Grass, Foliage and Water colors
bool biomeWater();
bool biomeGrass();
bool biomeFoliage();
void setName(const QString &newname);
void setBiomeGrass(bool value);
void setBiomeFoliage(bool value);
const QString &getName();
// enabled for complete definition pack
bool enabled;
// internal state
double alpha;
QString blockstate;
bool variants; // block_state dependant variants
bool transparent;
bool liquid;
bool rendernormal;
bool providepower;
bool spawninside;
QColor colors[16];
private:
QString name;
// cache special block attributes used during mob spawning detection
bool bedrock;
bool hopper;
bool snow;
bool water;
bool grass;
bool foliage;
};
class BlockIdentifier {
public:
// singleton: access to global usable instance
static BlockIdentifier &Instance();
int addDefinitions(JSONArray *, int pack = -1);
void enableDefinitions(int id);
void disableDefinitions(int id);
BlockInfo &getBlockInfo(uint hid);
bool hasBlockInfo(uint hid);
private:
// singleton: prevent access to constructor and copyconstructor
BlockIdentifier();
~BlockIdentifier();
BlockIdentifier(const BlockIdentifier &);
BlockIdentifier &operator=(const BlockIdentifier &);
void parseDefinition(JSONObject *block, BlockInfo *parent, int pack);
QMap<uint, BlockInfo*> blocks;
QList<QList<BlockInfo*> > packs;
};
#endif // BLOCKIDENTIFIER_H_