Search in sources :

Example 96 with PotionEffect

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

the class ItemPotionFlask method onItemUseFinish.

@Override
public ItemStack onItemUseFinish(ItemStack stack, World world, EntityLivingBase entityLiving) {
    EntityPlayer player = entityLiving instanceof EntityPlayer ? (EntityPlayer) entityLiving : null;
    int remainingUses = stack.getMaxDamage() - stack.getItemDamage();
    if (remainingUses <= 0) {
        NBTHelper.checkNBT(stack);
        stack.getTagCompound().setBoolean("empty", true);
        return stack;
    }
    if (player == null || !player.capabilities.isCreativeMode) {
        stack.setItemDamage(stack.getItemDamage() + 1);
    }
    if (!world.isRemote) {
        for (PotionEffect potioneffect : PotionUtils.getEffectsFromStack(stack)) {
            entityLiving.addPotionEffect(new PotionEffect(potioneffect));
        }
    }
    return stack;
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 97 with PotionEffect

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

the class ItemSentientArmour method onPlayerAttacked.

public void onPlayerAttacked(ItemStack stack, DamageSource source, EntityPlayer attackedPlayer) {
    if (source.getTrueSource() instanceof EntityLivingBase) {
        EntityLivingBase attacker = (EntityLivingBase) source.getTrueSource();
        EnumDemonWillType type = this.getCurrentType(stack);
        switch(type) {
            case CORROSIVE:
                if (!source.isProjectile()) {
                    // TODO: customize duration
                    attacker.addPotionEffect(new PotionEffect(MobEffects.POISON, 100));
                }
                break;
            case DEFAULT:
                break;
            case DESTRUCTIVE:
                break;
            case STEADFAST:
                break;
            case VENGEFUL:
                break;
        }
    }
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType)

Example 98 with PotionEffect

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

the class PotionBloodMagic method apply.

public PotionEffect apply(EntityLivingBase entity, int duration, int level) {
    PotionEffect effect = new PotionEffect(this, duration, level, false, false);
    entity.addPotionEffect(effect);
    return effect;
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect)

Example 99 with PotionEffect

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

the class LivingArmourUpgradeNightSight method onTick.

@Override
public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) {
    if (world.getLight(player.getPosition()) <= 9) {
        isActive = true;
        if (player.isPotionActive(MobEffects.NIGHT_VISION)) {
            int dur = player.getActivePotionEffect(MobEffects.NIGHT_VISION).getDuration();
            if (dur > 100 && dur < 20 * 60 * 20) {
                // Don't override the potion effect if the other potion effect is sufficiently long.
                return;
            }
        }
        player.addPotionEffect(new PotionEffect(MobEffects.NIGHT_VISION, Constants.Misc.NIGHT_VISION_CONSTANT_BEGIN, 0, false, false));
    } else {
        isActive = false;
    }
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect)

Example 100 with PotionEffect

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

the class LivingArmourUpgradePoisonResist method onTick.

@Override
public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) {
    if (player.isPotionActive(MobEffects.POISON) && poisonCooldown <= 0) {
        PotionEffect eff = player.getActivePotionEffect(MobEffects.POISON);
        if (eff.getAmplifier() <= poisonMaxCure[this.level]) {
            player.removePotionEffect(MobEffects.POISON);
            poisonCooldown = poisonCooldownTime[this.level];
            player.sendStatusMessage(new TextComponentString(TextHelper.localize(chatBase + "poisonRemove")), true);
        }
    } else if (poisonCooldown > 0) {
        poisonCooldown--;
    }
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) TextComponentString(net.minecraft.util.text.TextComponentString)

Aggregations

PotionEffect (net.minecraft.potion.PotionEffect)367 EntityLivingBase (net.minecraft.entity.EntityLivingBase)115 EntityPlayer (net.minecraft.entity.player.EntityPlayer)89 ItemStack (net.minecraft.item.ItemStack)62 BlockPos (net.minecraft.util.math.BlockPos)48 Entity (net.minecraft.entity.Entity)36 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)35 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)34 World (net.minecraft.world.World)26 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)24 Potion (net.minecraft.potion.Potion)21 IBlockState (net.minecraft.block.state.IBlockState)20 ArrayList (java.util.ArrayList)19 WorldServer (net.minecraft.world.WorldServer)19 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)17 List (java.util.List)14 Random (java.util.Random)14 NBTTagList (net.minecraft.nbt.NBTTagList)14 TileEntity (net.minecraft.tileentity.TileEntity)13 SPacketEntityEffect (net.minecraft.network.play.server.SPacketEntityEffect)9