Search in sources :

Example 11 with EntityLightningBolt

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

the class BlockReinforcedFenceGate method onEntityIntersected.

@Override
public void onEntityIntersected(World world, BlockPos pos, Entity entity) {
    if (BlockUtils.getBlockPropertyAsBoolean(world, pos, OPEN)) {
        return;
    }
    if (entity instanceof EntityItem)
        return;
    else if (entity instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) entity;
        if (((TileEntityOwnable) world.getTileEntity(pos)).getOwner().isOwner(player))
            return;
    } else if (entity instanceof EntityCreeper) {
        EntityCreeper creeper = (EntityCreeper) entity;
        EntityLightningBolt lightning = new EntityLightningBolt(world, pos.getX(), pos.getY(), pos.getZ(), true);
        creeper.onStruckByLightning(lightning);
        return;
    }
    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)

Example 12 with EntityLightningBolt

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

the class BlockReinforcedFenceGate method onEntityCollidedWithBlock.

public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
    if (world.getBlockMetadata(x, y, z) > 3)
        return;
    //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)

Example 13 with EntityLightningBolt

use of net.minecraft.entity.effect.EntityLightningBolt in project Pearcel-Mod by MiningMark48.

the class ItemGuardianFood method onFoodEaten.

@Override
protected void onFoodEaten(ItemStack stack, World world, EntityPlayer player) {
    BlockPos pos = player.getPosition();
    int x = pos.getX();
    int y = pos.getY();
    int z = pos.getZ();
    Random rand = new Random();
    int num = rand.nextInt(5) + 10;
    int range = 25;
    List<EntityPlayer> players = world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(x - range, y - range, z - range, x + range, y + range, z + range));
    if (!world.isRemote) {
        EntityPearcelBoss pb = new EntityPearcelBoss(world);
        pb.setPosition(x, y + num, z);
        world.spawnEntity(new EntityLightningBolt(world, x, y, z, true));
        world.spawnEntity(pb);
        for (EntityPlayer e : players) {
            e.sendMessage(new TextComponentString(TextFormatting.GREEN + Translate.toLocal("chat.item.guardian_food.summoned")));
        }
    }
    world.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, x + 0.5, y + num + 0.5, z + 0.5, 1.0D, 0.0D, 0.0D);
    for (EntityPlayer e : players) {
        e.playSound(ModSoundEvents.MOB_PEARCEL_BOSS_LAUGH, 5.0F, 1.0F);
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Random(java.util.Random) EntityPearcelBoss(com.miningmark48.pearcelmod.entity.EntityPearcelBoss) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 14 with EntityLightningBolt

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

the class TileEntityKeystoneRecepticle method updateEntity.

@Override
public void updateEntity() {
    super.updateEntity();
    AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(xCoord + 0.3, yCoord - 3, zCoord + 0.3, xCoord + 0.7, yCoord, zCoord + 0.7);
    ArrayList<Entity> entities = (ArrayList<Entity>) worldObj.getEntitiesWithinAABB(EntityLivingBase.class, bb);
    if (this.isActive) {
        surroundingCheckTicks--;
        if (surroundingCheckTicks <= 0) {
            surroundingCheckTicks = 20;
            checkSurroundings();
        }
        if (entities.size() == 1) {
            doTeleport(entities.get(0));
        }
    } else {
        if (entities.size() == 1 && worldObj.canBlockSeeTheSky(xCoord, yCoord, zCoord)) {
            Entity entity = entities.get(0);
            if (entity instanceof EntityPlayer) {
                EntityPlayer player = (EntityPlayer) entity;
                if (player.isPotionActive(BuffList.haste) && player.isPotionActive(Potion.moveSpeed.id) && player.isSprinting()) {
                    //if (worldObj.isRemote)
                    //player.addStat(AMCore.achievements.EightyEightMilesPerHour, 1);
                    this.key = 0;
                    if (!worldObj.isRemote) {
                        EntityLightningBolt elb = new EntityLightningBolt(worldObj, xCoord, yCoord, zCoord);
                        worldObj.spawnEntityInWorld(elb);
                    }
                    doTeleport(player);
                }
            }
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) S35PacketUpdateTileEntity(net.minecraft.network.play.server.S35PacketUpdateTileEntity) Entity(net.minecraft.entity.Entity) ArrayList(java.util.ArrayList) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt)

Example 15 with EntityLightningBolt

use of net.minecraft.entity.effect.EntityLightningBolt in project Pearcel-Mod by MiningMark48.

the class BlockSummoner method onBlockActivated.

public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
    Random rand = new Random();
    int spawnRand = rand.nextInt(5) + 1;
    int negRand = rand.nextInt(2) + 1;
    int x = pos.getX();
    int y = pos.getY();
    int z = pos.getZ();
    if (negRand == 1) {
        spawnRand = -spawnRand;
    }
    EntitySheep sheep = new EntitySheep(world);
    sheep.setPosition(x + spawnRand, y + 2, z + spawnRand);
    EntityEnderman enderman = new EntityEnderman(world);
    enderman.setPosition(x + spawnRand, y + 2, z + spawnRand);
    EntityBlaze blaze = new EntityBlaze(world);
    blaze.setPosition(x + spawnRand, y + 2, z + spawnRand);
    EntityGhast ghast = new EntityGhast(world);
    ghast.setPosition(x + spawnRand, y + 5, z + spawnRand);
    EntitySkeleton skeleton = new EntitySkeleton(world);
    skeleton.setPosition(x + spawnRand, y + 2, z + spawnRand);
    EntityCreeper creeper = new EntityCreeper(world);
    creeper.setPosition(x + spawnRand, y + 2, z + spawnRand);
    EntityEnderCrystal endcrystal = new EntityEnderCrystal(world);
    endcrystal.setPosition(x + spawnRand, y + 2, z + spawnRand);
    EntityHorse horse = new EntityHorse(world);
    horse.setPosition(x + spawnRand, y + 2, z + spawnRand);
    EntityIronGolem iron_golem = new EntityIronGolem(world);
    iron_golem.setPosition(x + spawnRand, y + 2, z + spawnRand);
    EntityVillager villager = new EntityVillager(world);
    villager.setPosition(x + spawnRand, y + 2, z + spawnRand);
    EntityDragon dragon = new EntityDragon(world);
    dragon.setPosition(x + spawnRand, y + 2, z + spawnRand);
    EntityWither wither = new EntityWither(world);
    wither.setPosition(x + spawnRand, y + 2, z + spawnRand);
    if (player.getHeldItem(EnumHand.MAIN_HAND) != null) {
        if (!player.isSneaking() && player.getHeldItem(EnumHand.MAIN_HAND).getItem() == ModItems.sap) {
            if (!world.isRemote) {
                //Missing Block
                if (world.getBlockState(pos.up()).getBlock() == Blocks.AIR) {
                    player.sendMessage(new TextComponentString(TextFormatting.DARK_RED + Translate.toLocal("summoner.error.missingBlock")));
                    if (world.isRemote) {
                        world.spawnEntity(new EntityLightningBolt(world, player.posX, player.posY, player.posZ, true));
                    }
                } else //Dragon
                if (isCorrectSetup(pos, world, Blocks.DRAGON_EGG, Blocks.DIAMOND_BLOCK)) {
                    if (player.dimension == 1) {
                        setTainted(pos, world);
                        world.spawnEntity(dragon);
                        player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.dragon") + " " + Translate.toLocal("summoner.summoned")));
                    } else {
                        player.sendMessage(new TextComponentString(TextFormatting.DARK_RED + Translate.toLocal("summoner.error.wrongDimension")));
                    }
                } else //Wither
                if (isCorrectSetup(pos, world, Blocks.SKULL, Blocks.DIAMOND_BLOCK)) {
                    setTainted(pos, world);
                    world.spawnEntity(wither);
                    player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.wither") + " " + Translate.toLocal("summoner.summoned")));
                } else //Sheep
                if (isCorrectSetup(pos, world, Blocks.WOOL, Blocks.WOOL)) {
                    setTainted(pos, world);
                    world.spawnEntity(sheep);
                    player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.sheep") + " " + Translate.toLocal("summoner.summoned")));
                } else //Enderman
                if (isCorrectSetup(pos, world, Blocks.END_STONE, Blocks.END_STONE)) {
                    setTainted(pos, world);
                    world.spawnEntity(enderman);
                    player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.enderman") + " " + Translate.toLocal("summoner.summoned")));
                } else //Blaze
                if (isCorrectSetup(pos, world, Blocks.GRAVEL, Blocks.NETHERRACK)) {
                    setTainted(pos, world);
                    world.spawnEntity(blaze);
                    player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.blaze") + " " + Translate.toLocal("summoner.summoned")));
                } else //Ghast
                if (isCorrectSetup(pos, world, Blocks.COBBLESTONE, Blocks.SOUL_SAND)) {
                    setTainted(pos, world);
                    world.spawnEntity(ghast);
                    player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.ghast") + " " + Translate.toLocal("summoner.summoned")));
                } else //Skeleton
                if (isCorrectSetup(pos, world, Blocks.PLANKS, Blocks.SAND)) {
                    setTainted(pos, world);
                    world.spawnEntity(skeleton);
                    player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.skeleton") + " " + Translate.toLocal("summoner.summoned")));
                } else //Creeper
                if (isCorrectSetup(pos, world, Blocks.TNT, Blocks.TNT)) {
                    setTainted(pos, world);
                    world.spawnEntity(creeper);
                    player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.creeper") + " " + Translate.toLocal("summoner.summoned")));
                } else //Horse
                if (isCorrectSetup(pos, world, Blocks.HAY_BLOCK, Blocks.HAY_BLOCK)) {
                    setTainted(pos, world);
                    world.spawnEntity(horse);
                    player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.horse") + " " + Translate.toLocal("summoner.summoned")));
                } else //Iron Golem
                if (isCorrectSetup(pos, world, Blocks.IRON_BLOCK, Blocks.IRON_BLOCK)) {
                    setTainted(pos, world);
                    world.spawnEntity(iron_golem);
                    player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.iron_golem") + " " + Translate.toLocal("summoner.summoned")));
                } else //Villager
                if (isCorrectSetup(pos, world, Blocks.EMERALD_BLOCK, Blocks.SKULL)) {
                    setTainted(pos, world);
                    world.spawnEntity(villager);
                    player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.villager") + " " + Translate.toLocal("summoner.summoned")));
                } else {
                    if (!world.isRemote) {
                        setTainted(pos, world);
                        player.sendMessage(new TextComponentString(TextFormatting.DARK_RED + Translate.toLocal("summoner.error.incorrectBlock")));
                    }
                    if (world.isRemote) {
                        world.spawnEntity(new EntityLightningBolt(world, player.posX, player.posY, player.posZ, true));
                    }
                }
            }
            player.playSound(ModSoundEvents.BLOCK_SUMMONER_LAUGH, 5.0F, 1.0F);
            world.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, x, y, z, 1.0D, 0.0D, 0.0D);
            if (!player.isCreative()) {
                player.getHeldItem(EnumHand.MAIN_HAND).damageItem(1, player);
                player.attackEntityFrom(DamageSource.outOfWorld, 10.0F);
            }
        } else {
            if (!world.isRemote) {
                player.sendMessage(new TextComponentString(TextFormatting.DARK_RED + Translate.toLocal("summoner.error.incorrectItem")));
            }
        }
    }
    return true;
}
Also used : EntityDragon(net.minecraft.entity.boss.EntityDragon) EntityEnderCrystal(net.minecraft.entity.item.EntityEnderCrystal) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt) TextComponentString(net.minecraft.util.text.TextComponentString) EntityHorse(net.minecraft.entity.passive.EntityHorse) Random(java.util.Random) EntityVillager(net.minecraft.entity.passive.EntityVillager) EntitySheep(net.minecraft.entity.passive.EntitySheep) EntityWither(net.minecraft.entity.boss.EntityWither)

Aggregations

EntityLightningBolt (net.minecraft.entity.effect.EntityLightningBolt)20 EntityPlayer (net.minecraft.entity.player.EntityPlayer)11 EntityCreeper (net.minecraft.entity.monster.EntityCreeper)7 EntityItem (net.minecraft.entity.item.EntityItem)6 TileEntityOwnable (net.geforcemods.securitycraft.tileentity.TileEntityOwnable)5 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