fixes issue #139

This commit is contained in:
walterhiggins 2014-05-28 22:40:38 +01:00
parent fa64f07c38
commit a2b0cda399

View file

@ -654,6 +654,7 @@ var putBlock = function( x, y, z, blockId, metadata, world ) {
var block = world.getBlockAt( x, y, z ); var block = world.getBlockAt( x, y, z );
if ( block.typeId != blockId || block.data != metadata ) { if ( block.typeId != blockId || block.data != metadata ) {
block.setTypeIdAndData( blockId, metadata, false ); block.setTypeIdAndData( blockId, metadata, false );
block.data = metadata;
} }
}; };
@ -1580,12 +1581,18 @@ var _cylinder1 = function( block,radius,height,exactParams ) {
}; };
var _paste = function( name, immediate ) var _paste = function( name, immediate )
{ {
/* if ( !immediate ) {
if ( !immediate ) { var clone = Drone.clone(this);
getQueue(this).push(function(){ _paste(name, true);}); getQueue(this).push(this.paste.bind(clone, name, true) );
return; return;
} }
*/
var ccContent = Drone.clipBoard[name]; var ccContent = Drone.clipBoard[name];
if (ccContent == undefined){
console.warn('Nothing called ' + name + ' in clipboard!');
return;
}
var srcBlocks = ccContent.blocks; var srcBlocks = ccContent.blocks;
var srcDir = ccContent.dir; // direction player was facing when copied. var srcDir = ccContent.dir; // direction player was facing when copied.
var dirOffset = (4 + (this.dir - srcDir ) ) %4; var dirOffset = (4 + (this.dir - srcDir ) ) %4;
@ -1597,9 +1604,8 @@ var _paste = function( name, immediate )
var d = srcBlocks[ww][hh].length; var d = srcBlocks[ww][hh].length;
_traverse[that.dir].depth(that,d,function( dd ) { _traverse[that.dir].depth(that,d,function( dd ) {
var b = srcBlocks[ww][hh][dd]; var b = srcBlocks[ww][hh][dd];
var bm = that._getBlockIdAndMeta(b ); var cb = b.type
var cb = bm[0]; var md = b.data;
var md = bm[1];
// //
// need to adjust blocks which face a direction // need to adjust blocks which face a direction
// //
@ -1607,59 +1613,59 @@ var _paste = function( name, immediate )
// //
// doors // doors
// //
case 64: // wood case 64: // wood
case 71: // iron case 71: // iron
// top half of door doesn't need to change // top half of door doesn't need to change
if ( md < 8 ) { if ( md < 8 ) {
md = (md + dirOffset ) % 4; md = (md + dirOffset ) % 4;
} }
break; break;
// //
// stairs // stairs
// //
case 53: // oak case 53: // oak
case 67: // cobblestone case 67: // cobblestone
case 108: // red brick case 108: // red brick
case 109: // stone brick case 109: // stone brick
case 114: // nether brick case 114: // nether brick
case 128: // sandstone case 128: // sandstone
case 134: // spruce case 134: // spruce
case 135: // birch case 135: // birch
case 136: // junglewood case 136: // junglewood
var dir = md & 0x3; var dir = md & 0x3;
var a = Drone.PLAYER_STAIRS_FACING; var a = Drone.PLAYER_STAIRS_FACING;
var len = a.length; var len = a.length;
for ( var c=0;c < len;c++ ) { for ( var c=0;c < len;c++ ) {
if ( a[c] == dir ) { if ( a[c] == dir ) {
break; break;
}
} }
} c = (c + dirOffset ) %4;
c = (c + dirOffset ) %4; var newDir = a[c];
var newDir = a[c]; md = (md >>2<<2 ) + newDir;
md = (md >>2<<2 ) + newDir; break;
break;
// //
// signs , ladders etc // signs , ladders etc
// //
case 23: // dispenser case 23: // dispenser
case 54: // chest case 54: // chest
case 61: // furnace case 61: // furnace
case 62: // burning furnace case 62: // burning furnace
case 65: // ladder case 65: // ladder
case 68: // wall sign case 68: // wall sign
var a = Drone.PLAYER_SIGN_FACING; var a = Drone.PLAYER_SIGN_FACING;
var len = a.length; var len = a.length;
for ( var c=0;c < len;c++ ) { for ( var c=0;c < len;c++ ) {
if ( a[c] == md ) { if ( a[c] == md ) {
break; break;
}
} }
c = (c + dirOffset ) %4;
var newDir = a[c];
md = newDir;
break;
} }
c = (c + dirOffset ) %4; putBlock(that.x,that.y,that.z,cb,md,that.world );
var newDir = a[c];
md = newDir;
break;
}
putBlock(that.x,that.y,that.z,cb,md,that.world );
} ); } );
} ); } );
} ); } );
@ -1809,7 +1815,7 @@ var _copy = function( name, w, h, d ) {
ccContent[ww].push([] ); ccContent[ww].push([] );
_traverse[that.dir].depth(that,d,function( dd ) { _traverse[that.dir].depth(that,d,function( dd ) {
var b = that.world.getBlockAt(that.x,that.y,that.z ); var b = that.world.getBlockAt(that.x,that.y,that.z );
ccContent[ww][hh][dd] = b; ccContent[ww][hh][dd] = {type:b.getTypeId(), data:b.data};
} ); } );
} ); } );
} ); } );