Search in sources :

Example 36 with PotionEffect

use of net.minecraft.potion.PotionEffect in project NetherEx by LogicTechCorp.

the class ExplosionSpore method doExplosionA.

@Override
public void doExplosionA() {
    if (!world.isRemote) {
        Set<BlockPos> set = Sets.newHashSet();
        for (int j = 0; j < 16; ++j) {
            for (int k = 0; k < 16; ++k) {
                for (int l = 0; l < 16; ++l) {
                    if (j == 0 || j == 15 || k == 0 || k == 15 || l == 0 || l == 15) {
                        double d0 = (double) ((float) j / 15.0F * 2.0F - 1.0F);
                        double d1 = (double) ((float) k / 15.0F * 2.0F - 1.0F);
                        double d2 = (double) ((float) l / 15.0F * 2.0F - 1.0F);
                        double d3 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
                        d0 = d0 / d3;
                        d1 = d1 / d3;
                        d2 = d2 / d3;
                        float f = explosionSize * (0.7F + world.rand.nextFloat() * 0.6F);
                        double d4 = explosionX;
                        double d6 = explosionY;
                        double d8 = explosionZ;
                        for (float f1 = 0.3F; f > 0.0F; f -= 0.22500001F) {
                            BlockPos blockpos = new BlockPos(d4, d6, d8);
                            IBlockState iblockstate = world.getBlockState(blockpos);
                            if (iblockstate.getMaterial() != Material.AIR) {
                                float f2 = exploder != null ? exploder.getExplosionResistance(this, world, blockpos, iblockstate) : iblockstate.getBlock().getExplosionResistance(world, blockpos, (Entity) null, this);
                                f -= (f2 + 0.3F) * 0.3F;
                            }
                            if (f > 0.0F && (exploder == null || exploder.verifyExplosion(this, world, blockpos, iblockstate, f))) {
                                set.add(blockpos);
                            }
                            d4 += d0 * 0.30000001192092896D;
                            d6 += d1 * 0.30000001192092896D;
                            d8 += d2 * 0.30000001192092896D;
                        }
                    }
                }
            }
        }
        affectedBlockPositions.addAll(set);
        float f3 = explosionSize * 2.0F;
        int k1 = MathHelper.floor(explosionX - (double) f3 - 1.0D);
        int l1 = MathHelper.floor(explosionX + (double) f3 + 1.0D);
        int i2 = MathHelper.floor(explosionY - (double) f3 - 1.0D);
        int i1 = MathHelper.floor(explosionY + (double) f3 + 1.0D);
        int j2 = MathHelper.floor(explosionZ - (double) f3 - 1.0D);
        int j1 = MathHelper.floor(explosionZ + (double) f3 + 1.0D);
        List<Entity> list = world.getEntitiesWithinAABBExcludingEntity(exploder, new AxisAlignedBB((double) k1, (double) i2, (double) j2, (double) l1, (double) i1, (double) j1));
        ForgeEventFactory.onExplosionDetonate(world, this, list, f3);
        Vec3d vec3d = new Vec3d(explosionX, explosionY, explosionZ);
        for (Entity entity : list) {
            if (!entity.isImmuneToExplosions()) {
                double d12 = entity.getDistance(explosionX, explosionY, explosionZ) / (double) f3;
                if (d12 <= 1.0D) {
                    double d5 = entity.posX - explosionX;
                    double d7 = entity.posY + (double) entity.getEyeHeight() - explosionY;
                    double d9 = entity.posZ - explosionZ;
                    double d13 = (double) MathHelper.sqrt(d5 * d5 + d7 * d7 + d9 * d9);
                    if (d13 != 0.0D) {
                        d5 = d5 / d13;
                        d7 = d7 / d13;
                        d9 = d9 / d13;
                        double d14 = (double) world.getBlockDensity(vec3d, entity.getEntityBoundingBox());
                        double d10 = (1.0D - d12) * d14;
                        if (!(entity instanceof EntitySporeCreeper) && !(entity instanceof EntitySpore)) {
                            entity.attackEntityFrom(DamageSource.causeExplosionDamage(this), (float) ((int) ((d10 * d10 + d10) / 2.0D * 7.0D * (double) f3 + 1.0D)));
                        }
                        if (entity instanceof EntityLivingBase) {
                            ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(NetherExEffects.SPORE, 2400, 0));
                        }
                        double d11 = d10;
                        if (entity instanceof EntityLivingBase) {
                            d11 = EnchantmentProtection.getBlastDamageReduction((EntityLivingBase) entity, d10);
                        }
                        entity.motionX += d5 * d11;
                        entity.motionY += d7 * d11;
                        entity.motionZ += d9 * d11;
                        if (entity instanceof EntityPlayer) {
                            EntityPlayer entityplayer = (EntityPlayer) entity;
                            if (!entityplayer.isSpectator() && (!entityplayer.isCreative() || !entityplayer.capabilities.isFlying)) {
                                playerKnockbackMap.put(entityplayer, new Vec3d(d5 * d10, d7 * d10, d9 * d10));
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity) EntitySpore(nex.entity.monster.EntitySpore) IBlockState(net.minecraft.block.state.IBlockState) PotionEffect(net.minecraft.potion.PotionEffect) EntitySporeCreeper(nex.entity.monster.EntitySporeCreeper) Vec3d(net.minecraft.util.math.Vec3d) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos)

Example 37 with PotionEffect

use of net.minecraft.potion.PotionEffect in project RealisticArmorTiers by IsakViste.

the class EventEquipmentGlobalVar method addSetEffectsArmour.

public void addSetEffectsArmour(PlayerTickEvent evt) {
    if (this.isFullSet()) {
        int i = 0;
        while (i < effects.size()) {
            evt.player.addPotionEffect(new PotionEffect(Potion.getPotionById(effects.get(i).effect), global.getPotionDur(), effects.get(i).efficiency));
            i++;
        }
    }
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect)

Example 38 with PotionEffect

use of net.minecraft.potion.PotionEffect in project BetterWithAddons by DaedalusGame.

the class ButcherHandler method playerTick.

@SubscribeEvent
public void playerTick(AttackEntityEvent attackEvent) {
    Entity target = attackEvent.getTarget();
    EntityLivingBase attacker = attackEvent.getEntityLiving();
    if (attacker == null || target == null)
        return;
    World world = attacker.getEntityWorld();
    BlockPos pos = EntityUtil.getEntityFloor(target, 2);
    if (!world.isRemote) {
        IBlockState state = world.getBlockState(pos);
        if (isChopBlock(state) && isSuitableWeapon(attacker.getHeldItemMainhand())) {
            attacker.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, 200));
            attacker.addPotionEffect(new PotionEffect(MobEffects.HUNGER, 200));
            splatter(world, pos, 1);
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) IBlockState(net.minecraft.block.state.IBlockState) PotionEffect(net.minecraft.potion.PotionEffect) EntityLivingBase(net.minecraft.entity.EntityLivingBase) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 39 with PotionEffect

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

the class OvenGlove method onWornTick.

@Override
public void onWornTick(ItemStack arg0, EntityLivingBase pEntity) {
    try {
        if (!(pEntity instanceof EntityPlayer))
            return;
        if (// MetaItem 0 is running this loop only
        arg0.getItemDamage() == 1)
            return;
        EntityPlayer tPlayer = (EntityPlayer) pEntity;
        InventoryBaubles tBaubles = baubles.common.lib.PlayerHandler.getPlayerBaubles(tPlayer);
        if (// no fire/lava cheat!
        tPlayer.isBurning()) {
            if (isGlovesResistActive(tPlayer))
                RemoveFireProtection(pEntity);
            return;
        }
        if (_mRnd.nextInt(20) == 0) {
            // Player must wear OvenGloves in both slots
            ItemStack tBaubleRing1 = tBaubles.stackList[1];
            ItemStack tBaubleRing2 = tBaubles.stackList[2];
            if (tBaubleRing1 == null || tBaubleRing2 == null) {
                // Log("Bauble 1 or 2 is null");
                return;
            }
            if (tBaubleRing1.getUnlocalizedName().contains(_mItemName) && tBaubleRing2.getUnlocalizedName().contains(_mItemName)) {
                if (tBaubleRing1.getItemDamage() != 0 || tBaubleRing2.getItemDamage() != 1) {
                    if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
                        if (!WrongSidePopupShown) {
                            WrongSidePopupShown = true;
                            eu.usrv.yamcore.client.Notification noti = new eu.usrv.yamcore.client.Notification(tBaubleRing1, "Wrong place", "The gloves feel weird...");
                            NotificationTickHandler.guiNotification.queueNotification(noti);
                        }
                    }
                    // Log("Gloves in wrong spots");
                    return;
                }
                if (// Cheated gloves don't have NBT tags sometimes
                tBaubleRing1.stackTagCompound == null || tBaubleRing2.stackTagCompound == null)
                    return;
                if (tBaubleRing1.stackTagCompound.getInteger(NBTTAG_DURABILITY) <= 1 || tBaubleRing2.stackTagCompound.getInteger(NBTTAG_DURABILITY) <= 1)
                    return;
                ItemStack tHeldItem = tPlayer.getCurrentEquippedItem();
                if (tHeldItem != null) {
                    // Update 12.01.2017: Player must hold any item containing Lava
                    if (isValidLavaContainerItem(tHeldItem)) {
                        if (!isResistActive(tPlayer) || isGlovesResistActive(tPlayer)) {
                            tPlayer.addPotionEffect(new PotionEffect(Potion.fireResistance.id, potionDuration, potionAmplifier, potionAmbient));
                            // Randomly damage gloves while giving the protection effect
                            int tRandomDamage = _mRnd.nextInt(10);
                            if (tRandomDamage == 1)
                                DamageItem(tBaubleRing1);
                            else if (tRandomDamage == 2)
                                DamageItem(tBaubleRing2);
                        }
                    }
                }
            }
        }
    } catch (// Fail-safe for all future crashes
    Exception e) {
        e.printStackTrace();
    }
}
Also used : InventoryBaubles(baubles.common.container.InventoryBaubles) PotionEffect(net.minecraft.potion.PotionEffect) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack)

Example 40 with PotionEffect

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

the class ExtendedFluidCollection method populateCompressedNitrogen.

private static void populateCompressedNitrogen() {
    Fluid tCompressedNitrogenFluid = ModFluidManager.GetNewFluid("CompressedNitrogen");
    tCompressedNitrogenFluid.setGaseous(true);
    tCompressedNitrogenFluid.setViscosity(1);
    tCompressedNitrogenFluid.setDensity(1);
    tCompressedNitrogenFluid.setLuminosity(0);
    tCompressedNitrogenFluid.setTemperature(295);
    // The rarity of the fluid. Used primarily in tool tips.
    tCompressedNitrogenFluid.setRarity(EnumRarity.epic);
    _mCompressedNitrogen = new ModSimpleBaseFluid(tCompressedNitrogenFluid, Material.water);
    // Add potion effects to the fluid if player steps into a pool
    // Syntax is: new PotionEffect(<potionID>, <duration in ticks>, <level>)
    // Level 0: Potion Level I
    // Level 1: Potion Level II
    // ...
    // For the duration: Set it low to vanish the effect as soon as the player leaves the pool
    // If you set the duration to 200, the potion timer will start to tick for 10 seconds after
    // the player has left the pool.
    _mCompressedNitrogen.addPotionEffect(new PotionEffect(Potion.weakness.id, 20, 3));
    // Same for stacking potion effects, except that you want to set the duration to the amount which will be
    // ADDED about each 0,5 seconds. So this poison-effect will increase as long as the player has contact with the
    // fluid block
    _mCompressedNitrogen.addStackingPotionEffect(new PotionEffect(Potion.weakness.id, 20, 3));
    // don't register a bucket
    _mCompressedNitrogen.setRegisterBucket(false);
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) ModSimpleBaseFluid(eu.usrv.yamcore.fluids.ModSimpleBaseFluid) Fluid(net.minecraftforge.fluids.Fluid) ModSimpleBaseFluid(eu.usrv.yamcore.fluids.ModSimpleBaseFluid)

Aggregations

PotionEffect (net.minecraft.potion.PotionEffect)135 EntityLivingBase (net.minecraft.entity.EntityLivingBase)43 EntityPlayer (net.minecraft.entity.player.EntityPlayer)41 ItemStack (net.minecraft.item.ItemStack)27 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)19 BlockPos (net.minecraft.util.math.BlockPos)17 Entity (net.minecraft.entity.Entity)12 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)12 World (net.minecraft.world.World)12 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)12 IBlockState (net.minecraft.block.state.IBlockState)11 Potion (net.minecraft.potion.Potion)9 Fluid (net.minecraftforge.fluids.Fluid)9 ArrayList (java.util.ArrayList)8 ModSimpleBaseFluid (eu.usrv.yamcore.fluids.ModSimpleBaseFluid)7 WorldServer (net.minecraft.world.WorldServer)7 Random (java.util.Random)6 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)6 NBTTagList (net.minecraft.nbt.NBTTagList)6 TileEntity (net.minecraft.tileentity.TileEntity)6