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"
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

View file

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

View file

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

View file

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