Search in sources :

Example 21 with Potion

use of net.minecraft.potion.Potion in project Nutrition by WesCook.

the class EffectsList method parseJson.

// Parse JSON data into more useful objects
public static void parseJson() {
    for (JsonEffect effectRaw : jsonEffects) {
        // Skip if effect is not enabled, or if field omitted (null)
        if (effectRaw.enabled != null && !effectRaw.enabled)
            continue;
        // Get potion from config
        Potion potion = Potion.getPotionFromResourceLocation(effectRaw.potion);
        if (potion == null) {
            Log.error("Potion '" + effectRaw.potion + "' is not valid (" + effectRaw.name + ").");
            continue;
        }
        // Copying and cleaning data
        Effect effect = new Effect();
        effect.name = effectRaw.name;
        effect.potion = potion;
        effect.minimum = effectRaw.minimum;
        effect.maximum = effectRaw.maximum;
        effect.detect = effectRaw.detect;
        // Amplifier defaults to 0 if undefined
        effect.amplifier = (effectRaw.amplifier != null) ? effectRaw.amplifier : 0;
        // Default the cumulative modifier to 1 if not defined
        effect.cumulativeModifier = (effectRaw.cumulative_modifier != null) ? effectRaw.cumulative_modifier : 1;
        // If nutrients are unspecified in file, this defaults to include every nutrient
        if (effectRaw.nutrients.size() == 0) {
            effect.nutrients.addAll(NutrientList.get());
        } else {
            // Field has been set, so fetch nutrients by name
            for (String nutrientName : effectRaw.nutrients) {
                Nutrient nutrient = NutrientList.getByName(nutrientName);
                if (nutrient != null)
                    // Nutrient checks out, add to list
                    effect.nutrients.add(nutrient);
                else
                    Log.error("Nutrient " + nutrientName + " not found (" + effectRaw.name + ").");
            }
        }
        // Register effect
        effects.add(effect);
    }
}
Also used : Potion(net.minecraft.potion.Potion) Nutrient(ca.wescook.nutrition.nutrients.Nutrient)

Example 22 with Potion

use of net.minecraft.potion.Potion in project BloodMagic by WayofTime.

the class Utils method applyPotionDamageCalculations.

public static float applyPotionDamageCalculations(EntityLivingBase attackedEntity, DamageSource source, float damage) {
    Potion resistance = MobEffects.RESISTANCE;
    if (source.isDamageAbsolute()) {
        return damage;
    } else {
        if (attackedEntity.isPotionActive(resistance) && source != DamageSource.OUT_OF_WORLD) {
            int i = (attackedEntity.getActivePotionEffect(resistance).getAmplifier() + 1) * 5;
            int j = 25 - i;
            float f = damage * (float) j;
            damage = f / 25.0F;
        }
        if (damage <= 0.0F) {
            return 0.0F;
        } else {
            int k = EnchantmentHelper.getEnchantmentModifierDamage(attackedEntity.getArmorInventoryList(), source);
            if (k > 20) {
                k = 20;
            }
            if (k > 0 && k <= 20) {
                int l = 25 - k;
                float f1 = damage * (float) l;
                damage = f1 / 25.0F;
            }
            return damage;
        }
    }
}
Also used : Potion(net.minecraft.potion.Potion)

Example 23 with Potion

use of net.minecraft.potion.Potion in project takumicraft by TNTModders.

the class EntityDarkCreeper method takumiExplodeEvent.

@Override
public boolean takumiExplodeEvent(Detonate event) {
    for (Entity entity : event.getAffectedEntities()) {
        if (entity instanceof EntityLivingBase) {
            boolean done = false;
            for (int i = 0; i < 50 && !done; i++) {
                done = this.teleportTo((EntityLivingBase) entity);
            }
            Potion potion = MobEffects.BLINDNESS;
            switch(this.rand.nextInt(6)) {
                case 0:
                    break;
                case 1:
                    potion = MobEffects.NAUSEA;
                    break;
                case 2:
                    potion = MobEffects.SLOWNESS;
                    break;
                case 3:
                    potion = MobEffects.HUNGER;
                    break;
                case 4:
                    potion = MobEffects.UNLUCK;
                    break;
                case 5:
                    if (this.rand.nextBoolean() && this.getPowered()) {
                        potion = MobEffects.LEVITATION;
                    }
                    break;
            }
            EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(entity.world, entity.posX, entity.posY, entity.posZ);
            entityareaeffectcloud.setRadius(5F);
            entityareaeffectcloud.setRadiusOnUse(-0.5F);
            entityareaeffectcloud.setWaitTime(10);
            entityareaeffectcloud.setDuration(entityareaeffectcloud.getDuration());
            entityareaeffectcloud.setRadiusPerTick(-entityareaeffectcloud.getRadius() / entityareaeffectcloud.getDuration());
            entityareaeffectcloud.addEffect(new PotionEffect(potion, potion == MobEffects.LEVITATION ? 100 : 1200, this.getPowered() ? 1 : 0));
            this.world.spawnEntity(entityareaeffectcloud);
        }
    }
    return true;
}
Also used : Entity(net.minecraft.entity.Entity) Potion(net.minecraft.potion.Potion) PotionEffect(net.minecraft.potion.PotionEffect) EntityAreaEffectCloud(net.minecraft.entity.EntityAreaEffectCloud) EntityLivingBase(net.minecraft.entity.EntityLivingBase)

Example 24 with Potion

use of net.minecraft.potion.Potion in project ArsMagica2 by Mithion.

the class AMIngameGUI method RenderBuffs.

public void RenderBuffs(int i, int j) {
    if (!AMCore.config.getShowBuffs()) {
        return;
    }
    int barWidth = i / 8;
    AMVector2 posBuffStart = getShiftedVector(AMCore.config.getPositiveBuffsPosition(), i, j);
    AMVector2 negBuffStart = getShiftedVector(AMCore.config.getNegativeBuffsPosition(), i, j);
    int positive_buff_x = posBuffStart.iX;
    int positive_buff_y = posBuffStart.iY;
    int negative_buff_x = negBuffStart.iX;
    int negative_buff_y = negBuffStart.iY;
    for (PotionEffect pe : getPotionEffectsByTimeRemaining()) {
        this.mc.renderEngine.bindTexture(inventory);
        int potionID = pe.getPotionID();
        if (potionID < 0 || potionID >= Potion.potionTypes.length)
            continue;
        Potion potion = Potion.potionTypes[potionID];
        if (potion == null)
            continue;
        if (potion.isBadEffect()) {
            if (potion.hasStatusIcon()) {
                int l = potion.getStatusIconIndex();
                if (pe.getDuration() < 100) {
                    GL11.glColor4f(1.0f, 1.0f, 1.0f, AMGuiHelper.instance.fastFlashAlpha);
                } else if (pe.getDuration() < 200) {
                    GL11.glColor4f(1.0f, 1.0f, 1.0f, AMGuiHelper.instance.slowFlashAlpha);
                }
                this.drawTexturedModalRect_Classic(negative_buff_x, negative_buff_y, 0 + l % 8 * 18, 198 + l / 8 * 18, 10, 10, 18, 18);
                GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
                negative_buff_x -= 12;
                if (negative_buff_x <= negBuffStart.iX - 48) {
                    negative_buff_x = negBuffStart.iX;
                    negative_buff_y += 12;
                }
            }
        } else {
            this.mc.renderEngine.bindTexture(inventory);
            if (potion.hasStatusIcon()) {
                int l = potion.getStatusIconIndex();
                if (pe.getDuration() < 100) {
                    GL11.glColor4f(1.0f, 1.0f, 1.0f, AMGuiHelper.instance.fastFlashAlpha);
                } else if (pe.getDuration() < 200) {
                    GL11.glColor4f(1.0f, 1.0f, 1.0f, AMGuiHelper.instance.slowFlashAlpha);
                }
                this.drawTexturedModalRect_Classic(positive_buff_x, positive_buff_y, 0 + l % 8 * 18, 198 + l / 8 * 18, 10, 10, 18, 18);
                GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
                positive_buff_x += 12;
                if (positive_buff_x >= posBuffStart.iX + 48) {
                    positive_buff_x = posBuffStart.iX;
                    positive_buff_y += 12;
                }
            }
        }
    }
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) Potion(net.minecraft.potion.Potion) AMVector2(am2.api.math.AMVector2)

Example 25 with Potion

use of net.minecraft.potion.Potion in project ArsMagica2 by Mithion.

the class BuffList method setPotionArrayLength.

private static void setPotionArrayLength(int length) throws Exception {
    if (length <= Potion.potionTypes.length)
        return;
    Potion[] potions = new Potion[length];
    for (int i = 0; i < Potion.potionTypes.length; ++i) {
        potions[i] = Potion.potionTypes[i];
    }
    Field field = null;
    Field[] fields = Potion.class.getDeclaredFields();
    for (Field f : fields) {
        if (f.getType().equals(Potion[].class)) {
            field = f;
            break;
        }
    }
    setFinalStatic(field, potions);
}
Also used : Field(java.lang.reflect.Field) Potion(net.minecraft.potion.Potion)

Aggregations

Potion (net.minecraft.potion.Potion)32 PotionEffect (net.minecraft.potion.PotionEffect)18 AttributeModifier (net.minecraft.entity.ai.attributes.AttributeModifier)3 IAttribute (net.minecraft.entity.ai.attributes.IAttribute)3 ItemStack (net.minecraft.item.ItemStack)3 Tuple (net.minecraft.util.Tuple)3 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 Field (java.lang.reflect.Field)2 Optional (java.util.Optional)2 Minecraft (net.minecraft.client.Minecraft)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2 Item (net.minecraft.item.Item)2 PotionType (net.minecraft.potion.PotionType)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 BlockPos (net.minecraft.util.math.BlockPos)2 PotionEffectType (org.spongepowered.api.effect.potion.PotionEffectType)2 AMVector2 (am2.api.math.AMVector2)1 InventoryBaubles (baubles.common.container.InventoryBaubles)1 ChemthrowerEffect_Damage (blusunrize.immersiveengineering.api.tool.ChemthrowerHandler.ChemthrowerEffect_Damage)1