Skip to content

Commit

Permalink
adding block-colors module
Browse files Browse the repository at this point in the history
  • Loading branch information
walterhiggins committed May 24, 2015
1 parent 4a2ea3c commit 734e058
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
19 changes: 19 additions & 0 deletions src/main/js/modules/block-colors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
var colors = {
white: 0,
orange: 1,
magenta: 2,
lightblue: 3,
yellow: 4,
lime: 5,
pink: 6,
gray: 7,
lightgray: 8,
cyan: 9,
purple: 10,
blue: 11,
brown: 12,
green: 13,
red: 14,
black: 15
};
module.exports = colors;
5 changes: 5 additions & 0 deletions src/main/js/modules/blockhelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,15 @@ function applyFacing( block, metadata ){
function applyColors( block, metadata ){
switch( block.typeId){
case blocks.wool.white:
case 35:
case blocks.stained_clay.white:
case 159:
case blocks.stained_glass.white:
case 95:
case blocks.stained_glass_pane.white:
case 160:
case blocks.carpet.white:
case 171:
property(block).set('color',metadata);
}
}
Expand Down
24 changes: 5 additions & 19 deletions src/main/js/modules/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ approximations).
The blocks module is globally exported by the Drone module.
***/
var colors = require('./block-colors');

var blocks = {
air: 0,
stone: 1,
Expand Down Expand Up @@ -291,23 +293,6 @@ var blocks = {

// Add all available colors to colorized block collections

var colors = {
orange: ':1',
magenta: ':2',
lightblue: ':3',
yellow: ':4',
lime: ':5',
pink: ':6',
gray: ':7',
lightgray: ':8',
cyan: ':9',
purple: ':10',
blue: ':11',
brown: ':12',
green: ':13',
red: ':14',
black: ':15'
};
var colorized_blocks = [
'wool',
'stained_clay',
Expand All @@ -321,7 +306,7 @@ for (var i = 0, len = colorized_blocks.length; i < len; i++) {
data_value = blocks[block].white;

for (var color in colors) {
blocks[block][color] = data_value + colors[color];
blocks[block][color] = data_value + ':' + colors[color];
}
};

Expand All @@ -338,6 +323,7 @@ blocks.rainbow = [
blocks.stained_glass.lime,
blocks.stained_glass.lightblue,
blocks.stained_glass.blue,
blocks.stained_glass.purple];
blocks.stained_glass.purple
];

module.exports = blocks;

0 comments on commit 734e058

Please sign in to comment.