Search in sources :

Example 1 with EntityLightningBolt

use of net.minecraft.entity.effect.EntityLightningBolt in project ImmersiveEngineering by BluSunrize.

the class TileEntityLightningrod method update.

@Override
public void update() {
    if (!worldObj.isRemote && formed && pos == 13) {
        if (energyStorage.getEnergyStored() > 0) {
            TileEntity tileEntity;
            for (EnumFacing f : EnumFacing.HORIZONTALS) {
                tileEntity = worldObj.getTileEntity(getPos().offset(f, 2));
                if (tileEntity instanceof IFluxReceiver) {
                    IFluxReceiver ifr = (IFluxReceiver) tileEntity;
                    int accepted = ifr.receiveEnergy(f.getOpposite(), energyStorage.getEnergyStored(), true);
                    int extracted = energyStorage.extractEnergy(accepted, false);
                    ifr.receiveEnergy(f.getOpposite(), extracted, false);
                }
            }
        }
        if (worldObj.getTotalWorldTime() % 256 == ((getPos().getX() ^ getPos().getZ()) & 255))
            fenceNet = null;
        if (fenceNet == null)
            fenceNet = this.getFenceNet();
        if (fenceNet != null && worldObj.getTotalWorldTime() % 128 == ((getPos().getX() ^ getPos().getZ()) & 127) && (worldObj.isThundering() || (worldObj.isRaining() && worldObj.rand.nextInt(10) == 0))) {
            int i = this.height + this.fenceNet.size();
            if (worldObj.rand.nextInt(4096 * worldObj.getHeight()) < i * (getPos().getY() + i)) {
                this.energyStorage.setEnergy(IEConfig.Machines.lightning_output);
                BlockPos pos = fenceNet.get(worldObj.rand.nextInt(fenceNet.size()));
                EntityLightningBolt entityLightningBolt = new EntityLightningBolt(worldObj, pos.getX(), pos.getY(), pos.getZ(), true);
                worldObj.addWeatherEffect(entityLightningBolt);
                worldObj.spawnEntityInWorld(entityLightningBolt);
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EnumFacing(net.minecraft.util.EnumFacing) IFluxReceiver(blusunrize.immersiveengineering.api.energy.immersiveflux.IFluxReceiver) BlockPos(net.minecraft.util.math.BlockPos) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt)

Example 2 with EntityLightningBolt

use of net.minecraft.entity.effect.EntityLightningBolt in project ArsMagica2 by Mithion.

the class AffinityHelper method onEntityHurt.

@SubscribeEvent
public void onEntityHurt(LivingHurtEvent event) {
    EntityLivingBase ent = event.entityLiving;
    AffinityData affinityData = AffinityData.For(ent);
    if (event.source.getSourceOfDamage() instanceof EntityPlayer) {
        float attackerFireDepth = AffinityData.For((EntityLivingBase) event.source.getSourceOfDamage()).getAffinityDepth(Affinity.FIRE);
        if (attackerFireDepth > 0.8f && ((EntityPlayer) event.source.getSourceOfDamage()).getCurrentEquippedItem() == null) {
            ent.setFire(4);
            event.ammount += 3;
        }
        float attackerLightningDepth = AffinityData.For((EntityLivingBase) event.source.getSourceOfDamage()).getAffinityDepth(Affinity.LIGHTNING);
        if (attackerLightningDepth > 0.75f && !ent.worldObj.isRemote && ((EntityPlayer) event.source.getSourceOfDamage()).getCurrentEquippedItem() == null) {
            EntityLightningBolt elb = new EntityLightningBolt(ent.worldObj, ent.posX, ent.posY, ent.posZ);
            elb.setPosition(ent.posX, ent.posY, ent.posZ);
            ent.worldObj.addWeatherEffect(elb);
        }
    }
    if (!(ent instanceof EntityPlayer))
        return;
    float earthDepth = affinityData.getAffinityDepth(Affinity.EARTH);
    if (earthDepth > 0.25f) {
        float reduction = 0.1f * earthDepth;
        event.ammount -= event.ammount * reduction;
    }
    float arcaneDepth = affinityData.getAffinityDepth(Affinity.ARCANE);
    if (arcaneDepth > 0.25f) {
        event.ammount *= 1.1f;
    }
    float waterDepth = affinityData.getAffinityDepth(Affinity.WATER);
    if (waterDepth > 0.9f && event.source.getSourceOfDamage() instanceof EntityEnderman) {
        event.source.getSourceOfDamage().attackEntityFrom(DamageSource.drown, 2);
    }
    float fireDepth = affinityData.getAffinityDepth(Affinity.FIRE);
    if (event.source.isFireDamage()) {
        float reduction = 1 - (0.6f * fireDepth);
        event.ammount = event.ammount * reduction;
    }
    float enderDepth = affinityData.getAffinityDepth(Affinity.ENDER);
    if (event.source == DamageSource.magic || event.source == DamageSource.wither) {
        float reduction = 1 - (0.75f * enderDepth);
        event.ammount = event.ammount * reduction;
    }
    if (event.source.getSourceOfDamage() instanceof EntityLivingBase) {
        float natureDepth = affinityData.getAffinityDepth(Affinity.NATURE);
        if (natureDepth == 1.0f) {
            ((EntityLivingBase) event.source.getSourceOfDamage()).attackEntityFrom(DamageSource.cactus, 3);
        } else if (natureDepth >= 0.75f) {
            ((EntityLivingBase) event.source.getSourceOfDamage()).attackEntityFrom(DamageSource.cactus, 2);
        } else if (natureDepth >= 0.5f) {
            ((EntityLivingBase) event.source.getSourceOfDamage()).attackEntityFrom(DamageSource.cactus, 1);
        }
        float iceDepth = affinityData.getAffinityDepth(Affinity.ICE);
        BuffEffectFrostSlowed effect = null;
        if (iceDepth == 1.0f) {
            effect = new BuffEffectFrostSlowed(200, 2);
        } else if (iceDepth >= 0.75f) {
            effect = new BuffEffectFrostSlowed(160, 1);
        } else if (iceDepth >= 0.5f) {
            effect = new BuffEffectFrostSlowed(100, 0);
        }
        if (effect != null) {
            ((EntityLivingBase) event.source.getSourceOfDamage()).addPotionEffect(effect);
        }
    }
    if (event.ammount == 0)
        event.setCanceled(true);
}
Also used : EntityLivingBase(net.minecraft.entity.EntityLivingBase) AffinityData(am2.playerextensions.AffinityData) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt) EntityEnderman(net.minecraft.entity.monster.EntityEnderman) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 3 with EntityLightningBolt

use of net.minecraft.entity.effect.EntityLightningBolt in project ArsMagica2 by Mithion.

the class Storm method applyEffect.

private void applyEffect(EntityLivingBase caster, World world) {
    float rainStrength = world.getRainStrength(1.0f);
    if (rainStrength > 0.9D) {
        if (!world.isRemote) {
            int xzradius = 50;
            int random = world.rand.nextInt(100);
            if (random < 20) {
                int randPosX = (int) caster.posX + world.rand.nextInt(xzradius * 2) - xzradius;
                int randPosZ = (int) caster.posZ + world.rand.nextInt(xzradius * 2) - xzradius;
                int posY = (int) caster.posY;
                while (!world.canBlockSeeTheSky(randPosX, posY, randPosZ)) {
                    posY++;
                }
                while (world.getBlock(randPosX, posY - 1, randPosZ) == Blocks.air) {
                    posY--;
                }
                EntityLightningBolt bolt = new EntityLightningBolt(world, randPosX, posY, randPosZ);
                world.addWeatherEffect(bolt);
            } else if (random < 80) {
                List<Entity> entities = world.getEntitiesWithinAABB(IMob.class, caster.boundingBox.expand(xzradius, 10D, xzradius));
                if (entities.size() <= 0) {
                    return;
                }
                Entity target = entities.get(world.rand.nextInt(entities.size()));
                if (target != null && world.canBlockSeeTheSky((int) target.posX, (int) target.posY, (int) target.posZ)) {
                    if (caster instanceof EntityPlayer) {
                        target.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) caster), 1);
                    }
                    EntityLightningBolt bolt = new EntityLightningBolt(world, target.posX, target.posY, target.posZ);
                    world.addWeatherEffect(bolt);
                }
            }
        }
    } else {
        if (!world.isRemote) {
            world.getWorldInfo().setRaining(true);
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) ParticleOrbitEntity(am2.particles.ParticleOrbitEntity) IMob(net.minecraft.entity.monster.IMob) EntityPlayer(net.minecraft.entity.player.EntityPlayer) List(java.util.List) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt)

Example 4 with EntityLightningBolt

use of net.minecraft.entity.effect.EntityLightningBolt in project Railcraft by Railcraft.

the class EntityAIHalloweenKnights method updateTask.

/**
     * Updates the task
     */
@Override
public void updateTask() {
    executed = true;
    DifficultyInstance difficultyinstance = horse.worldObj.getDifficultyForLocation(new BlockPos(horse));
    horse.setType(HorseType.SKELETON);
    horse.setHorseTamed(true);
    horse.setGrowingAge(0);
    horse.worldObj.addWeatherEffect(new EntityLightningBolt(horse.worldObj, horse.posX, horse.posY, horse.posZ, true));
    EntitySkeleton entityskeleton = createSkeleton(difficultyinstance, horse);
    entityskeleton.startRiding(horse);
    for (int i = 0; i < 3; ++i) {
        EntityHorse entityhorse = createHorse(difficultyinstance);
        EntitySkeleton skeleton = createSkeleton(difficultyinstance, entityhorse);
        skeleton.startRiding(entityhorse);
        entityhorse.addVelocity(horse.getRNG().nextGaussian() * 0.5D, 0.0D, horse.getRNG().nextGaussian() * 0.5D);
    }
}
Also used : EntityHorse(net.minecraft.entity.passive.EntityHorse) DifficultyInstance(net.minecraft.world.DifficultyInstance) EntitySkeleton(net.minecraft.entity.monster.EntitySkeleton) BlockPos(net.minecraft.util.math.BlockPos) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt)

Example 5 with EntityLightningBolt

use of net.minecraft.entity.effect.EntityLightningBolt in project SecurityCraft by Geforce132.

the class BlockIronFence method onEntityCollidedWithBlock.

public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
    //so dropped items don't get destroyed
    if (entity instanceof EntityItem)
        return;
    else //owner check
    if (entity instanceof EntityPlayer) {
        if (((TileEntityOwnable) world.getTileEntity(x, y, z)).getOwner().isOwner((EntityPlayer) entity))
            return;
    } else if (entity instanceof EntityCreeper) {
        EntityCreeper creeper = (EntityCreeper) entity;
        EntityLightningBolt lightning = new EntityLightningBolt(world, x, y, z);
        creeper.onStruckByLightning(lightning);
        creeper.extinguish();
        return;
    }
    //3 hearts per attack
    entity.attackEntityFrom(CustomDamageSources.electricity, 6.0F);
}
Also used : EntityCreeper(net.minecraft.entity.monster.EntityCreeper) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt) EntityItem(net.minecraft.entity.item.EntityItem) TileEntityOwnable(net.geforcemods.securitycraft.tileentity.TileEntityOwnable)

Aggregations

EntityLightningBolt (net.minecraft.entity.effect.EntityLightningBolt)18 EntityPlayer (net.minecraft.entity.player.EntityPlayer)9 EntityCreeper (net.minecraft.entity.monster.EntityCreeper)5 TileEntityOwnable (net.geforcemods.securitycraft.tileentity.TileEntityOwnable)4 EntityItem (net.minecraft.entity.item.EntityItem)4 BlockPos (net.minecraft.util.math.BlockPos)4 Random (java.util.Random)3 EntityLivingBase (net.minecraft.entity.EntityLivingBase)3 TextComponentString (net.minecraft.util.text.TextComponentString)3 Entity (net.minecraft.entity.Entity)2 EntityHorse (net.minecraft.entity.passive.EntityHorse)2 TileEntity (net.minecraft.tileentity.TileEntity)2 AMVector3 (am2.api.math.AMVector3)1 EntityLightningGuardian (am2.bosses.EntityLightningGuardian)1 ParticleOrbitEntity (am2.particles.ParticleOrbitEntity)1 AffinityData (am2.playerextensions.AffinityData)1 IFluxReceiver (blusunrize.immersiveengineering.api.energy.immersiveflux.IFluxReceiver)1 EntityPearcelBoss (com.miningmark48.pearcelmod.entity.EntityPearcelBoss)1 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 ArrayList (java.util.ArrayList)1