Search in sources :

Example 16 with Potion

use of net.minecraft.potion.Potion in project SpongeCommon by SpongePowered.

the class PotionEffectTypeRegistryModule method additionalRegistration.

@AdditionalRegistration
public void additionalRegistration() {
    // I'm guessing that this should work very well.
    for (Potion potion : Potion.REGISTRY) {
        if (potion != null) {
            PotionEffectType potionEffectType = (PotionEffectType) potion;
            if (!this.potionList.contains(potionEffectType)) {
                this.potionList.add(potionEffectType);
                this.potionEffectTypeMap.put(Potion.REGISTRY.getNameForObject(potion).toString(), potionEffectType);
            }
        }
    }
}
Also used : Potion(net.minecraft.potion.Potion) PotionEffectType(org.spongepowered.api.effect.potion.PotionEffectType) AdditionalRegistration(org.spongepowered.api.registry.util.AdditionalRegistration)

Example 17 with Potion

use of net.minecraft.potion.Potion in project MorePlanets by SteveKunG.

the class EntityInfectedElderGuardian method updateAITasks.

@Override
protected void updateAITasks() {
    if ((this.ticksExisted + this.getEntityId()) % 1200 == 0) {
        Potion potion = MobEffects.MINING_FATIGUE;
        for (EntityPlayerMP entityplayermp : this.world.getPlayers(EntityPlayerMP.class, entity -> this.getDistanceSq(entity) < 2500.0D && entity.interactionManager.survivalOrAdventure())) {
            if (!entityplayermp.isPotionActive(potion) || entityplayermp.getActivePotionEffect(potion).getAmplifier() < 2 || entityplayermp.getActivePotionEffect(potion).getDuration() < 1200) {
                MorePlanetsCore.PROXY.spawnParticle(EnumParticleTypesMP.INFECTED_GUARDIAN_APPEARANCE, entityplayermp.posX, entityplayermp.posY, entityplayermp.posZ);
                entityplayermp.world.playSound(entityplayermp, entityplayermp.posX, entityplayermp.posY, entityplayermp.posZ, SoundEvents.ENTITY_ELDER_GUARDIAN_CURSE, SoundCategory.HOSTILE, 1.0F, 1.0F);
                entityplayermp.addPotionEffect(new PotionEffect(potion, 6000, 2));
                if (!entityplayermp.capabilities.isCreativeMode && !entityplayermp.isPotionActive(MPPotions.INFECTED_SPORE_PROTECTION)) {
                    entityplayermp.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 80, 2));
                }
            }
        }
    }
    if (!this.hasHome()) {
        this.setHomePosAndDistance(new BlockPos(this), 16);
    }
}
Also used : Potion(net.minecraft.potion.Potion) PotionEffect(net.minecraft.potion.PotionEffect) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) BlockPos(net.minecraft.util.math.BlockPos)

Example 18 with Potion

use of net.minecraft.potion.Potion in project NewHorizonsCoreMod by GTNewHorizons.

the class WitherProtectionRing method onWornTick.

/*
    private void CreateOrInitNBTTag(ItemStack pItemStack)
    {
        if( pItemStack.stackTagCompound == null )
        {
            pItemStack.setTagCompound( new NBTTagCompound( ) );
            pItemStack.stackTagCompound.setInteger(NBTTAG_VISVICTUS, 10000);
            pItemStack.stackTagCompound.setInteger(NBTTAG_PotionEffectID, Potion.heal.getId());
            pItemStack.stackTagCompound.setInteger(NBTTAG_PotionLevel, 5);
        }
    }
    
    // ------------------ NBT End
    */
@Override
public void onWornTick(ItemStack arg0, EntityLivingBase pEntity) {
    if (!(pEntity instanceof EntityPlayer))
        return;
    if (_mRnd.nextInt(20) == 0) {
        EntityPlayer tPlayer = (EntityPlayer) pEntity;
        InventoryBaubles tBaubles = baubles.common.lib.PlayerHandler.getPlayerBaubles(tPlayer);
        //PotionEffect tEff = getNBTPotionEffect(arg0);
        //int tStoredVictus = GetNBTVictusVis(arg0);
        /*if (tEff == null || tStoredVictus < 1)
            {
                return;
            }
*/
        Potion tPot = Potion.wither;
        if (tPlayer.isPotionActive(tPot)) {
            tPlayer.removePotionEffect(tPot.id);
        //DamageItem(arg0);
        }
    }
}
Also used : InventoryBaubles(baubles.common.container.InventoryBaubles) Potion(net.minecraft.potion.Potion) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 19 with Potion

use of net.minecraft.potion.Potion in project Bewitchment by Um-Mitternacht.

the class BrewUtils method addPotionTooltip.

@SideOnly(Side.CLIENT)
public static void addPotionTooltip(ItemStack itemIn, List<String> tooltip) {
    List<PotionEffect> list = PotionUtils.getEffectsFromStack(itemIn);
    List<Tuple<String, AttributeModifier>> attributes = Lists.newArrayList();
    if (list.isEmpty()) {
        tooltip.add(TextFormatting.DARK_GRAY + "" + TextFormatting.ITALIC + "---");
    } else {
        for (PotionEffect effect : list) {
            StringBuilder string = new StringBuilder();
            string.append(" - ").append(I18n.format(effect.getEffectName()).trim());
            Potion potion = effect.getPotion();
            Map<IAttribute, AttributeModifier> map = potion.getAttributeModifierMap();
            if (!map.isEmpty()) {
                for (Map.Entry<IAttribute, AttributeModifier> entry : map.entrySet()) {
                    AttributeModifier attribute = entry.getValue();
                    attribute = new AttributeModifier(attribute.getName(), potion.getAttributeModifierAmount(effect.getAmplifier(), attribute), attribute.getOperation());
                    attributes.add(new Tuple<>(entry.getKey().getName(), attribute));
                }
            }
            if (effect.getAmplifier() > 0) {
                string.append(" ").append(RomanNumber.getRoman(effect.getAmplifier()));
            }
            if (effect.getDuration() > 20) {
                string.append(" (").append(Potion.getPotionDurationString(effect, 1.0F)).append(")");
            }
            if (potion.isBadEffect()) {
                tooltip.add(TextFormatting.DARK_RED + string.toString());
            } else {
                tooltip.add(TextFormatting.DARK_BLUE + string.toString());
            }
        }
    }
    if (!attributes.isEmpty()) {
        tooltip.add("");
        tooltip.add(TextFormatting.DARK_PURPLE + I18n.format("potion.whenDrank"));
        for (Tuple<String, AttributeModifier> tuple : attributes) {
            AttributeModifier modifier = tuple.getSecond();
            double amount = modifier.getAmount();
            double newAmount;
            if (modifier.getOperation() != 1 && modifier.getOperation() != 2) {
                newAmount = modifier.getAmount();
            } else {
                newAmount = modifier.getAmount() * 100.0D;
            }
            if (amount > 0.0D) {
                tooltip.add(TextFormatting.BLUE + I18n.format("attribute.modifier.plus." + modifier.getOperation(), ItemStack.DECIMALFORMAT.format(newAmount), I18n.format("attribute.name." + tuple.getFirst())));
            } else if (amount < 0.0D) {
                newAmount = newAmount * -1.0D;
                tooltip.add(TextFormatting.RED + I18n.format("attribute.modifier.take." + modifier.getOperation(), ItemStack.DECIMALFORMAT.format(newAmount), I18n.format("attribute.name." + tuple.getFirst())));
            }
        }
    }
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) Potion(net.minecraft.potion.Potion) AttributeModifier(net.minecraft.entity.ai.attributes.AttributeModifier) IAttribute(net.minecraft.entity.ai.attributes.IAttribute) Tuple(net.minecraft.util.Tuple) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 20 with Potion

use of net.minecraft.potion.Potion in project BaseMetals by MinecraftModDevelopmentMods.

the class MMDToolEffects method applyEffectsForMithril.

private static void applyEffectsForMithril(final EntityPlayer player) {
    if (hasFullSuit(player, MaterialNames.MITHRIL)) {
        // needed to avoid concurrent modification error
        final List<Potion> removeList = new LinkedList<>();
        final Iterator<PotionEffect> effectIterator = player.getActivePotionEffects().iterator();
        while (effectIterator.hasNext()) {
            final PotionEffect pe = effectIterator.next();
            final Potion p = pe.getPotion();
            if (p.isBadEffect()) {
                removeList.add(p);
            }
        }
        for (final Potion p : removeList) {
            player.removePotionEffect(p);
        }
    }
}
Also used : Potion(net.minecraft.potion.Potion) PotionEffect(net.minecraft.potion.PotionEffect) LinkedList(java.util.LinkedList)

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