Skip to content

Commit bff2393

Browse files
committed
Fix issue #269 for both spigot and canary - make sure new stairs don't cause same issue again.
1 parent 0dbff00 commit bff2393

3 files changed

Lines changed: 36 additions & 44 deletions

File tree

src/main/js/modules/blockhelper.js

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -98,31 +98,24 @@ function applyFacing( block, metadata ){
9898
function face(direction){
9999
property(block).set('facing', lookup.facing[direction]);
100100
}
101-
switch( block.typeId ){
102-
case blocks.stairs.oak:
103-
case blocks.stairs.cobblestone:
104-
case blocks.stairs.brick:
105-
case blocks.stairs.stone:
106-
case blocks.stairs.nether:
107-
case blocks.stairs.sandstone:
108-
case blocks.stairs.spruce:
109-
case blocks.stairs.jungle:
110-
case blocks.stairs.quartz:
111-
face( ['east','west','south','north'][metadata] );
112-
break;
113-
case blocks.sign:
114-
case blocks.ladder:
115-
// bug: furnace, chest, dispenser don't always use the right metadata
116-
case blocks.furnace:
117-
case blocks.furnace_burning:
118-
case blocks.chest:
119-
case blocks.enderchest:
120-
case blocks.dispenser:
121-
face( [null,null,'north','south','west','east'][metadata] );
122-
break;
123-
case blocks.torch:
124-
face( ['up'/* default */,'east','west','south','north','up'][metadata] );
125-
break;
101+
if ( blocks.isStair(block.typeId) ){
102+
face( ['east','west','south','north'] [metadata] );
103+
} else {
104+
switch( block.typeId ){
105+
case blocks.sign:
106+
case blocks.ladder:
107+
// bug: furnace, chest, dispenser don't always use the right metadata
108+
case blocks.furnace:
109+
case blocks.furnace_burning:
110+
case blocks.chest:
111+
case blocks.enderchest:
112+
case blocks.dispenser:
113+
face( [null,null,'north','south','west','east'][metadata] );
114+
break;
115+
case blocks.torch:
116+
face( ['up'/* default */,'east','west','south','north','up'][metadata] );
117+
break;
118+
}
126119
}
127120
}
128121
function applyColors( block, metadata ){

src/main/js/modules/blocks.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,5 +325,12 @@ blocks.rainbow = [
325325
blocks.stained_glass.blue,
326326
blocks.stained_glass.purple
327327
];
328-
328+
blocks.isStair = function(id){
329+
var p;
330+
for (p in this.stairs){
331+
if (this.stairs[p] == id)
332+
return true;
333+
}
334+
return false;
335+
};
329336
module.exports = blocks;

src/main/js/modules/drone/index.js

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -766,29 +766,20 @@ Drone.prototype.debug = function( ) {
766766

767767
function getBlockIdAndMeta( b ) {
768768
var defaultMeta = 0,
769-
i = 0,
770-
bs,
771-
md,
772-
sp;
769+
i = 0,
770+
bs,
771+
md,
772+
sp;
773773
if (typeof b === 'number' || /^[0-9]+$/.test(b)) {
774774
// wph 20130414 - use sensible defaults for certain blocks e.g. stairs
775775
// should face the drone.
776-
switch (b) {
777-
case blocks.stairs.birch:
778-
case blocks.stairs.brick:
779-
case blocks.stairs.cobblestone:
780-
case blocks.stairs.jungle:
781-
case blocks.stairs.nether:
782-
case blocks.stairs.oak:
783-
case blocks.stairs.quartz:
784-
case blocks.stairs.sandstone:
785-
case blocks.stairs.spruce:
786-
case blocks.stairs.stone:
787-
defaultMeta = Drone.PLAYER_STAIRS_FACING[ this.dir % 4 ];
788-
break;
776+
if ( blocks.isStair(b) ) {
777+
defaultMeta = Drone.PLAYER_STAIRS_FACING[ this.dir % 4 ];
778+
} else {
779+
switch (b) {
789780
case blocks.sign:
790781
case blocks.ladder:
791-
// bug: furnace, chest, dispenser don't always use the right metadata
782+
// bug: furnace, chest, dispenser don't always use the right metadata
792783
case blocks.furnace:
793784
case blocks.furnace_burning:
794785
case blocks.chest:
@@ -799,6 +790,7 @@ function getBlockIdAndMeta( b ) {
799790
case blocks.sign_post:
800791
defaultMeta = ( 12 + ( ( this.dir + 2 ) * 4 ) ) % 16;
801792
break;
793+
}
802794
}
803795
return [ b, defaultMeta ];
804796
}

0 commit comments

Comments
 (0)