mirror of
https://github.com/danbulant/flying-squid
synced 2026-06-18 22:11:07 +00:00
Make effects ends, screw player abilities
This commit is contained in:
parent
0adfc20a1f
commit
7d062ad169
2 changed files with 14 additions and 7 deletions
9
src/lib/plugins/effects.js
vendored
9
src/lib/plugins/effects.js
vendored
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
});
|
||||
});*/
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue