Advertisement
Superloup10

EffectPotion

Sep 10th, 2015
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.51 KB | None | 0 0
  1. package fr.tesm.module.magic.common.potion;
  2.  
  3. import fr.tesm.main.common.core.PlayerProps;
  4.  
  5. import java.awt.Color;
  6.  
  7. import net.minecraft.entity.EntityLivingBase;
  8. import net.minecraft.entity.player.EntityPlayer;
  9. import net.minecraft.potion.Potion;
  10. import net.minecraft.util.ResourceLocation;
  11.  
  12. public class EffectPotion extends Potion
  13. {
  14.     public static Potion mana;
  15.     public static Potion stamina;
  16.     public static Potion health;
  17.  
  18.     protected EffectPotion(int potionID, ResourceLocation location, boolean badEffect, int potionColor, String name)
  19.     {
  20.         super(potionID, location, badEffect, potionColor);
  21.         this.setPotionName("potion." + name);
  22.     }
  23.  
  24.     @Override
  25.     protected EffectPotion setIconIndex(int x, int y)
  26.     {
  27.         super.setIconIndex(x, y);
  28.         return this;
  29.     }
  30.  
  31.     @Override
  32.     public void performEffect(EntityLivingBase entity, int level)
  33.     {
  34.         super.performEffect(entity, level);
  35.  
  36.         if(entity instanceof EntityPlayer)
  37.         {
  38.             PlayerProps props = PlayerProps.get((EntityPlayer)entity);
  39.             if(props != null)
  40.             {
  41.                 if(this.id == mana.id)
  42.                 {
  43.                     props.addMana(5);
  44.                 }
  45.  
  46.                 if(this.id == stamina.id)
  47.                 {
  48.                     props.addStamina(5);
  49.                 }
  50.  
  51.                 if(this.id == health.id)
  52.                 {
  53.                     float maxHeal = entity.getMaxHealth();
  54.                     if(entity.getHealth() < maxHeal)
  55.                     {
  56.                         float regen = maxHeal / 6000;
  57.                         entity.heal(regen);
  58.                         System.out.println(entity.getHealth());
  59.                     }
  60.                 }
  61.                 System.out.println(health.id);
  62.             }
  63.         }
  64.         System.out.println(entity);
  65.     }
  66.  
  67.     public static void loadEffect()
  68.     {
  69.         mana = new EffectPotion(25, new ResourceLocation("mana"), false, Color.cyan.getRGB(), "mana").setEffectiveness(0.25D);
  70.         stamina = new EffectPotion(26, new ResourceLocation("stamina"), false, Color.green.getRGB(), "stamina").setEffectiveness(0.25D);
  71.         health = new EffectPotion(27, new ResourceLocation("health"), false, Color.red.getRGB(), "health").setEffectiveness(0.25D);
  72.     }
  73.  
  74.     public static void register()
  75.     {
  76.         Potion.potionTypes[mana.getId()] = mana;
  77.         Potion.potionTypes[stamina.getId()] = stamina;
  78.         Potion.potionTypes[health.getId()] = health;
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement