This repository has been archived on 2021-07-14. You can view files and clone it, but cannot push or open issues or pull requests.
scriptcraft/src/main/js/plugins/drone/contrib/hangtorch.js

45 lines
876 B
JavaScript

'use strict';
/*global require, __plugin, org*/
var Drone = require('drone'),
bkMaterial = org.bukkit.Material,
blocks = require('blocks');
function canHang( block ) {
if (__plugin.bukkit){
if ( block.type.equals(bkMaterial.AIR) ||
block.type.equals(bkMaterial.VINE) ) {
return true;
}
}
if (__plugin.canary){
if (block.typeId == blocks.air ||
block.typeid == blocks.vines ) {
return true;
}
}
return false;
}
function hangtorch() {
var torch = blocks.torch + ':' + Drone.PLAYER_TORCH_FACING[this.dir];
var moves = 0;
var block = this.getBlock();
while ( !canHang(block) ){
moves++;
this.back();
if (moves == 10){
this
.fwd(moves);
console.log('nowhere to hang torch');
return;
}
block = this.getBlock();
}
this
.box(torch)
.fwd(moves);
}
Drone.extend(hangtorch);