Search in sources :

Example 26 with Potion

use of net.minecraft.potion.Potion in project harvestcraft by MatrexsVigil.

the class ItemPamPotionFood method addDefaultSpeedPotionEffect.

public ItemPamPotionFood addDefaultSpeedPotionEffect() {
    setAlwaysEdible();
    final Potion potion = Potion.getPotionFromResourceLocation("speed");
    if (potion == null) {
        FMLLog.bigWarning("Could not set potion effect.");
        return this;
    }
    setPotionEffect(new PotionEffect(potion, 600, 0), 0.8F);
    return this;
}
Also used : Potion(net.minecraft.potion.Potion) PotionEffect(net.minecraft.potion.PotionEffect)

Example 27 with Potion

use of net.minecraft.potion.Potion in project ImmersiveEngineering by BluSunrize.

the class ThaumcraftHelper method init.

@Override
public void init() {
    FMLInterModComms.sendMessage("thaumcraft", "harvestStackedCrop", new ItemStack(IEContent.blockCrop, 5));
    Potion potion_ward = Potion.getPotionFromResourceLocation("thaumcraft:warpward");
    if (potion_ward != null)
        ChemthrowerHandler.registerEffect("purifying_fluid", new ChemthrowerEffect_Potion(null, 0, potion_ward, 100, 0));
    try {
        Class c_DamageSourceThaumcraft = Class.forName("thaumcraft.api.damagesource.DamageSourceThaumcraft");
        if (c_DamageSourceThaumcraft != null) {
            DamageSource dmg_dissolve = (DamageSource) c_DamageSourceThaumcraft.getField("dissolve").get(null);
            ChemthrowerHandler.registerEffect("liquid_death", new ChemthrowerEffect_Damage(dmg_dissolve, 4));
        }
    } catch (Exception e) {
    }
    try {
        Class c_TileSmelter = Class.forName("thaumcraft.common.tiles.essentia.TileSmelter");
        if (c_TileSmelter != null)
            ExternalHeaterHandler.registerHeatableAdapter(c_TileSmelter, new AlchemyFurnaceAdapter(c_TileSmelter));
    } catch (Exception e) {
    }
}
Also used : DamageSource(net.minecraft.util.DamageSource) ChemthrowerEffect_Damage(blusunrize.immersiveengineering.api.tool.ChemthrowerHandler.ChemthrowerEffect_Damage) ChemthrowerEffect_Potion(blusunrize.immersiveengineering.api.tool.ChemthrowerHandler.ChemthrowerEffect_Potion) Potion(net.minecraft.potion.Potion) ItemStack(net.minecraft.item.ItemStack) ChemthrowerEffect_Potion(blusunrize.immersiveengineering.api.tool.ChemthrowerHandler.ChemthrowerEffect_Potion)

Example 28 with Potion

use of net.minecraft.potion.Potion in project BetterRain by OreCruncher.

the class PotionHUD method doRender.

public void doRender(final RenderGameOverlayEvent event) {
    if (event.isCancelable() || event.type != ElementType.EXPERIENCE) {
        return;
    }
    final int TEXT_POTION_NAME = (int) (255 * ModOptions.potionHudTransparency) << 24 | 0xFFFFFF;
    final int TEXT_DURATION = (int) (255 * ModOptions.potionHudTransparency) << 24 | 0x7F7F7F;
    final int TEXT_DURATION_LOW = (int) (255 * ModOptions.potionHudTransparency) << 24 | 0xFF0000;
    final float GUITOP = ModOptions.potionHudTopOffset;
    final float GUILEFT = ModOptions.potionHudLeftOffset;
    final float SCALE = ModOptions.potionHudScale;
    final Minecraft mc = Minecraft.getMinecraft();
    final FontRenderer font = mc.fontRendererObj;
    final EntityPlayer player = Minecraft.getMinecraft().thePlayer;
    int guiLeft = 2;
    int guiTop = 2;
    final Collection<PotionEffect> collection = player.getActivePotionEffects();
    if (!collection.isEmpty()) {
        GL11.glPushMatrix();
        GL11.glColor4f(1.0F, 1.0F, 1.0F, ModOptions.potionHudTransparency);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glTranslatef(GUILEFT, GUITOP, 0.0F);
        GL11.glScalef(SCALE, SCALE, SCALE);
        int k = 33;
        if (collection.size() > 7) {
            k = 198 / (collection.size() - 1);
        }
        for (Iterator<PotionEffect> iterator = collection.iterator(); iterator.hasNext(); guiTop += k) {
            final PotionEffect potioneffect = iterator.next();
            final Potion potion = Potion.potionTypes[potioneffect.getPotionID()];
            GL11.glColor4f(1.0F, 1.0F, 1.0F, ModOptions.potionHudTransparency);
            mc.getTextureManager().bindTexture(TEXTURE);
            this.drawTexturedModalRect(guiLeft, guiTop, 0, 166, 140, 32);
            if (potion.hasStatusIcon()) {
                int l = potion.getStatusIconIndex();
                this.drawTexturedModalRect(guiLeft + 6, guiTop + 7, 0 + l % 8 * 18, 198 + l / 8 * 18, 18, 18);
            }
            try {
                potion.renderInventoryEffect(guiLeft, guiTop, potioneffect, mc);
            } catch (final Exception ex) {
                ;
            }
            if (!potion.shouldRenderInvText(potioneffect))
                continue;
            String s1 = I18n.format(potion.getName(), new Object[0]);
            if (potioneffect.getAmplifier() == 1) {
                s1 = s1 + " " + I18n.format("enchantment.level.2", new Object[0]);
            } else if (potioneffect.getAmplifier() == 2) {
                s1 = s1 + " " + I18n.format("enchantment.level.3", new Object[0]);
            } else if (potioneffect.getAmplifier() == 3) {
                s1 = s1 + " " + I18n.format("enchantment.level.4", new Object[0]);
            }
            font.drawStringWithShadow(s1, guiLeft + 10 + 18, guiTop + 6, TEXT_POTION_NAME);
            String s = Potion.getDurationString(potioneffect);
            font.drawStringWithShadow(s, guiLeft + 10 + 18, guiTop + 6 + 10, potioneffect.getDuration() <= 200 ? TEXT_DURATION_LOW : TEXT_DURATION);
        }
        GL11.glPopMatrix();
    }
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) Potion(net.minecraft.potion.Potion) EntityPlayer(net.minecraft.entity.player.EntityPlayer) FontRenderer(net.minecraft.client.gui.FontRenderer) Minecraft(net.minecraft.client.Minecraft)

Example 29 with Potion

use of net.minecraft.potion.Potion in project BetterStorage by copygirl.

the class ItemDrinkingHelmet method use.

public static void use(EntityPlayer player) {
    ItemStack drinkingHelmet = getDrinkingHelmet(player);
    if (drinkingHelmet == null)
        return;
    int uses = StackUtils.get(drinkingHelmet, 0, "uses");
    if (uses <= 0)
        return;
    ItemStack[] potions = StackUtils.getStackContents(drinkingHelmet, 2);
    List<PotionEffect> potionEffects = new ArrayList<PotionEffect>();
    for (ItemStack item : potions) if (item.getItem() instanceof ItemPotion) {
        List<PotionEffect> effects = ((ItemPotion) item.getItem()).getEffects(item);
        if (effects != null)
            potionEffects.addAll(effects);
    }
    for (PotionEffect effect : potionEffects) {
        Potion potion = Potion.potionTypes[effect.getPotionID()];
        PotionEffect active = player.getActivePotionEffect(potion);
        effect = new SmallPotionEffect(effect, active);
        player.addPotionEffect(effect);
    }
    player.worldObj.playSoundAtEntity(player, "random.drink", 0.5F, 0.9F + player.worldObj.rand.nextFloat() * 0.1F);
    if (--uses <= 0)
        setPotions(drinkingHelmet, null);
    else
        StackUtils.set(drinkingHelmet, uses, "uses");
}
Also used : SmallPotionEffect(net.mcft.copy.betterstorage.misc.SmallPotionEffect) ItemPotion(net.minecraft.item.ItemPotion) PotionEffect(net.minecraft.potion.PotionEffect) SmallPotionEffect(net.mcft.copy.betterstorage.misc.SmallPotionEffect) ItemPotion(net.minecraft.item.ItemPotion) Potion(net.minecraft.potion.Potion) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ItemStack(net.minecraft.item.ItemStack)

Example 30 with Potion

use of net.minecraft.potion.Potion in project BetterStorage by copygirl.

the class SmallPotionEffect method performEffect.

@Override
public void performEffect(EntityLivingBase entity) {
    int smallEffect = 6 * (getAmplifier() + 1) / ItemDrinkingHelmet.maxUses;
    Potion potion = Potion.potionTypes[getPotionID()];
    if (entity.isEntityUndead() ? (potion == Potion.heal) : (potion == Potion.harm))
        entity.attackEntityFrom(DamageSource.magic, smallEffect);
    else if (potion == Potion.heal)
        entity.heal(smallEffect);
    else
        super.performEffect(entity);
}
Also used : 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