A javascript library spawns commands for Command-Block of Minecraft.
The aim of the library is to simplify Minecraft Map Makers' work. However, it just a javascript library, that is to say, coding before using.
I hope that someone can use this library to make a web app, providing GUI features for map makers.
$ npm install
Concepts:
- Item
- TargetSelector
- Coordinate
- Player
Commands:
- give
- tell / msg / w
- say
- spawnpoint
Generally, every API provides a toString() method to get a plain string.
TargetSelector
A target selector variable identifies the broad category of targets to select. see HERE.
To create a TargetSelector and then get string, you can:
const {TargetSelector} = require('./src/concepts');
const ts = new TargetSelector('p');
ts.toString(); // '@p'
more complex example:
const ts = new TargetSelector('a', {
coordinate: [100, undefined, 300],
count: 3,
team: 'red'
});
ts.toString(); // '@a[x=100,z=300,c=3,team=red]'
Item
which can be found at: http://minecraft.gamepedia.com/Data_values#Item_IDs
To create an item:
const {
Item
} = require('../src/concepts');
const item = new Item('bow');
item.toString(); // 'minecraft:bow'
Player
You can use a plain string or a TargetSelector to create a player:
const {
Player,
TargetSelector
} = require('../src/concepts');
const playerMike = new Player('Mike');
const playerClosest = new Player(
new TargetSelector('p')
);
Say Command
http://minecraft.gamepedia.com/Commands#say
const {Say} = require(./src/commands);
const say = new Say('Hi everybody!');
say.toString(); // '/say Hi everybody'
Tell Command
http://minecraft.gamepedia.com/Commands#tell
const {Tell} = require('.src/commands');
const tell = new Tell(new Player('Mike'), 'Hi Mike');
tell.toString(); // '/tell Mike Hi Mike'
Give Command
http://minecraft.gamepedia.com/Commands#give
Gives an item to a player.
To give 64 apples to Mike:
const {
Item,
Player
} = require('../src/concepts');
const {Give} = require(./src/commands);
const give = new Give(
new Player('Mike'),
new Item('apple'),
64,
1,
{display: {Lore: ["Apple here"]}}
);
give.toString(); // '/give Mike minecraft:apple 64 1 {display:{Lore:["Apple here"]}}'
Some other commands are not listed above, I will put them in the specific document.
You should build before test:
$ npm babel
I use mocha to do tests, start a new terminal and simply run:
$ npm test
All documentation resides here:
The project just getting started, and I think it will become very huge. I just try to make a simple Framework.
For a long period to come, I will fill in the framework with a lot of data and simple logic. I finished a little data as well as logic at present, and I really need your help.
I'll be glad if you send me some PullRequests :)
MIT