GenuineSounds

Speed Changing.

Jun 19th, 2012
194
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.13 KB | None | 0 0
  1. package net.minecraft.src;
  2.  
  3. import ltd.genuine.common.Tasks;
  4. import ltd.genuine.spell.template.Normal;
  5.  
  6. public class GenuineSpellSpeed extends Normal {
  7.  
  8.     private float speed1;
  9.  
  10.     private float speed2;
  11.  
  12.     private float speed3;
  13.  
  14.     private boolean ran = false;
  15.  
  16.     private EntityLiving spellTarget;
  17.  
  18.     public GenuineSpellSpeed(int level) {
  19.         super("Speed Boots", level, level + 5, 30, true, false);
  20.     }
  21.  
  22.     @Override
  23.     public String getDescription() {
  24.         return  "You're a long way from home.\n\n" +
  25.                 "Run at break-neck speeds. Go\n" +
  26.                 "anywhere you've ever wanted\n" +
  27.                 "to go in a flash\n\n" +
  28.                 "Lasts " + this.getRuntime() + " seconds.\n" + (20 * this.getLevel() + 100) + "% speeds.\n" +
  29.                 "Cooldown: " + Tasks.secondsToTimeString(this.getCooldown());
  30.     }
  31.  
  32.     @Override
  33.     public String getIcon() {
  34.         if (this.getLevel() > 8)
  35.             return "/genuine/spell/speed3.png";
  36.         if (this.getLevel() > 4)
  37.             return "/genuine/spell/speed2.png";
  38.         return "/genuine/spell/speed1.png";
  39.     }
  40.  
  41.     @Override
  42.     public void onCast(World world, EntityLiving source, EntityLiving target) {
  43.         spellTarget = target == null ? source : target;
  44.         this.ran = false;
  45.         if (spellTarget instanceof EntityPlayer) {
  46.             this.speed1 = ((EntityPlayer) spellTarget).speedOnGround;
  47.             this.speed2 = spellTarget.landMovementFactor;
  48.         } else
  49.             this.speed3 = spellTarget.moveSpeed;
  50.     }
  51.  
  52.     @Override
  53.     public void onEffectOverTime(World world, EntityLiving source, EntityLiving target) {
  54.         if (spellTarget instanceof EntityPlayer) {
  55.             ((EntityPlayer) spellTarget).speedOnGround = this.speed1 + this.speed1 * 0.2F * this.getLevel();
  56.             if (!this.ran) {
  57.                 spellTarget.landMovementFactor = this.speed2 + this.speed2 * 0.2F * this.getLevel();
  58.                 this.ran = !this.ran;
  59.             }
  60.         } else
  61.             spellTarget.moveSpeed = this.speed3 + this.speed3 * 0.2F * this.getLevel();
  62.     }
  63.  
  64.     @Override
  65.     public void onRemove(World world, EntityLiving source, EntityLiving target) {
  66.         if (spellTarget instanceof EntityPlayer) {
  67.             ((EntityPlayer) spellTarget).speedOnGround = this.speed1;
  68.             spellTarget.landMovementFactor = this.speed2;
  69.         } else
  70.             spellTarget.moveSpeed = this.speed3;
  71.     }
  72. }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment