mirror of
https://github.com/danbulant/flying-squid
synced 2026-07-06 03:31:10 +00:00
Trying to fix sound, no success so far
This commit is contained in:
parent
93ab42152c
commit
de59be23ad
4 changed files with 22 additions and 26 deletions
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -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));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue