Skip to content

Commit

Permalink
fix Mob spawn detection
Browse files Browse the repository at this point in the history
+ fix all Slabs
+ fix all Stairs
+ fix vegetables
  • Loading branch information
EtlamGit committed Dec 29, 2018
1 parent 57b05da commit 8e4ab09
Show file tree
Hide file tree
Showing 3 changed files with 283 additions and 58 deletions.
21 changes: 3 additions & 18 deletions blockidentifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,6 @@ bool BlockInfo::isLiquid() const {
return this->liquid;
}

bool BlockInfo::doesBlockHaveSolidTopSurface(int data) const {
if (this->isOpaque() && this->renderAsNormalBlock()) return true;
if (this->stairs && ((data & 4) == 4)) return true;
if (this->halfslab && ((data & 8) == 8)) return true;
if (this->hopper) return true;
if (this->snow && ((data & 7) == 7)) return true;
return false;
}

bool BlockInfo::doesBlockHaveSolidTopSurface() const {
if (this->isOpaque() && this->renderAsNormalBlock()) return true;
if (this->hopper) return true;
Expand All @@ -65,23 +56,17 @@ void BlockInfo::setName(const QString & newname) {
name = newname;
// precompute mob spawning conditions
bedrock = this->name.contains("Bedrock", Qt::CaseInsensitive);
hopper = this->name.contains("Hopper", Qt::CaseInsensitive);
stairs = this->name.contains("Stairs", Qt::CaseInsensitive);
halfslab = this->name.contains("Slab", Qt::CaseInsensitive) &&
!this->name.contains("Double", Qt::CaseInsensitive) &&
!this->name.contains("Full", Qt::CaseInsensitive);
snow = this->name.contains("Snow", Qt::CaseInsensitive);
hopper = this->name.contains("Hopper", Qt::CaseInsensitive);
snow = this->name.contains("Snow", Qt::CaseInsensitive);
// precompute biome based watercolormodifier
water = this->name.contains("Water", Qt::CaseInsensitive);
water = this->name.contains("Water", Qt::CaseInsensitive);
}

const QString & BlockInfo::getName() { return name; }


bool BlockInfo::isBedrock() { return bedrock; }
bool BlockInfo::isHopper() { return hopper; }
bool BlockInfo::isStairs() { return stairs; }
bool BlockInfo::isHalfSlab() { return halfslab; }
bool BlockInfo::isSnow() { return snow; }

bool BlockInfo::biomeWater() { return water; }
Expand Down
10 changes: 5 additions & 5 deletions blockidentifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class BlockInfo {
// special block attribute used during mob spawning detection
bool isOpaque() const;
bool isLiquid() const;
bool doesBlockHaveSolidTopSurface(int data) const;
bool doesBlockHaveSolidTopSurface() const;
bool isBlockNormalCube() const;
bool renderAsNormalBlock() const;
Expand All @@ -44,10 +43,13 @@ class BlockInfo {
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 enabled;
bool transparent;
bool liquid;
bool rendernormal;
Expand All @@ -60,8 +62,6 @@ class BlockInfo {
// cache special block attributes used during mob spawning detection
bool bedrock;
bool hopper;
bool stairs;
bool halfslab;
bool snow;
bool water;
bool grass;
Expand All @@ -73,7 +73,7 @@ class BlockIdentifier {
// singleton: access to global usable instance
static BlockIdentifier &Instance();

int addDefinitions(JSONArray *, int pack = -1);
int addDefinitions(JSONArray *, int pack = -1);
void enableDefinitions(int id);
void disableDefinitions(int id);
BlockInfo &getBlockInfo(uint hid);
Expand Down
Loading

0 comments on commit 8e4ab09

Please sign in to comment.