diff --git a/src/lib/plugins/effects.js b/src/lib/plugins/effects.js index ad35f0a..007a2da 100644 --- a/src/lib/plugins/effects.js +++ b/src/lib/plugins/effects.js @@ -16,7 +16,6 @@ module.exports.entity = function(entity, serv) { duration: duration, hideParticles: !particles }; - console.log(data); serv._writeArray('entity_effect', data, sendTo); }; @@ -36,6 +35,7 @@ module.exports.entity = function(entity, serv) { amplifier: opt.amplifier || 0, duration: opt.duration || 30*20, particles: opt.particles || true, + end: Date.now() + (opt.duration || 30*20)*1000/20 // 1000/20 == convert from ticks to milliseconds }; entity.sendEffect(effectId, opt); return true; @@ -46,6 +46,13 @@ module.exports.entity = function(entity, serv) { entity.effects[effectId] = null; entity.sendRemoveEffect(effectId, opt); }; + + serv.on('tick', () => { + Object.keys(entity.effects).forEach(effectId => { + var e = entity.effects[effectId]; + if (e && e.end <= Date.now()) entity.removeEffect(effectId); + }); + }); }; module.exports.player = function(player, serv) { diff --git a/src/lib/plugins/updatePositions.js b/src/lib/plugins/updatePositions.js index 686f4d0..10e04e5 100644 --- a/src/lib/plugins/updatePositions.js +++ b/src/lib/plugins/updatePositions.js @@ -68,20 +68,20 @@ module.exports.player=function(player) if (notCancelled) player.sendSelfPosition(); } - player.sendAbilities = () => { + player.sendAbilities = () => { // TODO: Fix all of this... var godmode = player.gameMode == 1 || player.gameMode == 3; var canFly = player.gameMode == 1 || player.gameMode == 3; var isFlying = !player.onGround && canFly; var creativeMode = player.gameMode == 1; var f = (+godmode*8) + (+canFly*4) + (+isFlying*2) + (+creativeMode*1); - var walkingSpeed = 4.3/20 * (1 + (player.effects[1] != null ? (player.effects[1].amplifier + 1) : 0) * 0.2) - var flyingSpeed = 1.0/20; - console.log(walkingSpeed, flyingSpeed); - player._client.write('abilities', { + var walkingSpeed = 0.2 * (1 + (player.effects[1] != null ? (player.effects[1].amplifier + 1) : 0) * 0.2) + var flyingSpeed = 0.1; + /*console.log(walkingSpeed, flyingSpeed); + player._client.write('abilities', { // FIIIIXXXXXXX flags: f, walkingSpeed: walkingSpeed, flyingSpeed: flyingSpeed - }); + });*/ } };