mirror of
https://github.com/danbulant/flying-squid
synced 2026-07-06 03:31:10 +00:00
No more crashes, update API, add more stuff
This commit is contained in:
parent
6a9281c195
commit
0355195cd9
3 changed files with 19 additions and 10 deletions
|
|
@ -109,6 +109,7 @@
|
||||||
- ["dig"](#dig)
|
- ["dig"](#dig)
|
||||||
- ["dug"](#dug)
|
- ["dug"](#dug)
|
||||||
- ["cancelDig"](#canceldig)
|
- ["cancelDig"](#canceldig)
|
||||||
|
- ["breakAnimation"](#breakanimation)
|
||||||
- ["placeBlock"](#placeblock)
|
- ["placeBlock"](#placeblock)
|
||||||
- ["attack"](#attack)
|
- ["attack"](#attack)
|
||||||
- ["requestRespawn"](#requestrespawn)
|
- ["requestRespawn"](#requestrespawn)
|
||||||
|
|
@ -696,6 +697,8 @@ Emitted when a player finishes digging something (or a player in creative breaks
|
||||||
- blockDropVelocity: The velocity the block has when dropped (Default: random)
|
- blockDropVelocity: The velocity the block has when dropped (Default: random)
|
||||||
- blockDropId: ID of the block dropped
|
- blockDropId: ID of the block dropped
|
||||||
- blockDropDamage: Damage of the block dropped
|
- blockDropDamage: Damage of the block dropped
|
||||||
|
- blockDropPickup: Time before user can pick up the block (Default: 0.5 seconds)
|
||||||
|
- blockDropDeath: Time before item despawns (Default: 5 minutes)
|
||||||
|
|
||||||
Default: Save new block as air, sends to all nearby players
|
Default: Save new block as air, sends to all nearby players
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ module.exports.player=function(player,serv)
|
||||||
return startDigging(position);
|
return startDigging(position);
|
||||||
}, cancelDig);
|
}, cancelDig);
|
||||||
else if(status==2)
|
else if(status==2)
|
||||||
completeDigging(position);
|
completeDigging(pos);
|
||||||
else if(status==1)
|
else if(status==1)
|
||||||
player.behavior('cancelDig', { // Cancel dig survival
|
player.behavior('cancelDig', { // Cancel dig survival
|
||||||
position: pos,
|
position: pos,
|
||||||
|
|
@ -30,7 +30,7 @@ module.exports.player=function(player,serv)
|
||||||
return cancelDigging(position);
|
return cancelDigging(position);
|
||||||
});
|
});
|
||||||
else if(status==0 && player.gameMode==1)
|
else if(status==0 && player.gameMode==1)
|
||||||
return creativeDigging(position);
|
return creativeDigging(pos);
|
||||||
})
|
})
|
||||||
.catch((err)=> setTimeout(() => {throw err;},0))
|
.catch((err)=> setTimeout(() => {throw err;},0))
|
||||||
});
|
});
|
||||||
|
|
@ -104,7 +104,9 @@ module.exports.player=function(player,serv)
|
||||||
blockDropWorld: player.world,
|
blockDropWorld: player.world,
|
||||||
blockDropVelocity: new Vec3(Math.random()*4 - 2, Math.random()*2 + 2, Math.random()*4 - 2),
|
blockDropVelocity: new Vec3(Math.random()*4 - 2, Math.random()*2 + 2, Math.random()*4 - 2),
|
||||||
blockDropId: currentlyDugBlock.type,
|
blockDropId: currentlyDugBlock.type,
|
||||||
blockDropDamage: currentlyDugBlock.metadata
|
blockDropDamage: currentlyDugBlock.metadata,
|
||||||
|
blockDropPickup: 500,
|
||||||
|
blockDropDeath: 60*5*1000
|
||||||
}, (data) => {
|
}, (data) => {
|
||||||
player.changeBlock(data.position,0,0);
|
player.changeBlock(data.position,0,0);
|
||||||
if (data.dropBlock) dropBlock(data);
|
if (data.dropBlock) dropBlock(data);
|
||||||
|
|
@ -119,11 +121,13 @@ module.exports.player=function(player,serv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function dropBlock({blockDropPosition, blockDropWorld, blockDropVelocity, blockDropId, blockDropDamage}) {
|
function dropBlock({blockDropPosition, blockDropWorld, blockDropVelocity, blockDropId, blockDropDamage, blockDropPickup, blockDropDeath}) {
|
||||||
serv.spawnObject(2, blockDropWorld, blockDropPosition, {
|
serv.spawnObject(2, blockDropWorld, blockDropPosition, {
|
||||||
velocity: blockDropVelocity,
|
velocity: blockDropVelocity,
|
||||||
itemId: blockDropId,
|
itemId: blockDropId,
|
||||||
itemDamage: blockDropDamage
|
itemDamage: blockDropDamage,
|
||||||
|
pickupTime: blockDropPickup,
|
||||||
|
deathTime: blockDropDeath
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -133,12 +137,14 @@ module.exports.player=function(player,serv)
|
||||||
player.behavior('dug', {
|
player.behavior('dug', {
|
||||||
position: location,
|
position: location,
|
||||||
block: currentlyDugBlock,
|
block: currentlyDugBlock,
|
||||||
dropBlock: true,
|
dropBlock: false,
|
||||||
blockDropPosition: location.offset(0.5, 0.5, 0.5),
|
blockDropPosition: location.offset(0.5, 0.5, 0.5),
|
||||||
blockDropWorld: player.world,
|
blockDropWorld: player.world,
|
||||||
blockDropVelocity: new Vec3(Math.random()*4 - 2, Math.random()*2 + 2, Math.random()*4 - 2),
|
blockDropVelocity: new Vec3(Math.random()*4 - 2, Math.random()*2 + 2, Math.random()*4 - 2),
|
||||||
blockDropId: currentlyDugBlock.type,
|
blockDropId: currentlyDugBlock.type,
|
||||||
blockDropDamage: currentlyDugBlock.metadata
|
blockDropDamage: currentlyDugBlock.metadata,
|
||||||
|
blockDropPickup: 500,
|
||||||
|
blockDropDeath: 60*5*1000
|
||||||
}, (data) => {
|
}, (data) => {
|
||||||
player.changeBlock(data.position,0,0);
|
player.changeBlock(data.position,0,0);
|
||||||
if (data.dropBlock) dropBlock(data);
|
if (data.dropBlock) dropBlock(data);
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ module.exports.server=function(serv,options) {
|
||||||
return entity;
|
return entity;
|
||||||
};
|
};
|
||||||
|
|
||||||
serv.spawnObject = (type, world, position, {pitch=0,yaw=0,velocity=new Vec3(0,0,0),data=1,itemId,itemDamage=0}={}) => {
|
serv.spawnObject = (type, world, position, {pitch=0,yaw=0,velocity=new Vec3(0,0,0),data=1,itemId,itemDamage=0,pickupTime=500,deathTime=60*1000}={}) => {
|
||||||
var object = serv.initEntity('object', type, world, position.scaled(32).floored());
|
var object = serv.initEntity('object', type, world, position.scaled(32).floored());
|
||||||
object.data = data;
|
object.data = data;
|
||||||
object.velocity = velocity.scaled(32).floored();
|
object.velocity = velocity.scaled(32).floored();
|
||||||
|
|
@ -35,8 +35,8 @@ module.exports.server=function(serv,options) {
|
||||||
object.terminalvelocity = new Vec3(27*32, 27*32, 27*32);
|
object.terminalvelocity = new Vec3(27*32, 27*32, 27*32);
|
||||||
object.friction = new Vec3(15*32, 0, 15*32);
|
object.friction = new Vec3(15*32, 0, 15*32);
|
||||||
object.size = new Vec3(0.25*32, 0.25*32, 0.25*32); // Hardcoded, will be dependent on type!
|
object.size = new Vec3(0.25*32, 0.25*32, 0.25*32); // Hardcoded, will be dependent on type!
|
||||||
object.deathTime = 60*1000; // 60 seconds
|
object.deathTime = deathTime;
|
||||||
object.pickupTime = 200;
|
object.pickupTime = pickupTime;
|
||||||
object.itemId = itemId;
|
object.itemId = itemId;
|
||||||
object.itemDamage = itemDamage;
|
object.itemDamage = itemDamage;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue