-
Notifications
You must be signed in to change notification settings - Fork 0
/
wool.js
29 lines (22 loc) · 906 Bytes
/
wool.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'use strict';
const ucfirst = require('ucfirst');
module.exports = (game, opts) => new WoolPlugin(game, opts);
class WoolPlugin {
constructor(game, opts) {
this.registry = game.plugins.get('voxel-registry');
if (!this.registry) throw new Error('voxel-wool requires voxel-registry plugin');
this.colors = ['black', 'blue', 'brown', 'cyan', 'gray', 'green', 'light_blue', 'lime', 'magenta', 'orange', 'pink', 'purple', 'red', 'silver', 'white', 'yellow']; // TODO: order?
this.enable();
}
enable() {
this.registry.registerBlocks('wool', this.colors.length, {
names: this.colors.map((color) => 'wool' + ucfirst(color)),
texture: (offset) => 'wool_colored_' + (this.colors[offset] || this.colors[0]),
displayName: (offset) => ucfirst(this.colors[offset]) + ' Wool',
creativeTab: 'decorative',
});
}
disable() {
// TODO: remove blocks
}
}