net.minecraft.entity.effect.EntityLightningBolt Java Examples

The following examples show how to use net.minecraft.entity.effect.EntityLightningBolt. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntityMage.java    From ToroQuest with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Attack the specified entity using a ranged attack.
 */
public void attackEntityWithRangedAttack(EntityLivingBase target, float p_82196_2_) {

	if (isDrinkingPotion()) {
		return;
	}

	int roll = rand.nextInt(100);

	setStaffAttacking(true);

	if (roll < 60) {
		attackWithPotion(target);

	} else if (roll < 90) {

		if (getDistanceSq(target) > 16 && rand.nextInt(100) > 60) {
			world.addWeatherEffect(new EntityLightningBolt(world, target.posX, target.posY, target.posZ, false));
		} else {
			attackWithForce(target);
		}

	} else {
		attackWithMobSpawn(target);
	}
}
 
Example #2
Source File: LexWand.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase target, EnumHand hand) {
	if (!player.world.isRemote) {
		BlockPos entityPos = target.getPosition();
		player.sendMessage(new TextComponentString(getBanMsg(target, player.world.rand)));
		target.world.addWeatherEffect(new EntityLightningBolt(target.world, entityPos.getX(), entityPos.getY(), entityPos.getZ(), false));
	}
	return true;
}
 
Example #3
Source File: ComponentLightning.java    From Artifacts with MIT License 5 votes vote down vote up
@Override
public boolean hitEntity(ItemStack itemStack, EntityLivingBase entityLivingHit, EntityLivingBase entityLivingPlayer) {
	if(!entityLivingPlayer.worldObj.isRemote && entityLivingPlayer instanceof EntityPlayer) {
		EntityLightningBolt entityLightningBolt = new EntityLightningBolt(entityLivingHit.worldObj, entityLivingHit.posX, entityLivingHit.posY, entityLivingHit.posZ);
		entityLivingHit.worldObj.addWeatherEffect(entityLightningBolt);
	}
	return false;
}
 
Example #4
Source File: TickHandlerPneumaticCraft.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
private void checkLightning(World world){
    if(world.isRemote) return;

    for(int i = 0; i < world.weatherEffects.size(); i++) {
        Entity entity = (Entity)world.weatherEffects.get(i);
        if(entity.ticksExisted == 1 && entity instanceof EntityLightningBolt) {
            handleElectrostaticGeneration(world, entity);
        }
    }
}
 
Example #5
Source File: BlockLightningPlant.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void executeFullGrownEffect(World world, int x, int y, int z, Random rand){
    if(!world.isRemote) {
        int j = MathHelper.floor_double(x) + rand.nextInt(20) - 10;
        int k = MathHelper.floor_double(z) + rand.nextInt(20) - 10;
        int l = world.getPrecipitationHeight(j, k);
        if(world.canLightningStrikeAt(j, l, k)) {
            EntityLightningBolt lightning = new EntityLightningBolt(world, j, l, k);
            world.addWeatherEffect(lightning);
            world.setBlockMetadataWithNotify(x, y, z, 11, 3);
        }
    }
}
 
Example #6
Source File: BlockElectricMushroom.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public void updateTick(World world, BlockPos pos, IBlockState state,
		Random rand) {
	if(!world.isRemote && Configuration.electricPlantsSpawnLightning && world.isRaining() && world.getBiome(pos) == AdvancedRocketryBiomes.stormLandsBiome) {
		int lightningX = pos.getX() + rand.nextInt(24) - 12;
		int lightningZ = pos.getZ() + rand.nextInt(24) - 12;
		BlockPos lightning = new BlockPos(lightningX, 0, lightningZ );
		lightning = world.getTopSolidOrLiquidBlock(lightning);
		
		world.addWeatherEffect(new EntityLightningBolt(world, lightning.getX(), lightning.getY(), lightning.getZ(), true));
	}
}
 
Example #7
Source File: Entity.java    From TickDynamic with MIT License 5 votes vote down vote up
/**
 * Called when a lightning bolt hits the entity.
 */
public void onStruckByLightning(EntityLightningBolt p_70077_1_)
{
    this.dealFireDamage(5);
    ++this.fire;

    if (this.fire == 0)
    {
        this.setFire(8);
    }
}
 
Example #8
Source File: Debug.java    From ehacks-pro with GNU General Public License v3.0 5 votes vote down vote up
public static List<int[]> getThorList(String filter) {
    ArrayList<int[]> nearCoords = new ArrayList<>();
    List<Entity> near = getNearEntities();
    for (Entity entity : near) {
        if (filter.equals("pl")) {
            if (entity == getPlayer() || !(entity instanceof EntityPlayer)) {
                continue;
            }
            nearCoords.add(getCoords(entity));
            continue;
        }
        if (filter.equals("ent")) {
            if (entity == getPlayer() || entity instanceof EntityLightningBolt) {
                continue;
            }
            nearCoords.add(getCoords(entity));
            continue;
        }
        EntityPlayer player = getPlayer(filter);
        if (player == null) {
            continue;
        }
        nearCoords.add(getCoords(player));
        break;
    }
    return nearCoords;
}
 
Example #9
Source File: LexWand.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void onAltarAction(World world, BlockPos pos) {
	List<Entity> entities = world.getEntitiesWithinAABB(EntityLivingBase.class, AOE.offset(pos));
	if (entities.isEmpty()) return;
		
	Entity entity = entities.get(world.rand.nextInt(entities.size()));
	
	world.getEntitiesWithinAABB(EntityPlayer.class, AOE.grow(6).offset(pos)).forEach((player) -> {
		player.sendMessage(new TextComponentString(getBanMsg(entity, world.rand)));
	});
	
	BlockPos entityPos = entity.getPosition();
	world.addWeatherEffect(new EntityLightningBolt(world, entityPos.getX(), entityPos.getY(), entityPos.getZ(), false));
}
 
Example #10
Source File: TransIconHerobrineButWithBetterPantsEntity.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor) {
    EntityLightningBolt lightning = new EntityLightningBolt(this.world, target.posX, target.posY, target.posZ, true);
    this.world.addWeatherEffect(lightning);

    target.attackEntityFrom(DamageSource.LIGHTNING_BOLT, 5.0F);

    this.dab(this.rand.nextBoolean() ? DabDirection.LEFT : DabDirection.RIGHT);

    this.navigator.clearPath();
}
 
Example #11
Source File: GTTileMultiLightningRod.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void update() {
	if (world.getTotalWorldTime() % 256 == 0 && world.rand.nextInt(chance) == 0) {
		if (world.isRaining() && (world.getPrecipitationHeight(pos).getY() <= (casingheight + 3))
				&& checkStructure()) {
			this.world.addWeatherEffect(new EntityLightningBolt(this.world, this.getPos().getX(), casingheight, this.getPos().getZ(), false));
			if (this.storage < this.maxStorage) {
				this.storage = Math.min(this.maxStorage, storage + 25000000);
				getNetwork().updateTileGuiField(this, "storage");
			}
		}
	}
	updateComparators();
	updateActive();
}
 
Example #12
Source File: GTItemTeslaStaff.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
	if (!(attacker instanceof EntityPlayer)) {
		return true;
	} else {
		if (ElectricItem.manager.canUse(stack, this.operationEnergyCost)) {
			attacker.world.addWeatherEffect(new EntityLightningBolt(attacker.world, target.lastTickPosX, target.lastTickPosY, target.lastTickPosZ, false));
			ElectricItem.manager.use(stack, this.operationEnergyCost, attacker);
		} else {
			target.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) attacker), 1.0F);
		}
		return false;
	}
}
 
Example #13
Source File: AuraEffects.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void doBlockEffect(ChunkCoordinates originTile, ChunkCoordinates selectedBlock, World world) {
    int highestY = world.getTopSolidOrLiquidBlock(selectedBlock.posX, selectedBlock.posZ);
    EntityLightningBolt entityLightning = new EntityLightningBolt(world, selectedBlock.posX + 0.5, highestY, selectedBlock.posZ + 0.5);
    world.addWeatherEffect(entityLightning);
}
 
Example #14
Source File: MixinRenderLightningBolt.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Inject(method = "doRender", at = @At("HEAD"), cancellable = true)
private void doRender(EntityLightningBolt entity, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo ci) {
    if (Settings.DISABLE_LIGHTNING) ci.cancel();
}
 
Example #15
Source File: ItemElectricThorHammer.java    From Electro-Magic-Tools with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) {
    if (player.capabilities.isCreativeMode) {
        return itemstack;
    } else if (ElectricItem.manager.canUse(itemstack, lightningCost)) {
        player.swingItem();
        // Corners
        world.spawnEntityInWorld(new EntityLightningBolt(world, player.posX + 8, player.posY, player.posZ - 8));
        world.spawnEntityInWorld(new EntityLightningBolt(world, player.posX - 8, player.posY, player.posZ + 8));
        world.spawnEntityInWorld(new EntityLightningBolt(world, player.posX - 8, player.posY, player.posZ - 8));
        world.spawnEntityInWorld(new EntityLightningBolt(world, player.posX + 8, player.posY, player.posZ + 8));

        // Fronts
        world.spawnEntityInWorld(new EntityLightningBolt(world, player.posX + 8, player.posY, player.posZ));
        world.spawnEntityInWorld(new EntityLightningBolt(world, player.posX - 8, player.posY, player.posZ));
        world.spawnEntityInWorld(new EntityLightningBolt(world, player.posX, player.posY, player.posZ - 8));
        world.spawnEntityInWorld(new EntityLightningBolt(world, player.posX, player.posY, player.posZ + 8));

        // Others
        world.spawnEntityInWorld(new EntityLightningBolt(world, player.posX + 8, player.posY, player.posZ + 1));
        world.spawnEntityInWorld(new EntityLightningBolt(world, player.posX - 8, player.posY, player.posZ + 2));
        world.spawnEntityInWorld(new EntityLightningBolt(world, player.posX + 8, player.posY, player.posZ + 3));
        world.spawnEntityInWorld(new EntityLightningBolt(world, player.posX - 8, player.posY, player.posZ + 4));

        world.spawnEntityInWorld(new EntityLightningBolt(world, player.posX + 8, player.posY, player.posZ - 1));
        world.spawnEntityInWorld(new EntityLightningBolt(world, player.posX - 8, player.posY, player.posZ - 2));
        world.spawnEntityInWorld(new EntityLightningBolt(world, player.posX + 8, player.posY, player.posZ - 3));
        world.spawnEntityInWorld(new EntityLightningBolt(world, player.posX - 8, player.posY, player.posZ - 4));

        world.spawnEntityInWorld(new EntityLightningBolt(world, player.posX + 1, player.posY, player.posZ + 8));
        world.spawnEntityInWorld(new EntityLightningBolt(world, player.posX + 2, player.posY, player.posZ - 8));
        world.spawnEntityInWorld(new EntityLightningBolt(world, player.posX + 3, player.posY, player.posZ + 8));
        world.spawnEntityInWorld(new EntityLightningBolt(world, player.posX + 4, player.posY, player.posZ - 8));

        world.spawnEntityInWorld(new EntityLightningBolt(world, player.posX - 1, player.posY, player.posZ + 8));
        world.spawnEntityInWorld(new EntityLightningBolt(world, player.posX - 2, player.posY, player.posZ - 8));
        world.spawnEntityInWorld(new EntityLightningBolt(world, player.posX - 3, player.posY, player.posZ + 8));
        world.spawnEntityInWorld(new EntityLightningBolt(world, player.posX - 4, player.posY, player.posZ - 8));

        EntityArcher archer;
        archer = new EntityArcher(world);
        archer.setPosition(player.posX + 8, player.posY + 2, player.posZ - 8);
        world.spawnEntityInWorld(archer);

        EntityArcher archer1;
        archer1 = new EntityArcher(world);
        archer1.setPosition(player.posX - 8, player.posY + 2, player.posZ + 8);
        world.spawnEntityInWorld(archer1);

        EntityArcher archer2;
        archer2 = new EntityArcher(world);
        archer2.setPosition(player.posX - 8, player.posY + 2, player.posZ - 8);
        world.spawnEntityInWorld(archer2);

        EntityArcher archer3;
        archer3 = new EntityArcher(world);
        archer3.setPosition(player.posX + 8, player.posY + 2, player.posZ + 8);
        world.spawnEntityInWorld(archer3);
        ElectricItem.manager.use(itemstack, lightningCost, player);
        return itemstack;
    } else {
        world.spawnEntityInWorld(new EntityLightningBolt(world, player.posX, player.posY, player.posZ));
        player.addPotionEffect(new PotionEffect(Potion.harm.getId(), 1, 1));
        return itemstack;
    }
}
 
Example #16
Source File: ItemMaterials.java    From Electro-Magic-Tools with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
    if (stack != null && stack.getItemDamage() == 6) {
        player.swingItem();
        float f = 1.0F;
        float f1 = player.prevRotationPitch + ((player.rotationPitch - player.prevRotationPitch) * f);
        float f2 = player.prevRotationYaw + ((player.rotationYaw - player.prevRotationYaw) * f);
        double d = player.prevPosX + ((player.posX - player.prevPosX) * f);
        double d1 = (player.prevPosY + ((player.posY - player.prevPosY) * f) + 1.6200000000000001D) - player.yOffset;
        double d2 = player.prevPosZ + ((player.posZ - player.prevPosZ) * f);
        Vec3 vec3d = Vec3.createVectorHelper(d, d1, d2);
        float f3 = MathHelper.cos((-f2 * 0.01745329F) - 3.141593F);
        float f4 = MathHelper.sin((-f2 * 0.01745329F) - 3.141593F);
        float f5 = -MathHelper.cos(-f1 * 0.01745329F);
        float f6 = MathHelper.sin(-f1 * 0.01745329F);
        float f7 = f4 * f5;
        float f8 = f6;
        float f9 = f3 * f5;
        double d3 = 5000D;
        Vec3 vec3d1 = vec3d.addVector(f7 * d3, f8 * d3, f9 * d3);
        MovingObjectPosition movingobjectposition = player.worldObj.rayTraceBlocks(vec3d, vec3d1, true);
        if (movingobjectposition == null) {
            return stack;
        }
        if (movingobjectposition.typeOfHit == MovingObjectType.BLOCK) {
            int i = movingobjectposition.blockX;
            int j = movingobjectposition.blockY;
            int k = movingobjectposition.blockZ;
            world.spawnEntityInWorld(new EntityLightningBolt(world, i, j, k));
        } else if (movingobjectposition.typeOfHit == MovingObjectType.ENTITY) {
            Entity entityhit = movingobjectposition.entityHit;
            double x = entityhit.posX;
            double y = entityhit.posY;
            double z = entityhit.posZ;
            world.spawnEntityInWorld(new EntityLightningBolt(world, x, y, z));
        }
        if (player.capabilities.isCreativeMode) {
            return stack;
        } else {
            player.inventory.consumeInventoryItem(this);
            return stack;
        }
    }
    return stack;
}
 
Example #17
Source File: ItemThorHammer.java    From Electro-Magic-Tools with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) {
    player.swingItem();
    float f = 1.0F;
    float f1 = player.prevRotationPitch + ((player.rotationPitch - player.prevRotationPitch) * f);
    float f2 = player.prevRotationYaw + ((player.rotationYaw - player.prevRotationYaw) * f);
    double d = player.prevPosX + ((player.posX - player.prevPosX) * f);
    double d1 = (player.prevPosY + ((player.posY - player.prevPosY) * f) + 1.6200000000000001D) - player.yOffset;
    double d2 = player.prevPosZ + ((player.posZ - player.prevPosZ) * f);
    Vec3 vec3d = Vec3.createVectorHelper(d, d1, d2);
    float f3 = MathHelper.cos((-f2 * 0.01745329F) - 3.141593F);
    float f4 = MathHelper.sin((-f2 * 0.01745329F) - 3.141593F);
    float f5 = -MathHelper.cos(-f1 * 0.01745329F);
    float f6 = MathHelper.sin(-f1 * 0.01745329F);
    float f7 = f4 * f5;
    float f8 = f6;
    float f9 = f3 * f5;
    double d3 = 5000D;
    Vec3 vec3d1 = vec3d.addVector(f7 * d3, f8 * d3, f9 * d3);
    MovingObjectPosition movingobjectposition = player.worldObj.rayTraceBlocks(vec3d, vec3d1, true);
    if (movingobjectposition == null) {
        return itemstack;
    }
    if (movingobjectposition.typeOfHit == MovingObjectType.BLOCK) {
        int i = movingobjectposition.blockX;
        int j = movingobjectposition.blockY;
        int k = movingobjectposition.blockZ;
        world.spawnEntityInWorld(new EntityLightningBolt(world, i, j, k));
    } else if (movingobjectposition.typeOfHit == MovingObjectType.ENTITY) {
        Entity entityhit = movingobjectposition.entityHit;
        double x = entityhit.posX;
        double y = entityhit.posY;
        double z = entityhit.posZ;
        world.spawnEntityInWorld(new EntityLightningBolt(world, x, y, z));
    }
    if (player.capabilities.isCreativeMode) {
        return itemstack;
    } else {
        itemstack.damageItem(20, player);
        return itemstack;
    }
}
 
Example #18
Source File: CraftLightningStrike.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public EntityLightningBolt getHandle() {
    return (EntityLightningBolt) entity;
}
 
Example #19
Source File: EntityCamera.java    From LookingGlass with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onStruckByLightning(EntityLightningBolt par1) {}
 
Example #20
Source File: CraftLightningStrike.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public CraftLightningStrike(final CraftServer server, final EntityLightningBolt entity) {
    super(server, entity);
}
 
Example #21
Source File: CraftLightningStrike.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public boolean isEffect() {
    return ((EntityLightningBolt) super.getHandle()).isEffect;
}
 
Example #22
Source File: CraftWorld.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public LightningStrike strikeLightningEffect(Location loc, boolean isSilent) {
    EntityLightningBolt lightning = new EntityLightningBolt(world, loc.getX(), loc.getY(), loc.getZ(), true, isSilent);
    world.addWeatherEffect(lightning);
    return new CraftLightningStrike(server, lightning);
}
 
Example #23
Source File: CraftWorld.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public LightningStrike strikeLightning(Location loc, boolean isSilent) {
    EntityLightningBolt lightning = new EntityLightningBolt(world, loc.getX(), loc.getY(), loc.getZ(), false, isSilent);
    world.addWeatherEffect(lightning);
    return new CraftLightningStrike(server, lightning);
}
 
Example #24
Source File: CraftWorld.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public LightningStrike strikeLightningEffect(Location loc) {
    EntityLightningBolt lightning = new EntityLightningBolt(world, loc.getX(), loc.getY(), loc.getZ(), true);
    world.addWeatherEffect(lightning);
    return new CraftLightningStrike(server, lightning);
}
 
Example #25
Source File: CraftWorld.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public LightningStrike strikeLightning(Location loc) {
    EntityLightningBolt lightning = new EntityLightningBolt(world, loc.getX(), loc.getY(), loc.getZ(), false);
    world.addWeatherEffect(lightning);
    return new CraftLightningStrike(server, lightning);
}