aboutsummaryrefslogtreecommitdiff
path: root/main/java/gregtech/common/entities/GT_Entity_Arrow_Potion.java
blob: 1deb2f37949d6f0972b21725f93210af2e485956 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package gregtech.common.entities;

import java.util.Random;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;

public class GT_Entity_Arrow_Potion
  extends GT_Entity_Arrow
{
  public GT_Entity_Arrow_Potion(World aWorld)
  {
    super(aWorld);
  }
  
  public GT_Entity_Arrow_Potion(World aWorld, double aX, double aY, double aZ)
  {
    super(aWorld, aX, aY, aZ);
  }
  
  public GT_Entity_Arrow_Potion(World aWorld, EntityLivingBase aEntity, float aSpeed)
  {
    super(aWorld, aEntity, aSpeed);
  }
  
  public void writeEntityToNBT(NBTTagCompound aNBT)
  {
    super.writeEntityToNBT(aNBT);
    aNBT.setIntArray("mPotions", this.mPotions);
  }
  
  public void readEntityFromNBT(NBTTagCompound aNBT)
  {
    super.readEntityFromNBT(aNBT);
    setPotions(aNBT.getIntArray("mPotions"));
  }
  
  public boolean breaksOnImpact()
  {
    return true;
  }
  
  public void setPotions(int... aPotions)
  {
    if (aPotions != null) {
      this.mPotions = aPotions;
    }
  }
  
  public int[] getPotions()
  {
    return this.mPotions;
  }
  
  private int[] mPotions = new int[0];
  
  public int[] onHitEntity(Entity aHitEntity, Entity aShootingEntity, ItemStack aArrow, int aRegularDamage, int aMagicDamage, int aKnockback, int aFireDamage, int aHitTimer)
  {
    if ((aHitEntity instanceof EntityLivingBase)) {
      for (int i = 3; i < this.mPotions.length; i += 4) {
        if (aHitEntity.worldObj.rand.nextInt(100) < this.mPotions[i]) {
          ((EntityLivingBase)aHitEntity).addPotionEffect(new PotionEffect(this.mPotions[(i - 3)], this.mPotions[(i - 2)], this.mPotions[(i - 1)], false));
        }
      }
    }
    return super.onHitEntity(aHitEntity, aShootingEntity, aArrow, 1, aMagicDamage, aKnockback, aFireDamage, aHitTimer);
  }
}



/* Location:           F:\Torrent\minecraft\jd-gui-0.3.6.windows\gregtech_1.7.10-5.07.07-dev.jar

 * Qualified Name:     gregtech.common.entities.GT_Entity_Arrow_Potion

 * JD-Core Version:    0.7.0.1

 */