/// <summary>
        /// Called when the throwable hits a block or entity.
        /// </summary>
        protected override void OnImpact(MovingObjectPosition par1MovingObjectPosition)
        {
            if (!WorldObj.IsRemote)
            {
                List <PotionEffect> list = Item.Potion.GetEffects(PotionDamage);

                if (list != null && list.Count > 0)
                {
                    AxisAlignedBB axisalignedbb = BoundingBox.Expand(4, 2, 4);
                    List <Entity> list1         = WorldObj.GetEntitiesWithinAABB(typeof(net.minecraft.src.EntityLiving), axisalignedbb);

                    if (list1 != null && list1.Count > 0)
                    {
                        for (IEnumerator <Entity> iterator = list1.GetEnumerator(); iterator.MoveNext();)
                        {
                            Entity entity = iterator.Current;
                            double d      = GetDistanceSqToEntity(entity);

                            if (d < 16D)
                            {
                                double d1 = 1.0D - Math.Sqrt(d) / 4D;

                                if (entity == par1MovingObjectPosition.EntityHit)
                                {
                                    d1 = 1.0D;
                                }

                                IEnumerator <PotionEffect> iterator1 = list.GetEnumerator();

                                while (iterator1.MoveNext())
                                {
                                    PotionEffect potioneffect = iterator1.Current;
                                    int          i            = potioneffect.GetPotionID();

                                    if (Potion.PotionTypes[i].IsInstant())
                                    {
                                        Potion.PotionTypes[i].AffectEntity(Thrower, (EntityLiving)entity, potioneffect.GetAmplifier(), d1);
                                    }
                                    else
                                    {
                                        int j = (int)(d1 * (double)potioneffect.GetDuration() + 0.5D);

                                        if (j > 20)
                                        {
                                            ((EntityLiving)entity).AddPotionEffect(new PotionEffect(i, j, potioneffect.GetAmplifier()));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                WorldObj.PlayAuxSFX(2002, (int)Math.Round(PosX), (int)Math.Round(PosY), (int)Math.Round(PosZ), PotionDamage);
                SetDead();
            }
        }
예제 #2
0
        public static string GetDurationString(PotionEffect par0PotionEffect)
        {
            int i = par0PotionEffect.GetDuration();
            int j = i / 20;
            int k = j / 60;

            j %= 60;

            if (j < 10)
            {
                return((new StringBuilder()).Append(k).Append(":0").Append(j).ToString());
            }
            else
            {
                return((new StringBuilder()).Append(k).Append(":").Append(j).ToString());
            }
        }
예제 #3
0
        /// <summary>
        /// allows items to add custom lines of information to the mouseover description
        /// </summary>
        public virtual void AddInformation(ItemStack par1ItemStack, List <string> par2List)
        {
            if (par1ItemStack.GetItemDamage() == 0)
            {
                return;
            }

            List <PotionEffect> list = Item.Potion.GetEffects(par1ItemStack);

            if (list != null && list.Count > 0)
            {
                for (IEnumerator <PotionEffect> iterator = list.GetEnumerator(); iterator.MoveNext();)
                {
                    PotionEffect potioneffect = iterator.Current;
                    string       s1           = StatCollector.TranslateToLocal(potioneffect.GetEffectName()).Trim();

                    if (potioneffect.GetAmplifier() > 0)
                    {
                        s1 = (new StringBuilder()).Append(s1).Append(" ").Append(StatCollector.TranslateToLocal((new StringBuilder()).Append("potion.potency.").Append(potioneffect.GetAmplifier()).ToString()).Trim()).ToString();
                    }

                    if (potioneffect.GetDuration() > 20)
                    {
                        s1 = (new StringBuilder()).Append(s1).Append(" (").Append(net.minecraft.src.Potion.GetDurationString(potioneffect)).Append(")").ToString();
                    }

                    if (net.minecraft.src.Potion.PotionTypes[potioneffect.GetPotionID()].IsBadEffect())
                    {
                        par2List.Add((new StringBuilder()).Append((char)0xa7 + "c").Append(s1).ToString());
                    }
                    else
                    {
                        par2List.Add((new StringBuilder()).Append((char)0xa7 + "7").Append(s1).ToString());
                    }
                }
            }
            else
            {
                string s = StatCollector.TranslateToLocal("potion.empty").Trim();
                par2List.Add((new StringBuilder()).Append((char)0xa7).Append(s).ToString());
            }
        }