Skip to content

Commit

Permalink
add precomputed flags to Blocks that might get their color based on B…
Browse files Browse the repository at this point in the history
…iome

foliage has to be filled later
  • Loading branch information
EtlamGit committed Dec 26, 2016
1 parent ba62ec1 commit a3f48be
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions blockidentifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,19 @@ bool BlockInfo::canProvidePower() {
}

void BlockInfo::setName(const QString & newname) {
// set name
name = newname;
// precompute mob spawning conditions
bedrock = this->name.contains("Bedrock");
hopper = this->name.contains("Hopper");
stairs = this->name.contains("Stairs");
halfslab = this->name.contains("Slab") && !this->name.contains("Double") &&
!this->name.contains("Full");
snow = this->name.contains("Snow");
// precompute biome based colors
water = this->name.contains("Water");
grass = this->name.compare("Grass", Qt::CaseInsensitive) == 0;
foliage = false;
}

const QString & BlockInfo::getName() { return name; }
Expand All @@ -60,6 +66,9 @@ bool BlockInfo::isStairs() { return stairs; }
bool BlockInfo::isHalfSlab() { return halfslab; }
bool BlockInfo::isSnow() { return snow; }

bool BlockInfo::biomeWater() { return water; }
bool BlockInfo::biomeGrass() { return grass; }
bool BlockInfo::biomeFoliage() { return foliage; }


BlockIdentifier::BlockIdentifier() {
Expand Down
8 changes: 8 additions & 0 deletions blockidentifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ class BlockInfo {
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);
const QString &getName();

Expand All @@ -58,6 +63,9 @@ class BlockInfo {
bool stairs;
bool halfslab;
bool snow;
bool water;
bool grass;
bool foliage;
};

class BlockIdentifier {
Expand Down

0 comments on commit a3f48be

Please sign in to comment.