added blocks.bonemeal and named some functions in drone.

This commit is contained in:
walterhiggins 2014-12-23 15:56:38 +00:00
parent bba65fdfca
commit 287ad49d7b
2 changed files with 35 additions and 25 deletions

View file

@ -234,7 +234,8 @@ var blocks = {
hardened_clay: 172, hardened_clay: 172,
coal_block: 173, coal_block: 173,
packed_ice: 174, packed_ice: 174,
double_plant: 175 double_plant: 175,
bonemeal: '351:15'
}; };
// Add all available colors to colorized block collections // Add all available colors to colorized block collections

View file

@ -1,3 +1,4 @@
/*global __plugin, require, org, setTimeout, addUnloadHandler, exports, global*/
var utils = require('utils'), var utils = require('utils'),
blocks = require('blocks'), blocks = require('blocks'),
bkLocation = org.bukkit.Location, bkLocation = org.bukkit.Location,
@ -570,7 +571,7 @@ Used when placing torches so that they face towards the drone.
// There is no need to read any further unless you want to understand how the Drone object works. // There is no need to read any further unless you want to understand how the Drone object works.
// //
var putBlock = function( x, y, z, blockId, metadata, world ) { function putBlock( x, y, z, blockId, metadata, world ) {
if ( typeof metadata == 'undefined' ) { if ( typeof metadata == 'undefined' ) {
metadata = 0; metadata = 0;
} }
@ -580,15 +581,17 @@ var putBlock = function( x, y, z, blockId, metadata, world ) {
block.typeId = blockId; block.typeId = blockId;
block.data = metadata; block.data = metadata;
block.update(); block.update();
return;
} }
if (__plugin.bukkit) { if (__plugin.bukkit) {
block.setTypeIdAndData( blockId, metadata, false ); block.setTypeIdAndData( blockId, metadata, false );
block.data = metadata; block.data = metadata;
return;
} }
} }
}; };
var putSign = function( drone, x, y, z, world, texts, blockId, meta, immediate ) { function putSign( drone, x, y, z, world, texts, blockId, meta, immediate ) {
var i, var i,
block, block,
state; state;
@ -629,7 +632,7 @@ var putSign = function( drone, x, y, z, world, texts, blockId, meta, immediate )
} }
}; };
var Drone = function( x, y, z, dir, world ) { function Drone( x, y, z, dir, world ) {
this.record = false; this.record = false;
var usePlayerCoords = false; var usePlayerCoords = false;
var player = (typeof self !== 'undefined' ? self : null); var player = (typeof self !== 'undefined' ? self : null);
@ -722,7 +725,6 @@ Drone.processQueue = function(){
if (process.name){ if (process.name){
console.log('while processing function ' + process.name); console.log('while processing function ' + process.name);
} }
} }
} }
} }
@ -1633,7 +1635,7 @@ var _getDirFromRotation = function( location ) {
if ( r > 315 || r < 45 ) if ( r > 315 || r < 45 )
return 1; // south return 1; // south
}; };
var _getBlockIdAndMeta = function( b ) { function _getBlockIdAndMeta( b ) {
var defaultMeta = 0, var defaultMeta = 0,
i = 0, i = 0,
bs, bs,
@ -1770,7 +1772,7 @@ var _copy = function( name, w, h, d ) {
} ); } );
Drone.clipBoard[name] = {dir: this.dir, blocks: ccContent}; Drone.clipBoard[name] = {dir: this.dir, blocks: ccContent};
}; };
var _garden = function( width, depth ) { function _garden( width, depth ) {
if ( typeof width == 'undefined' ) { if ( typeof width == 'undefined' ) {
width = 10; width = 10;
} }
@ -1796,9 +1798,9 @@ var _garden = function( width, depth ) {
dist[air] = 1; dist[air] = 1;
return this.rand( dist, width, 1, depth, false /* don't overwrite */ ); return this.rand( dist, width, 1, depth, false /* don't overwrite */ );
}; }
var _rand = function( blockDistribution ) { function _rand( blockDistribution ) {
if ( !(blockDistribution.constructor == Array ) ) { if ( !(blockDistribution.constructor == Array ) ) {
var a = []; var a = [];
for ( var p in blockDistribution ) { for ( var p in blockDistribution ) {
@ -1815,9 +1817,9 @@ var _rand = function( blockDistribution ) {
} }
fisherYates(blockDistribution ); fisherYates(blockDistribution );
return blockDistribution; return blockDistribution;
}; }
Drone.extend( 'rand', function( dist, width, height, depth, overwrite ) { Drone.extend( function rand( dist, width, height, depth, overwrite ) {
if ( typeof overwrite == 'undefined' ) { if ( typeof overwrite == 'undefined' ) {
overwrite = true; overwrite = true;
} }
@ -1831,21 +1833,28 @@ var _trees = {
jungle: bkTreeType.JUNGLE, jungle: bkTreeType.JUNGLE,
spruce: bkTreeType.REDWOOD spruce: bkTreeType.REDWOOD
}; };
for ( var p in _trees ) { function bukkitTreeFactory( k, v ) {
Drone.extend(p, function( v ) { return function( ) {
return function( ) { var block = this.world.getBlockAt(this.x,this.y,this.z );
var block = this.world.getBlockAt(this.x,this.y,this.z ); if ( block.typeId == 2 ) {
if ( block.typeId == 2 ) { this.up( );
this.up( ); }
} var treeLoc = this.getLocation();
var treeLoc = new bkLocation(this.world,this.x,this.y,this.z ); var successful = treeLoc.world.generateTree(treeLoc,v );
var successful = treeLoc.world.generateTree(treeLoc,v ); if ( block.typeId == 2 ) {
if ( block.typeId == 2 ) { this.down( );
this.down( ); }
} };
};
}(_trees[p] ) );
} }
function canaryTreeFactory( k, v ){
return function(){
console.log(k + ' not yet implemented.');
};
}
for ( var p in _trees ) {
Drone.extend(p, (__plugin.canary? canaryTreeFactory : bukkitTreeFactory) ( p, _trees[p] ) );
}
Drone.clone = function(origin) { Drone.clone = function(origin) {
var result = {x: origin.x, y: origin.y, z: origin.z, world: origin.world, dir: origin.dir}; var result = {x: origin.x, y: origin.y, z: origin.z, world: origin.world, dir: origin.dir};
return result; return result;