Search in sources :

Example 26 with PotionEffect

use of net.minecraft.potion.PotionEffect in project minecolonies by Minecolonies.

the class EntityCitizen method onLivingUpdate.

/**
     * Called frequently so the entity can update its state every tick as
     * required. For example, zombies and skeletons. use this to react to
     * sunlight and start to burn.
     */
@Override
public void onLivingUpdate() {
    if (recentlyHit > 0) {
        citizenData.markDirty();
    }
    if (world.isRemote) {
        updateColonyClient();
    } else {
        pickupItems();
        cleanupChatMessages();
        updateColonyServer();
        if (getColonyJob() != null) {
            checkIfStuck();
        }
        if (world.isDaytime() && !world.isRaining() && citizenData != null) {
            SoundUtils.playRandomSound(world, this, citizenData.getSaturation());
        } else if (world.isRaining() && 1 >= rand.nextInt(RANT_ABOUT_WEATHER_CHANCE) && this.getColonyJob() != null) {
            SoundUtils.playSoundAtCitizenWithChance(world, this.getPosition(), this.getColonyJob().getBadWeatherSound(), 1);
        }
    }
    if (isEntityInsideOpaqueBlock() || isInsideOfMaterial(Material.LEAVES)) {
        getNavigator().moveAwayFromXYZ(this.getPosition(), MOVE_AWAY_RANGE, MOVE_AWAY_SPEED);
    }
    gatherXp();
    if (citizenData != null) {
        if (citizenData.getSaturation() <= 0) {
            this.addPotionEffect(new PotionEffect(Potion.getPotionFromResourceLocation("slowness")));
        } else {
            this.removeActivePotionEffect(Potion.getPotionFromResourceLocation("slowness"));
        }
        if (citizenData.getSaturation() < HIGH_SATURATION) {
            tryToEat();
        }
    }
    checkHeal();
    super.onLivingUpdate();
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect)

Example 27 with PotionEffect

use of net.minecraft.potion.PotionEffect in project Pearcel-Mod by MiningMark48.

the class ItemCharmedPearcel method doEffects.

public static void doEffects(EntityPlayer player, ItemStack stack) {
    if (stack.getTagCompound().getString("type").equalsIgnoreCase("fire") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_fire, player) || player.isCreative())) {
        player.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, 25, 0, true, false));
        player.extinguish();
        useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_fire, false, player);
    }
    if (stack.getTagCompound().getString("type").equalsIgnoreCase("water") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_water, player) || player.isCreative())) {
        player.addPotionEffect(new PotionEffect(MobEffects.WATER_BREATHING, 25, 5, true, false));
        useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_water, false, player);
    }
    if (stack.getTagCompound().getString("type").equalsIgnoreCase("saturation") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_saturation, player) || player.isCreative())) {
        player.addPotionEffect(new PotionEffect(MobEffects.SATURATION, 25, 5, true, false));
        useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_saturation, false, player);
    }
    if (stack.getTagCompound().getString("type").equalsIgnoreCase("step_assist") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_stepAssist, player) || player.isCreative())) {
        ItemStack s = new ItemStack(ModItems.charmed_pearcel);
        if (!s.hasTagCompound()) {
            s.setTagCompound(new NBTTagCompound());
        }
        s.getTagCompound().setString("type", "step_assist");
        if (player.inventory.hasItemStack(s)) {
            player.stepHeight = 1.25F;
        }
        useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_stepAssist, false, player);
    }
    if (stack.getTagCompound().getString("type").equalsIgnoreCase("gravity") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_gravity, player) || player.isCreative())) {
        if (player.isSneaking()) {
            player.addVelocity(0D, -0.125D, 0D);
        }
        useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_gravity, false, player);
    }
    if (stack.getTagCompound().getString("type").equalsIgnoreCase("adrenaline") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_adrenaline, player) || player.isCreative())) {
        player.addPotionEffect(new PotionEffect(MobEffects.SPEED, 25, 1, true, false));
        player.addPotionEffect(new PotionEffect(MobEffects.HASTE, 25, 0, true, false));
        player.addPotionEffect(new PotionEffect(MobEffects.JUMP_BOOST, 25, 1, true, false));
        useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_adrenaline, false, player);
    }
    if (stack.getTagCompound().getString("type").equalsIgnoreCase("cloaking") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_cloaking, player) || player.isCreative())) {
        player.addPotionEffect(new PotionEffect(MobEffects.INVISIBILITY, 25, 0, true, false));
        useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_cloaking, false, player);
    }
    if (stack.getTagCompound().getString("type").equalsIgnoreCase("hearty") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_hearty, player) || player.isCreative())) {
        player.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, 25, 0, true, false));
        player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 25, 0, true, false));
        useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_hearty, false, player);
    }
    if (stack.getTagCompound().getString("type").equalsIgnoreCase("repair") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_repair, player) || player.isCreative())) {
        if (player.getHeldItemMainhand() != null) {
            if (player.getHeldItemMainhand().getItem().isDamageable() && player.getHeldItemMainhand().getItem().isDamaged(player.getHeldItemMainhand())) {
                Random rand = new Random();
                int num = rand.nextInt(100);
                if (num == 0) {
                    player.getHeldItemMainhand().getItem().setDamage(player.getHeldItemMainhand(), player.getHeldItemMainhand().getItemDamage() - 1);
                }
            }
        }
        useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_repair, false, player);
    }
    if (stack.getTagCompound().getString("type").equalsIgnoreCase("physco") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_physco, player) || player.isCreative())) {
        int x = (int) player.posX;
        int y = (int) player.posY;
        int z = (int) player.posZ;
        int range = 15;
        List<EntityCreature> creatureList = player.world.getEntitiesWithinAABB(EntityCreature.class, new AxisAlignedBB(x - range, y - range, z - range, x + range, y + range, z + range));
        for (EntityCreature creature : creatureList) {
            if (creature.isCreatureType(EnumCreatureType.MONSTER, false)) {
                List<EntityCreature> creatureList2 = creature.world.getEntitiesWithinAABB(EntityCreature.class, new AxisAlignedBB(x - range, y - range, z - range, x + range, y + range, z + range));
                for (EntityCreature creature2 : creatureList2) {
                    creature.setAttackTarget(creature2);
                }
            }
        }
        useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_physco, false, player);
    }
    if (stack.getTagCompound().getString("type").equalsIgnoreCase("third_eye") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_thirdEye, player) || player.isCreative())) {
        int x = (int) player.posX;
        int y = (int) player.posY;
        int z = (int) player.posZ;
        int range = 15;
        List<EntityLiving> entities = player.world.getEntitiesWithinAABB(EntityLiving.class, new AxisAlignedBB(x - range, y - range, z - range, x + range, y + range, z + range));
        for (EntityLiving e : entities) {
            e.addPotionEffect(new PotionEffect(MobEffects.GLOWING, 25, 0, true, false));
        }
        player.addPotionEffect(new PotionEffect(MobEffects.NIGHT_VISION, 25, 0, true, false));
        useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_thirdEye, false, player);
    }
    if (stack.getTagCompound().getString("type").equalsIgnoreCase("fall") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_fall, player) || player.isCreative())) {
        useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_fall, false, player);
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Random(java.util.Random) PotionEffect(net.minecraft.potion.PotionEffect) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 28 with PotionEffect

use of net.minecraft.potion.PotionEffect in project Pearcel-Mod by MiningMark48.

the class ItemJeweledPearcel method onItemUseFinish.

@Override
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) {
    if (entityLiving instanceof EntityPlayer) {
        EntityPlayer entityplayer = (EntityPlayer) entityLiving;
        if (!entityplayer.isCreative()) {
            --stack.stackSize;
        }
        entityplayer.addPotionEffect(new PotionEffect(MobEffects.INVISIBILITY, 1500, 1));
        entityplayer.addPotionEffect(new PotionEffect(MobEffects.HASTE, 2000, 3));
        entityplayer.addPotionEffect(new PotionEffect(MobEffects.SATURATION, 3500, 0));
        entityplayer.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 5000, 3));
        entityplayer.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 5000, 2));
        entityplayer.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, 7000, 0));
        entityplayer.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, 7000, 5));
    }
    return stack;
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 29 with PotionEffect

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

the class EntityAISummonAllies method updateTask.

@Override
public void updateTask() {
    if (((IArsMagicaBoss) host).getCurrentAction() != BossActions.CASTING)
        ((IArsMagicaBoss) host).setCurrentAction(BossActions.CASTING);
    actionTicks++;
    if (actionTicks == 16) {
        if (!host.worldObj.isRemote)
            host.worldObj.playSoundAtEntity(host, "arsmagica2:mob.lifeguardian.summon", 1.0f, host.getRNG().nextFloat() * 0.5f + 0.5f);
        int numAllies = 3;
        for (int i = 0; i < numAllies; ++i) {
            Class summon = mobs[host.worldObj.rand.nextInt(mobs.length)];
            try {
                Constructor ctor = summon.getConstructor(World.class);
                EntityCreature mob = (EntityCreature) ctor.newInstance(host.worldObj);
                mob.setPosition(host.posX + host.worldObj.rand.nextDouble() * 2 - 1, host.posY, host.posZ + host.worldObj.rand.nextDouble() * 2 - 1);
                mob.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 99999, 1));
                mob.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 99999, 1));
                mob.addPotionEffect(new PotionEffect(Potion.regeneration.id, 99999, 1));
                mob.addPotionEffect(new BuffEffectMagicShield(99999, 1));
                if (host.getHealth() < host.getMaxHealth() / 2) {
                    mob.addPotionEffect(new BuffEffectShrink(99999, 1));
                }
                EntityUtilities.makeSummon_MonsterFaction(mob, false);
                EntityUtilities.setOwner(mob, host);
                EntityUtilities.setSummonDuration(mob, 1800);
                host.worldObj.spawnEntityInWorld(mob);
                host.queued_minions.add(mob);
            } catch (Throwable e) {
                e.printStackTrace();
                return;
            }
        }
    }
    if (actionTicks >= 23) {
        resetTask();
    }
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) Constructor(java.lang.reflect.Constructor) BuffEffectShrink(am2.buffs.BuffEffectShrink) BuffEffectMagicShield(am2.buffs.BuffEffectMagicShield) EntityCreature(net.minecraft.entity.EntityCreature)

Example 30 with PotionEffect

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

the class BuffEffectFury method stopEffect.

@Override
public void stopEffect(EntityLivingBase entityliving) {
    if (!entityliving.worldObj.isRemote) {
        AMCore.proxy.addDeferredPotionEffect(entityliving, new PotionEffect(Potion.hunger.id, 200, 1));
        AMCore.proxy.addDeferredPotionEffect(entityliving, new PotionEffect(Potion.confusion.id, 200, 1));
    }
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect)

Aggregations

PotionEffect (net.minecraft.potion.PotionEffect)95 EntityPlayer (net.minecraft.entity.player.EntityPlayer)28 EntityLivingBase (net.minecraft.entity.EntityLivingBase)21 ItemStack (net.minecraft.item.ItemStack)21 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)11 Fluid (net.minecraftforge.fluids.Fluid)9 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)8 BlockPos (net.minecraft.util.math.BlockPos)8 ModSimpleBaseFluid (eu.usrv.yamcore.fluids.ModSimpleBaseFluid)7 IBlockState (net.minecraft.block.state.IBlockState)7 Potion (net.minecraft.potion.Potion)7 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)7 ArrayList (java.util.ArrayList)6 NBTTagList (net.minecraft.nbt.NBTTagList)6 World (net.minecraft.world.World)6 ChemthrowerEffect_Potion (blusunrize.immersiveengineering.api.tool.ChemthrowerHandler.ChemthrowerEffect_Potion)4 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)4 Random (java.util.Random)4 Entity (net.minecraft.entity.Entity)4 EntityLiving (net.minecraft.entity.EntityLiving)4