Skip to content

Commit

Permalink
read usage of Biome based colorizer from Block definition file
Browse files Browse the repository at this point in the history
  • Loading branch information
EtlamGit committed Dec 27, 2016
1 parent 67705c8 commit 644c196
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 22 deletions.
15 changes: 11 additions & 4 deletions blockidentifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
static BlockInfo unknownBlock;

BlockInfo::BlockInfo() : transparent(false), liquid(false), rendernormal(true),
providepower(false), spawninside(false) {}
providepower(false), spawninside(false), grass(false), foliage(false) {}

bool BlockInfo::isOpaque() {
return !(this->transparent);
Expand Down Expand Up @@ -51,10 +51,8 @@ void BlockInfo::setName(const QString & newname) {
halfslab = this->name.contains("Slab") && !this->name.contains("Double") &&
!this->name.contains("Full");
snow = this->name.contains("Snow");
// precompute biome based colors
// precompute biome based watercolormodifier
water = this->name.contains("Water");
grass = this->name.compare("Grass", Qt::CaseInsensitive) == 0;
foliage = false;
}

const QString & BlockInfo::getName() { return name; }
Expand All @@ -70,6 +68,8 @@ bool BlockInfo::biomeWater() { return water; }
bool BlockInfo::biomeGrass() { return grass; }
bool BlockInfo::biomeFoliage() { return foliage; }

void BlockInfo::setBiomeGrass(bool value) { grass = value; }
void BlockInfo::setBiomeFoliage(bool value) { foliage = value; }

BlockIdentifier::BlockIdentifier() {
// clear cache pointers
Expand Down Expand Up @@ -257,6 +257,13 @@ void BlockIdentifier::parseDefinition(JSONObject *b, BlockInfo *parent,
255*block->alpha );
}

// biome dependant color
if (b->has("biomeGrass"))
block->setBiomeGrass( b->at("biomeGrass")->asBool() );
if (b->has("biomeFoliage"))
block->setBiomeFoliage( b->at("biomeFoliage")->asBool() );

// variant reduction mask
if (b->has("mask"))
block->mask = b->at("mask")->asNumber();
else if (b->has("variants"))
Expand Down
13 changes: 5 additions & 8 deletions blockidentifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,20 @@
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();

// special block attribute used during mob spawning detection
bool isOpaque();
bool isLiquid();
bool doesBlockHaveSolidTopSurface(int data);
bool isBlockNormalCube();
bool renderAsNormalBlock();
bool canProvidePower();

// special blocks used during mob spawning detection
// special block type used during mob spawning detection
bool isBedrock();
bool isHopper();
bool isStairs();
Expand All @@ -42,6 +37,8 @@ class BlockInfo {
bool biomeFoliage();

void setName(const QString &newname);
void setBiomeGrass(bool value);
void setBiomeFoliage(bool value);
const QString &getName();

int id;
Expand Down
36 changes: 34 additions & 2 deletions definitions/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,30 @@ deobfuscated 1.8.x code is not available.



Other special attribute value pairs in this file:
Other attribute value pairs in this file:

"mask": number
"id": integer_number

Numerical code used in the savegame for this block


"name": "Name of Block"

String representation of this Block, shown in status bar when hovering mouse over


"color": "#ffffff"

Color usedd for rendering this block


"alpha": float_number

In case the block is transparent (e.g. water) this defines the amount it coveres
the block below. 0.0 is completely transparent. 1.0 is the default, a opaque block.


"mask": integer_number

In case a block has variants a mask can be given to blend out bits in the data
field that are not used to define the block itself. These bits are mostely used
Expand All @@ -68,5 +89,16 @@ to define block orientation.
if a block has some variants defined, "mask": 15 is predefined


"biomeGrass": boolean

When color of block is changing based on Biome and is based on the Grass Colorizer,
this flag has to be set true. Defaults to false.


"biomeFoliage": boolean

When color of block is changing based on Biome and is based on the Foliage Colorizer,
this flag has to be set true. Defaults to false.


[EtlamGit]
22 changes: 14 additions & 8 deletions definitions/vanilla_ids.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Vanilla",
"type": "block",
"version": "1.11.16w39a",
"version": "1.11.16w40a",
"data": [
{
"id": 0,
Expand Down Expand Up @@ -51,7 +51,8 @@
{
"id": 2,
"name": "Grass",
"color": "#78bf64"
"color": "#939393",
"biomeGrass": true
},
{
"id": 3,
Expand Down Expand Up @@ -358,12 +359,14 @@
{
"data": 1,
"name": "Tall Grass",
"color": "#83bf54"
"color": "#909090",
"biomeGrass": true
},
{
"data": 2,
"name": "Fern",
"color": "#8fbb64"
"color": "#828282",
"biomeGrass": true
}
]
},
Expand Down Expand Up @@ -942,9 +945,10 @@
{
"id": 83,
"name": "Sugar Cane",
"color": "#aadb74",
"color": "#97c06b",
"spawninside": true,
"transparent": true
"transparent": true,
"biomeGrass": true
},
{
"id": 84,
Expand Down Expand Up @@ -2200,12 +2204,14 @@
{
"data": 2,
"name": "Double Tallgrass",
"color": "#5e8328"
"color": "#969696",
"biomeGrass": true
},
{
"data": 3,
"name": "Large Fern",
"color": "#617b2d"
"color": "#828282",
"biomeGrass": true
},
{
"data": 4,
Expand Down

0 comments on commit 644c196

Please sign in to comment.