No more crashes, update API, add more stuff

This commit is contained in:
DemiPixel 2015-11-23 16:27:35 -08:00
parent 6a9281c195
commit 0355195cd9
3 changed files with 19 additions and 10 deletions

View file

@ -109,6 +109,7 @@
- ["dig"](#dig)
- ["dug"](#dug)
- ["cancelDig"](#canceldig)
- ["breakAnimation"](#breakanimation)
- ["placeBlock"](#placeblock)
- ["attack"](#attack)
- ["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)
- blockDropId: ID 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

View file

@ -21,7 +21,7 @@ module.exports.player=function(player,serv)
return startDigging(position);
}, cancelDig);
else if(status==2)
completeDigging(position);
completeDigging(pos);
else if(status==1)
player.behavior('cancelDig', { // Cancel dig survival
position: pos,
@ -30,7 +30,7 @@ module.exports.player=function(player,serv)
return cancelDigging(position);
});
else if(status==0 && player.gameMode==1)
return creativeDigging(position);
return creativeDigging(pos);
})
.catch((err)=> setTimeout(() => {throw err;},0))
});
@ -104,7 +104,9 @@ module.exports.player=function(player,serv)
blockDropWorld: player.world,
blockDropVelocity: new Vec3(Math.random()*4 - 2, Math.random()*2 + 2, Math.random()*4 - 2),
blockDropId: currentlyDugBlock.type,
blockDropDamage: currentlyDugBlock.metadata
blockDropDamage: currentlyDugBlock.metadata,
blockDropPickup: 500,
blockDropDeath: 60*5*1000
}, (data) => {
player.changeBlock(data.position,0,0);
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, {
velocity: blockDropVelocity,
itemId: blockDropId,
itemDamage: blockDropDamage
itemDamage: blockDropDamage,
pickupTime: blockDropPickup,
deathTime: blockDropDeath
});
}
@ -133,12 +137,14 @@ module.exports.player=function(player,serv)
player.behavior('dug', {
position: location,
block: currentlyDugBlock,
dropBlock: true,
dropBlock: false,
blockDropPosition: location.offset(0.5, 0.5, 0.5),
blockDropWorld: player.world,
blockDropVelocity: new Vec3(Math.random()*4 - 2, Math.random()*2 + 2, Math.random()*4 - 2),
blockDropId: currentlyDugBlock.type,
blockDropDamage: currentlyDugBlock.metadata
blockDropDamage: currentlyDugBlock.metadata,
blockDropPickup: 500,
blockDropDeath: 60*5*1000
}, (data) => {
player.changeBlock(data.position,0,0);
if (data.dropBlock) dropBlock(data);

View file

@ -25,7 +25,7 @@ module.exports.server=function(serv,options) {
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());
object.data = data;
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.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.deathTime = 60*1000; // 60 seconds
object.pickupTime = 200;
object.deathTime = deathTime;
object.pickupTime = pickupTime;
object.itemId = itemId;
object.itemDamage = itemDamage;