Fix issue #269 for both spigot and canary - make sure new stairs don't cause same issue again.

This commit is contained in:
walterhiggins 2015-08-29 19:07:19 +01:00
parent 0dbff00703
commit bff23932a7
3 changed files with 36 additions and 44 deletions

View file

@ -98,31 +98,24 @@ function applyFacing( block, metadata ){
function face(direction){ function face(direction){
property(block).set('facing', lookup.facing[direction]); property(block).set('facing', lookup.facing[direction]);
} }
switch( block.typeId ){ if ( blocks.isStair(block.typeId) ){
case blocks.stairs.oak: face( ['east','west','south','north'] [metadata] );
case blocks.stairs.cobblestone: } else {
case blocks.stairs.brick: switch( block.typeId ){
case blocks.stairs.stone: case blocks.sign:
case blocks.stairs.nether: case blocks.ladder:
case blocks.stairs.sandstone: // bug: furnace, chest, dispenser don't always use the right metadata
case blocks.stairs.spruce: case blocks.furnace:
case blocks.stairs.jungle: case blocks.furnace_burning:
case blocks.stairs.quartz: case blocks.chest:
face( ['east','west','south','north'][metadata] ); case blocks.enderchest:
break; case blocks.dispenser:
case blocks.sign: face( [null,null,'north','south','west','east'][metadata] );
case blocks.ladder: break;
// bug: furnace, chest, dispenser don't always use the right metadata case blocks.torch:
case blocks.furnace: face( ['up'/* default */,'east','west','south','north','up'][metadata] );
case blocks.furnace_burning: break;
case blocks.chest: }
case blocks.enderchest:
case blocks.dispenser:
face( [null,null,'north','south','west','east'][metadata] );
break;
case blocks.torch:
face( ['up'/* default */,'east','west','south','north','up'][metadata] );
break;
} }
} }
function applyColors( block, metadata ){ function applyColors( block, metadata ){

View file

@ -325,5 +325,12 @@ blocks.rainbow = [
blocks.stained_glass.blue, blocks.stained_glass.blue,
blocks.stained_glass.purple blocks.stained_glass.purple
]; ];
blocks.isStair = function(id){
var p;
for (p in this.stairs){
if (this.stairs[p] == id)
return true;
}
return false;
};
module.exports = blocks; module.exports = blocks;

View file

@ -766,29 +766,20 @@ Drone.prototype.debug = function( ) {
function getBlockIdAndMeta( b ) { function getBlockIdAndMeta( b ) {
var defaultMeta = 0, var defaultMeta = 0,
i = 0, i = 0,
bs, bs,
md, md,
sp; sp;
if (typeof b === 'number' || /^[0-9]+$/.test(b)) { if (typeof b === 'number' || /^[0-9]+$/.test(b)) {
// wph 20130414 - use sensible defaults for certain blocks e.g. stairs // wph 20130414 - use sensible defaults for certain blocks e.g. stairs
// should face the drone. // should face the drone.
switch (b) { if ( blocks.isStair(b) ) {
case blocks.stairs.birch: defaultMeta = Drone.PLAYER_STAIRS_FACING[ this.dir % 4 ];
case blocks.stairs.brick: } else {
case blocks.stairs.cobblestone: switch (b) {
case blocks.stairs.jungle:
case blocks.stairs.nether:
case blocks.stairs.oak:
case blocks.stairs.quartz:
case blocks.stairs.sandstone:
case blocks.stairs.spruce:
case blocks.stairs.stone:
defaultMeta = Drone.PLAYER_STAIRS_FACING[ this.dir % 4 ];
break;
case blocks.sign: case blocks.sign:
case blocks.ladder: case blocks.ladder:
// bug: furnace, chest, dispenser don't always use the right metadata // bug: furnace, chest, dispenser don't always use the right metadata
case blocks.furnace: case blocks.furnace:
case blocks.furnace_burning: case blocks.furnace_burning:
case blocks.chest: case blocks.chest:
@ -799,6 +790,7 @@ function getBlockIdAndMeta( b ) {
case blocks.sign_post: case blocks.sign_post:
defaultMeta = ( 12 + ( ( this.dir + 2 ) * 4 ) ) % 16; defaultMeta = ( 12 + ( ( this.dir + 2 ) * 4 ) ) % 16;
break; break;
}
} }
return [ b, defaultMeta ]; return [ b, defaultMeta ];
} }