mirror of
https://github.com/danbulant/flying-squid
synced 2026-07-05 03:00:46 +00:00
update fire placing/destroying, fix #171
This commit is contained in:
parent
0fd80dcb7c
commit
6b6a6764ae
3 changed files with 50 additions and 32 deletions
|
|
@ -7,32 +7,46 @@ module.exports.player=function(player,serv)
|
||||||
player.sendBlock(position, block.type, block.metadata);
|
player.sendBlock(position, block.type, block.metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
player._client.on("block_dig",({location,status} = {}) => {
|
player._client.on("block_dig",async ({location,status,face}) => {
|
||||||
var pos=new Vec3(location.x,location.y,location.z);
|
var pos=new Vec3(location.x,location.y,location.z);
|
||||||
player.world.getBlock(pos)
|
|
||||||
.then(block => {
|
var directionVector=directionToVector[face];
|
||||||
currentlyDugBlock=block;
|
var facedPos=pos.plus(directionVector);
|
||||||
if(currentlyDugBlock.type==0) return;
|
|
||||||
if(status==0 && player.gameMode!=1)
|
try {
|
||||||
player.behavior('dig', { // Start dig survival
|
let facedBlock = await player.world.getBlock(facedPos);
|
||||||
position: pos,
|
let block;
|
||||||
block: block
|
if(facedBlock.name=="fire")
|
||||||
}, ({position}) => {
|
{
|
||||||
return startDigging(position);
|
block=facedBlock;
|
||||||
}, cancelDig);
|
pos=facedPos;
|
||||||
else if(status==2)
|
}
|
||||||
completeDigging(pos);
|
else block=player.world.getBlock(pos);
|
||||||
else if(status==1)
|
|
||||||
player.behavior('cancelDig', { // Cancel dig survival
|
currentlyDugBlock = block;
|
||||||
position: pos,
|
if (currentlyDugBlock.type == 0) return;
|
||||||
block: block
|
if (status == 0 && player.gameMode != 1)
|
||||||
}, ({position}) => {
|
player.behavior('dig', { // Start dig survival
|
||||||
return cancelDigging(position);
|
position: pos,
|
||||||
});
|
block: block
|
||||||
else if(status==0 && player.gameMode==1)
|
}, ({position}) => {
|
||||||
return creativeDigging(pos);
|
return startDigging(position);
|
||||||
})
|
}, cancelDig);
|
||||||
.catch((err)=> setTimeout(() => {throw err;},0))
|
else if (status == 2)
|
||||||
|
completeDigging(pos);
|
||||||
|
else if (status == 1)
|
||||||
|
player.behavior('cancelDig', { // Cancel dig survival
|
||||||
|
position: pos,
|
||||||
|
block: block
|
||||||
|
}, ({position}) => {
|
||||||
|
return cancelDigging(position);
|
||||||
|
});
|
||||||
|
else if (status == 0 && player.gameMode == 1)
|
||||||
|
return creativeDigging(pos);
|
||||||
|
}
|
||||||
|
catch(err) {
|
||||||
|
setTimeout(() => {throw err;},0);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function diggingTime()
|
function diggingTime()
|
||||||
|
|
@ -160,3 +174,5 @@ module.exports.player=function(player,serv)
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var directionToVector=[new Vec3(0,-1,0),new Vec3(0,1,0),new Vec3(0,0,-1),new Vec3(0,0,1),new Vec3(-1,0,0),new Vec3(1,0,0)];
|
||||||
|
|
@ -3,17 +3,19 @@ var Vec3 = require("vec3").Vec3;
|
||||||
var UserError=require("flying-squid").UserError;
|
var UserError=require("flying-squid").UserError;
|
||||||
|
|
||||||
module.exports.player=function(player,serv) {
|
module.exports.player=function(player,serv) {
|
||||||
player.use_flint_and_steel=async (referencePosition,direction) => {
|
player.use_flint_and_steel=async (referencePosition,direction,position) => {
|
||||||
let block=await player.world.getBlock(referencePosition);
|
let block=await player.world.getBlock(referencePosition);
|
||||||
if(block.name=="obsidian")
|
if(block.name=="obsidian")
|
||||||
{
|
{
|
||||||
var frames=await detectFrame(player.world,referencePosition,direction);
|
var frames=await detectFrame(player.world,referencePosition,direction);
|
||||||
if(frames.length==0)
|
if(frames.length!=0) {
|
||||||
|
var air = frames[0].air;
|
||||||
|
air.forEach(pos => player.setBlock(pos, 90, (frames[0].bottom[0].x - frames[0].bottom[1].x) != 0 ? 1 : 2));
|
||||||
|
player.world.portals.push(frames[0]);
|
||||||
return;
|
return;
|
||||||
var air=frames[0].air;
|
}
|
||||||
air.forEach(pos => player.setBlock(pos,90,(frames[0].bottom[0].x-frames[0].bottom[1].x)!=0 ? 1 : 2));
|
|
||||||
player.world.portals.push(frames[0]);
|
|
||||||
}
|
}
|
||||||
|
player.changeBlock(position, 51, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
player.on("dug",({position,block}) => {
|
player.on("dug",({position,block}) => {
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ module.exports.player=function(player,serv)
|
||||||
|
|
||||||
var item= items[heldItem.blockId];
|
var item= items[heldItem.blockId];
|
||||||
if(item.name=="flint_and_steel")
|
if(item.name=="flint_and_steel")
|
||||||
player.use_flint_and_steel(referencePosition,directionVector);
|
player.use_flint_and_steel(referencePosition,directionVector,position);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
var directionToVector=[new Vec3(0,-1,0),new Vec3(0,1,0),new Vec3(0,0,-1),new Vec3(0,0,1),new Vec3(-1,0,0),new Vec3(1,0,0)];
|
var directionToVector=[new Vec3(0,-1,0),new Vec3(0,1,0),new Vec3(0,0,-1),new Vec3(0,0,1),new Vec3(-1,0,0),new Vec3(1,0,0)];
|
||||||
Loading…
Reference in a new issue