Advertisement
peacestorm

Add random effect

Apr 16th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. Array.prototype.getRandomElement = function() {
  2. return this[Math.floor(Math.random() * this.length)];
  3. }
  4.  
  5. const effects = [MobEffect.jump, MobEffect.blindness, MobEffect.regeneration, MobEffect.nightVision];
  6. const minDur = 10;
  7. const maxDur = 9999;
  8.  
  9. function useItem(x, y, z, itemId, blockId, side, itemDamage, blockDamage) {
  10. if (itemId==280) {
  11. const randomDuration = Math.floor(Math.random() * (maxDur - minDur + 1)) + minDur;
  12. const randomEffect = effects.getRandomElement();
  13. Entity.addEffect(getPlayerEnt(), randomEffect, randomDuration*20, 3);
  14. }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement