Trying to fix sound, no success so far

This commit is contained in:
DemiPixel 2015-11-22 19:31:00 -08:00
parent 93ab42152c
commit de59be23ad
4 changed files with 22 additions and 26 deletions

View file

@ -639,7 +639,7 @@ Cancelled: Nothing
#### "command" #### "command"
Emitted when player starts their message with a slash Emitted when player starts their message with a slash
- message: Their commands (includes the slash) - command: Their commands (excludes the slash)
Default: Handle command by command system Default: Handle command by command system

View file

@ -12,9 +12,8 @@ module.exports.player=function(player,serv)
player._client.on('chat', ({message} = {}) => { player._client.on('chat', ({message} = {}) => {
if(message[0]=="/") { if(message[0]=="/") {
player.behavior('command', { player.behavior('command', {
command: message command: message.slice(1)
}, ({message}) => { }, ({command}) => {
var command = message.slice(1);
player.handleCommand(command); player.handleCommand(command);
}); });
} }

View file

@ -15,28 +15,28 @@ module.exports.player=function(player,serv)
if(currentlyDugBlock.type==0) return; if(currentlyDugBlock.type==0) return;
if(status==0 && player.gameMode!=1) if(status==0 && player.gameMode!=1)
player.behavior('dig', { // Start dig survival player.behavior('dig', { // Start dig survival
position: position, position: pos,
block: block block: block
}, ({position}) => { }, ({position}) => {
return startDigmehging(position); return startDigmehging(position);
}, cancelDig); }, cancelDig);
else if(status==2) else if(status==2)
player.behavior('dug', { // Finish dig survival player.behavior('dug', { // Finish dig survival
position: position, position: pos,
block: block block: block
}, ({position}) => { }, ({position}) => {
return completeDigging(position); return completeDigging(position);
}, cancelDig); }, cancelDig);
else if(status==1) else if(status==1)
player.behavior('cancelDig', { // Cancel dig survival player.behavior('cancelDig', { // Cancel dig survival
position: position, position: pos,
block: block block: block
}, ({position}) => { }, ({position}) => {
return cancelDigging(position); return cancelDigging(position);
}); });
else if(status==0 && player.gameMode==1) else if(status==0 && player.gameMode==1)
player.behavior('dug', { // Start/finish dig creative player.behavior('dug', { // Start/finish dig creative
position: position, position: pos,
block: block block: block
}, ({position}) => { }, ({position}) => {
return creativeDigging(position); return creativeDigging(position);

View file

@ -40,31 +40,28 @@ module.exports.player=function(player,serv) {
serv.playSound(sound, player.world, null, opt); serv.playSound(sound, player.world, null, opt);
}; };
player._client.on('placeBlock_cancel', ({location}={}, cancel) => { player.on('placeBlock_cancel', async ({position, reference}, cancel) => {
if (player.crouching) return; if (player.crouching) return;
var pos=new Vec3(location.x,location.y,location.z); var id = await player.world.getBlockType(reference);
player.world.getBlockType(pos).then((id) => { if (id != 25) return;
if (id != 25) return; cancel(false);
cancel(); if (!player.world.blockEntityData[reference.toString()]) player.world.blockEntityData[reference.toString()] = {};
if (!player.world.blockEntityData[pos.toString()]) player.world.blockEntityData[pos.toString()] = {}; var data = player.world.blockEntityData[reference.toString()];
var data = player.world.blockEntityData[pos.toString()]; if (typeof data.note == 'undefined') data.note = -1;
if (typeof data.note == 'undefined') data.note = -1; data.note++;
data.note++; data.note %= 25;
data.note %= 25; serv.playNoteBlock(data.note, player.world, reference);
serv.playNoteBlock(data.note, player.world, pos);
}).catch((err)=> setTimeout(() => {throw err;},0));
}); });
player._client.on('dig_cancel', ({location,status} = {}, cancel) => { player.on('dig_cancel', async ({position, reference}, cancel) => {
if (status != 0 || player.gameMode == 1) return; if (status != 0 || player.gameMode == 1) return;
var pos=new Vec3(location.x,location.y,location.z); return player.world.getBlockType(reference).then((id) => {
player.world.getBlockType(pos).then((id) => {
if (id != 25) return; if (id != 25) return;
cancel(); cancel();
if (!player.world.blockEntityData[pos.toString()]) player.world.blockEntityData[pos.toString()] = {}; if (!player.world.blockEntityData[reference.toString()]) player.world.blockEntityData[reference.toString()] = {};
var data = player.world.blockEntityData[pos.toString()]; var data = player.world.blockEntityData[reference.toString()];
if (typeof data.note == 'undefined') data.note = 0; if (typeof data.note == 'undefined') data.note = 0;
serv.playNoteBlock(data.not,player.world, pos, data.note); serv.playNoteBlock(data.not,player.world, reference, data.note);
}).catch((err)=> setTimeout(() => {throw err;},0)); }).catch((err)=> setTimeout(() => {throw err;},0));
}); });