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/bed.js
2015-01-01 12:53:11 +00:00

54 lines
1.2 KiB
JavaScript

'use strict';
/*global require, Packages*/
var Drone = require('./drone').Drone,
blocks = require('blocks');
/************************************************************************
### Drone.bed() method
Creates a bed. The foot of the bed will be at the drone's location and
the head of the bed will extend away from the drone.
#### Example
To create a bed at the in-game prompt, look at a block then type:
```javascript
/js bed()
```
Like most Drone methods, this returns the drone so it can be chained like so:
```javascript
this
.fwd(3)
.bed()
.back(3)
```
***/
var bedDirections = {
0:3, // east
1:0, // south
2:1, // west
3:2 // north
};
function bed(){
this.then(function(){
var foot = this.setBlock(blocks.bed, bedDirections[this.dir], 0,0,0, false);
var head = this.setBlock(blocks.bed, bedDirections[this.dir] + 8, 0,0,1, false);
if (Drone.bountiful){
var prop = require('blockhelper').property;
var BedHalf = Packages.net.canarymod.api.world.blocks.properties.BlockPropertyEnums.BedHalf;
prop(foot)
.set('facing',this.dir)
.set('part', BedHalf.FOOT);
prop(head)
.set('facing',this.dir)
.set('part', BedHalf.HEAD);
}
foot.update();
head.update();
});
}
Drone.extend( bed );