mirror of
https://github.com/danbulant/flying-squid
synced 2026-07-04 10:40:42 +00:00
Add cool sounds, remove some debugging
This commit is contained in:
parent
0684ff481f
commit
cc072e2464
2 changed files with 16 additions and 9 deletions
|
|
@ -1,5 +1,16 @@
|
||||||
|
var blocks=require("minecraft-data")(require("../version")).blocks;
|
||||||
var vec3 = require("vec3");
|
var vec3 = require("vec3");
|
||||||
|
|
||||||
|
var materialToSound = {
|
||||||
|
undefined: 'stone',
|
||||||
|
'rock': 'stone',
|
||||||
|
'dirt': 'grass',
|
||||||
|
'plant': 'grass',
|
||||||
|
'wool': 'cloth',
|
||||||
|
'web': 'cloth',
|
||||||
|
'wood': 'wood'
|
||||||
|
}
|
||||||
|
|
||||||
module.exports=inject;
|
module.exports=inject;
|
||||||
|
|
||||||
function inject(serv,player)
|
function inject(serv,player)
|
||||||
|
|
@ -11,7 +22,10 @@ function inject(serv,player)
|
||||||
var placedPosition=referencePosition.plus(directionVector);
|
var placedPosition=referencePosition.plus(directionVector);
|
||||||
player.world.getBlockType(referencePosition).then((id) => {
|
player.world.getBlockType(referencePosition).then((id) => {
|
||||||
if([25].indexOf(id) != -1) return;
|
if([25].indexOf(id) != -1) return;
|
||||||
serv.playSound('random.click', player.world, placedPosition.clone().add(vec3(0.5, 0.5, 0.5)));
|
var sound = 'dig.' + (materialToSound[blocks[heldItem.blockId].material] || 'stone');
|
||||||
|
serv.playSound(sound, player.world, placedPosition.clone().add(vec3(0.5, 0.5, 0.5)), {
|
||||||
|
pitch: 0.8
|
||||||
|
});
|
||||||
if(heldItem.blockId!=323){
|
if(heldItem.blockId!=323){
|
||||||
player.changeBlock(placedPosition,heldItem.blockId,heldItem.itemDamage);
|
player.changeBlock(placedPosition,heldItem.blockId,heldItem.itemDamage);
|
||||||
}else if(direction==1){
|
}else if(direction==1){
|
||||||
|
|
|
||||||
|
|
@ -44,9 +44,6 @@ function inject(serv) {
|
||||||
var yVec = entity.position.offset(0, entity.velocity.y*delta + sizeSigned.y/2, 0).scaled(1/32).floored();
|
var yVec = entity.position.offset(0, entity.velocity.y*delta + sizeSigned.y/2, 0).scaled(1/32).floored();
|
||||||
var zVec = entity.position.offset(0, 0, entity.velocity.z*delta + sizeSigned.z/2).scaled(1/32).floored();
|
var zVec = entity.position.offset(0, 0, entity.velocity.z*delta + sizeSigned.z/2).scaled(1/32).floored();
|
||||||
|
|
||||||
//console.log(xVec, yVec, zVec);
|
|
||||||
//console.log(entity.velocity);
|
|
||||||
|
|
||||||
// Get block for each (x/y/z)Vec, check to avoid duplicate getBlockTypes
|
// Get block for each (x/y/z)Vec, check to avoid duplicate getBlockTypes
|
||||||
var xBlock = blocks[await entity.world.getBlockType(xVec)].boundingBox == 'block';
|
var xBlock = blocks[await entity.world.getBlockType(xVec)].boundingBox == 'block';
|
||||||
var yBlock = yVec.equals(xVec) ? xBlock : blocks[await entity.world.getBlockType(yVec)].boundingBox == 'block';
|
var yBlock = yVec.equals(xVec) ? xBlock : blocks[await entity.world.getBlockType(yVec)].boundingBox == 'block';
|
||||||
|
|
@ -59,17 +56,13 @@ function inject(serv) {
|
||||||
entity.velocity.z = getFriction(entity.velocity.x, entity.friction.x, delta);
|
entity.velocity.z = getFriction(entity.velocity.x, entity.friction.x, delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
//console.log('afterfric',entity.velocity);
|
|
||||||
|
|
||||||
var oldPos = entity.position.clone();
|
var oldPos = entity.position.clone();
|
||||||
|
|
||||||
entity.position.x += getMoveAmount('x', xBlock, entity, delta, sizeSigned.x);
|
entity.position.x += getMoveAmount('x', xBlock, entity, delta, sizeSigned.x);
|
||||||
entity.position.y += getMoveAmount('y', yBlock, entity, delta, sizeSigned.y);
|
entity.position.y += getMoveAmount('y', yBlock, entity, delta, sizeSigned.y);
|
||||||
entity.position.z += getMoveAmount('z', zBlock, entity, delta, sizeSigned.z);
|
entity.position.z += getMoveAmount('z', zBlock, entity, delta, sizeSigned.z);
|
||||||
|
|
||||||
//console.log(entity.position, old);
|
//serv.emitParticle(30, serv.overworld, entity.position.scaled(1/32), { size: vec3(0, 0, 0) });
|
||||||
|
|
||||||
serv.emitParticle(30, serv.overworld, entity.position.scaled(1/32), { size: vec3(0, 0, 0) });
|
|
||||||
return { oldPos: oldPos, onGround: yBlock}
|
return { oldPos: oldPos, onGround: yBlock}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue