Further work on Drone for 1.8 Doors now work! and Chessboard, rainbow and all colored materials.
This commit is contained in:
parent
1443b37ec4
commit
21a64efca0
2 changed files with 92 additions and 87 deletions
|
@ -3,10 +3,45 @@
|
||||||
var Facing = Packages.net.minecraft.util.EnumFacing;
|
var Facing = Packages.net.minecraft.util.EnumFacing;
|
||||||
var DoorHalf = Packages.net.minecraft.block.BlockDoor.EnumDoorHalf;
|
var DoorHalf = Packages.net.minecraft.block.BlockDoor.EnumDoorHalf;
|
||||||
var HingePosition = Packages.net.minecraft.block.BlockDoor.EnumHingePosition;
|
var HingePosition = Packages.net.minecraft.block.BlockDoor.EnumHingePosition;
|
||||||
|
var DyeColor = Packages.net.minecraft.item.EnumDyeColor;
|
||||||
var table = {
|
var table = {
|
||||||
facing: [ Facing.EAST, Facing.SOUTH, Facing.WEST, Facing.NORTH],
|
facing: [ Facing.EAST, Facing.SOUTH, Facing.WEST, Facing.NORTH],
|
||||||
half: { upper: DoorHalf.UPPER, lower: DoorHalf.LOWER },
|
half: { upper: DoorHalf.UPPER, lower: DoorHalf.LOWER },
|
||||||
hinge: { left: HingePosition.LEFT, right: HingePosition.RIGHT }
|
hinge: { left: HingePosition.LEFT, right: HingePosition.RIGHT },
|
||||||
|
color: {
|
||||||
|
black: DyeColor.BLACK,
|
||||||
|
blue: DyeColor.BLUE,
|
||||||
|
brown: DyeColor.BROWN,
|
||||||
|
cyan: DyeColor.CYAN,
|
||||||
|
gray: DyeColor.GRAY,
|
||||||
|
green: DyeColor.GREEN,
|
||||||
|
lightblue: DyeColor.LIGHT_BLUE,
|
||||||
|
lime: DyeColor.LIME,
|
||||||
|
magenta: DyeColor.MAGENTA,
|
||||||
|
orange: DyeColor.ORANGE,
|
||||||
|
pink: DyeColor.PINK,
|
||||||
|
purple: DyeColor.PURPLE,
|
||||||
|
red: DyeColor.RED,
|
||||||
|
silver: DyeColor.SILVER,
|
||||||
|
white: DyeColor.WHITE,
|
||||||
|
yellow: DyeColor.YELLOW,
|
||||||
|
0: DyeColor.WHITE,
|
||||||
|
1: DyeColor.ORANGE,
|
||||||
|
2: DyeColor.MAGENTA,
|
||||||
|
3: DyeColor.LIGHT_BLUE,
|
||||||
|
4: DyeColor.YELLOW,
|
||||||
|
5: DyeColor.LIME,
|
||||||
|
6: DyeColor.PINK,
|
||||||
|
7: DyeColor.GRAY,
|
||||||
|
8: DyeColor.SILVER,
|
||||||
|
9: DyeColor.CYAN,
|
||||||
|
10: DyeColor.PURPLE,
|
||||||
|
11: DyeColor.BLUE,
|
||||||
|
12: DyeColor.BROWN,
|
||||||
|
13: DyeColor.GREEN,
|
||||||
|
14: DyeColor.RED,
|
||||||
|
15: DyeColor.BLACK
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function property( block ){
|
function property( block ){
|
||||||
|
|
|
@ -578,11 +578,28 @@ function putBlock( 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 ) {
|
||||||
if (__plugin.canary) {
|
if (__plugin.canary) {
|
||||||
//console.log(JSON.stringify([x,y,z,blockId,metadata]));
|
world.setBlockAt(x, y, z, blockId, metadata);
|
||||||
if (block.getProperties){
|
if (block.getProperties){
|
||||||
// TODO we are in 1.8
|
// TODO we are in 1.8
|
||||||
|
var prop = require('blockhelper').property;
|
||||||
|
block = world.getBlockAt(x,y,z);
|
||||||
|
switch (blockId){
|
||||||
|
case blocks.wool.white:
|
||||||
|
case blocks.stained_clay.white:
|
||||||
|
case blocks.stained_glass.white:
|
||||||
|
case blocks.carpet.white:
|
||||||
|
prop(block).set('color',metadata);
|
||||||
|
block.update();
|
||||||
|
break;
|
||||||
|
case blocks.torch:
|
||||||
|
/* TODO This doesn't work right now */
|
||||||
|
if (metadata >= 0 && metadata <= 3){
|
||||||
|
prop(block).set('facing',metadata);
|
||||||
|
block.update();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
world.setBlockAt(x, y, z, blockId, metadata);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (__plugin.bukkit) {
|
if (__plugin.bukkit) {
|
||||||
|
@ -1128,63 +1145,51 @@ Drone.prototype.cuboid0 = function( block, w, h, d ) {
|
||||||
return this.move( 'start_point' );
|
return this.move( 'start_point' );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function door( doorMaterial, hinge) {
|
||||||
Drone.extend( function door( doorMaterial ) {
|
|
||||||
if ( typeof doorMaterial == 'undefined' ) {
|
if ( typeof doorMaterial == 'undefined' ) {
|
||||||
doorMaterial = 64; // wood
|
doorMaterial = 64; // wood
|
||||||
} else {
|
}
|
||||||
doorMaterial = 71; // iron
|
if (typeof hinge == 'undefined') {
|
||||||
|
hinge = 'left';
|
||||||
}
|
}
|
||||||
this.then(function(){
|
this.then(function(){
|
||||||
putBlock( this.x, this.y, this.z, doorMaterial, this.dir, this.world );
|
putBlock( this.x, this.y, this.z, doorMaterial, this.dir, this.world );
|
||||||
putBlock( this.x, this.y+1, this.z, doorMaterial, 8, this.world );
|
putBlock( this.x, this.y+1, this.z, doorMaterial, 8, this.world );
|
||||||
var block = this.world.getBlockAt(this.x,this.y,this.z);
|
var lower = this.world.getBlockAt(this.x,this.y,this.z);
|
||||||
if (block.getProperties){
|
var upper = this.world.getBlockAt(this.x,this.y+1,this.z);
|
||||||
|
if (upper.getProperties){
|
||||||
// 1.8
|
// 1.8
|
||||||
var prop = require('blockhelper').property;
|
var prop = require('blockhelper').property;
|
||||||
prop(block)
|
prop(upper)
|
||||||
|
.set('half','upper')
|
||||||
|
.set('hinge',hinge);
|
||||||
|
prop(lower)
|
||||||
.set('facing',this.dir)
|
.set('facing',this.dir)
|
||||||
.set('hinge','left')
|
|
||||||
.set('half','lower');
|
.set('half','lower');
|
||||||
var Position = Packages.net.canarymod.api.world.position.Position;
|
|
||||||
var setBlockAt = 'setBlockAt(net.canarymod.api.world.position.Position, net.canarymod.api.world.blocks.Block)';
|
|
||||||
this.world[setBlockAt](new Position(this.x,this.y,this.z),block);
|
|
||||||
|
|
||||||
block = this.world.getBlockAt(this.x,this.y+1,this.z);
|
upper.update();
|
||||||
prop(block)
|
lower.update();
|
||||||
.set('facing',this.dir)
|
|
||||||
.set('hinge','left')
|
|
||||||
.set('half','upper');
|
|
||||||
this.world[setBlockAt](new Position(this.x,this.y+1,this.z),block);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} );
|
}
|
||||||
|
Drone.extend( door );
|
||||||
|
|
||||||
Drone.extend( function door_iron( ) {
|
Drone.extend( function door_iron( ) {
|
||||||
this.cuboidX( 71, this.dir )
|
this.door(71);
|
||||||
.up( )
|
|
||||||
.cuboidX( 71, 8 )
|
|
||||||
.down( );
|
|
||||||
} );
|
} );
|
||||||
|
|
||||||
Drone.extend( function door2( doorMaterial ) {
|
Drone.extend( function door2( doorMaterial ) {
|
||||||
if ( typeof doorMaterial == 'undefined' ) {
|
if ( typeof doorMaterial == 'undefined' ) {
|
||||||
doorMaterial = 64;
|
doorMaterial = 64;
|
||||||
} else {
|
|
||||||
doorMaterial = 71;
|
|
||||||
}
|
}
|
||||||
this
|
this
|
||||||
.cuboidX( doorMaterial, this.dir ).up( )
|
.door( doorMaterial, 'left')
|
||||||
.cuboidX( doorMaterial, 8 ).right( )
|
.right()
|
||||||
.cuboidX( doorMaterial, 9 ).down( )
|
.door( doorMaterial, 'right')
|
||||||
.cuboidX( doorMaterial, this.dir ).left( );
|
.left();
|
||||||
} );
|
} );
|
||||||
Drone.extend( function door2_iron( ) {
|
Drone.extend( function door2_iron( ) {
|
||||||
this
|
this.door2( 71 );
|
||||||
.cuboidX( 71, this.dir ).up( )
|
|
||||||
.cuboidX( 71, 8 ).right( )
|
|
||||||
.cuboidX( 71, 9 ).down( )
|
|
||||||
.cuboidX( 71, this.dir ).left( );
|
|
||||||
} );
|
} );
|
||||||
|
|
||||||
// player dirs: 0 = east, 1 = south, 2 = west, 3 = north
|
// player dirs: 0 = east, 1 = south, 2 = west, 3 = north
|
||||||
|
@ -1239,42 +1244,18 @@ Drone.extend(stairs);
|
||||||
function prism( block, w, d ) {
|
function prism( block, w, d ) {
|
||||||
var stairEquiv = _STAIRBLOCKS[block];
|
var stairEquiv = _STAIRBLOCKS[block];
|
||||||
if ( stairEquiv ) {
|
if ( stairEquiv ) {
|
||||||
this.fwd( ).prism(stairEquiv,w,d-2 ).back( );
|
this
|
||||||
var d2 = 0;
|
.fwd()
|
||||||
var middle = Math.floor( d/2 );
|
.prism( stairEquiv,w,d-2 )
|
||||||
var uc = 0,dc = 0;
|
.back()
|
||||||
while ( d2 < d ) {
|
.stairs(block, w, d / 2)
|
||||||
var di = (d2 < middle?this.dir:(this.dir+2 )%4 );
|
.fwd(d - 1)
|
||||||
var bd = block + ':' + Drone.PLAYER_STAIRS_FACING[di];
|
.right(w - 1)
|
||||||
var putStep = true;
|
.turn(2)
|
||||||
if ( d2 == middle ) {
|
.stairs(block, w, d / 2)
|
||||||
if ( d % 2 == 1 ) {
|
.turn(2)
|
||||||
putStep = false;
|
.left(w - 1)
|
||||||
}
|
.back(d - 1);
|
||||||
}
|
|
||||||
if ( putStep ) {
|
|
||||||
this.cuboid(bd,w );
|
|
||||||
}
|
|
||||||
if ( d2 < middle-1 ) {
|
|
||||||
this.up( );
|
|
||||||
uc++;
|
|
||||||
}
|
|
||||||
var modulo = d % 2;
|
|
||||||
if ( modulo == 1 ) {
|
|
||||||
if ( d2 > middle && d2<d-1) {
|
|
||||||
this.down( );
|
|
||||||
dc++;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
if ( d2 >= middle && d2<d-1 ) {
|
|
||||||
this.down( );
|
|
||||||
dc++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.fwd( );
|
|
||||||
d2++;
|
|
||||||
}
|
|
||||||
this.back(d );
|
|
||||||
}else{
|
}else{
|
||||||
var c = 0;
|
var c = 0;
|
||||||
var d2 = d;
|
var d2 = d;
|
||||||
|
@ -1291,19 +1272,7 @@ function prism( block, w, d ) {
|
||||||
//
|
//
|
||||||
// prism0 private implementation
|
// prism0 private implementation
|
||||||
//
|
//
|
||||||
;
|
function prism0( block,w,d ) {
|
||||||
Drone.extend( function prism0( block,w,d ) {
|
|
||||||
/* this.prism(block,w,d )
|
|
||||||
.fwd( ).right( )
|
|
||||||
.prism(0,w-2,d-2 )
|
|
||||||
.left( ).back( );
|
|
||||||
var se = _STAIRBLOCKS[block];
|
|
||||||
if ( d % 2 == 1 && se ) {
|
|
||||||
// top of roof will be open - need repair
|
|
||||||
var f = Math.floor(d/2 );
|
|
||||||
this.fwd(f ).up(f ).cuboid(se,w ).down(f ).back(f );
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
this
|
this
|
||||||
.stairs(block,w,d/2)
|
.stairs(block,w,d/2)
|
||||||
.fwd(d-1)
|
.fwd(d-1)
|
||||||
|
@ -1324,7 +1293,8 @@ Drone.extend( function prism0( block,w,d ) {
|
||||||
.left(w-1)
|
.left(w-1)
|
||||||
.back();
|
.back();
|
||||||
}
|
}
|
||||||
} );
|
}
|
||||||
|
Drone.extend(prism0);
|
||||||
Drone.extend(prism);
|
Drone.extend(prism);
|
||||||
Drone.extend('box', Drone.prototype.cuboid );
|
Drone.extend('box', Drone.prototype.cuboid );
|
||||||
Drone.extend('box0',Drone.prototype.cuboid0 );
|
Drone.extend('box0',Drone.prototype.cuboid0 );
|
||||||
|
|
Reference in a new issue