Java Code Examples for net.minecraft.world.World.getLightFor()

The following are Jave code examples for showing how to use getLightFor() of the net.minecraft.world.World class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: DecompiledMinecraft   File: BlockDaylightDetector.java   Source Code and License Vote up 6 votes
public void updatePower(World worldIn, BlockPos pos)
{
    if (!worldIn.provider.getHasNoSky())
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);
        int i = worldIn.getLightFor(EnumSkyBlock.SKY, pos) - worldIn.getSkylightSubtracted();
        float f = worldIn.getCelestialAngleRadians(1.0F);
        float f1 = f < (float)Math.PI ? 0.0F : ((float)Math.PI * 2F);
        f = f + (f1 - f) * 0.2F;
        i = Math.round((float)i * MathHelper.cos(f));
        i = MathHelper.clamp_int(i, 0, 15);

        if (this.inverted)
        {
            i = 15 - i;
        }

        if (((Integer)iblockstate.getValue(POWER)).intValue() != i)
        {
            worldIn.setBlockState(pos, iblockstate.withProperty(POWER, Integer.valueOf(i)), 3);
        }
    }
}
 
Example 2
Project: BaseClient   File: BlockDaylightDetector.java   Source Code and License Vote up 6 votes
public void updatePower(World worldIn, BlockPos pos)
{
    if (!worldIn.provider.getHasNoSky())
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);
        int i = worldIn.getLightFor(EnumSkyBlock.SKY, pos) - worldIn.getSkylightSubtracted();
        float f = worldIn.getCelestialAngleRadians(1.0F);
        float f1 = f < (float)Math.PI ? 0.0F : ((float)Math.PI * 2F);
        f = f + (f1 - f) * 0.2F;
        i = Math.round((float)i * MathHelper.cos(f));
        i = MathHelper.clamp_int(i, 0, 15);

        if (this.inverted)
        {
            i = 15 - i;
        }

        if (((Integer)iblockstate.getValue(POWER)).intValue() != i)
        {
            worldIn.setBlockState(pos, iblockstate.withProperty(POWER, Integer.valueOf(i)), 3);
        }
    }
}
 
Example 3
Project: uniquecrops   File: DevilSnare.java   Source Code and License Vote up 6 votes
private void trySpread(World world, BlockPos pos) {
	
	for (EnumFacing face : EnumFacing.HORIZONTALS) {
		BlockPos looppos = pos.offset(face);
		if (world.getLightFor(EnumSkyBlock.BLOCK, looppos) > 5) continue;
		if (world.isAirBlock(looppos) && (world.getBlockState(looppos.down()).getBlock() == Blocks.DIRT || world.getBlockState(looppos.down()).getBlock() == Blocks.FARMLAND)) {
			if (world.rand.nextInt(2) == 0) {
				if (world.getBlockState(looppos.down()).getBlock() == Blocks.DIRT)
					world.setBlockState(looppos.down(), Blocks.FARMLAND.getDefaultState(), 3);
				else
					world.setBlockState(looppos, UCBlocks.cropDevilsnare.getDefaultState(), 3);
				break;
			}
		}
	}
}
 
Example 4
Project: CustomWorldGen   File: StructureComponent.java   Source Code and License Vote up 5 votes
protected int func_189916_b(World p_189916_1_, int p_189916_2_, int p_189916_3_, int p_189916_4_, StructureBoundingBox p_189916_5_)
{
    int i = this.getXWithOffset(p_189916_2_, p_189916_4_);
    int j = this.getYWithOffset(p_189916_3_ + 1);
    int k = this.getZWithOffset(p_189916_2_, p_189916_4_);
    BlockPos blockpos = new BlockPos(i, j, k);
    return !p_189916_5_.isVecInside(blockpos) ? EnumSkyBlock.SKY.defaultLightValue : p_189916_1_.getLightFor(EnumSkyBlock.SKY, blockpos);
}
 
Example 5
Project: DecompiledMinecraft   File: BlockSnowBlock.java   Source Code and License Vote up 5 votes
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    if (worldIn.getLightFor(EnumSkyBlock.BLOCK, pos) > 11)
    {
        this.dropBlockAsItem(worldIn, pos, worldIn.getBlockState(pos), 0);
        worldIn.setBlockToAir(pos);
    }
}
 
Example 6
Project: Backmemed   File: StructureComponent.java   Source Code and License Vote up 5 votes
protected int func_189916_b(World p_189916_1_, int p_189916_2_, int p_189916_3_, int p_189916_4_, StructureBoundingBox p_189916_5_)
{
    int i = this.getXWithOffset(p_189916_2_, p_189916_4_);
    int j = this.getYWithOffset(p_189916_3_ + 1);
    int k = this.getZWithOffset(p_189916_2_, p_189916_4_);
    BlockPos blockpos = new BlockPos(i, j, k);
    return !p_189916_5_.isVecInside(blockpos) ? EnumSkyBlock.SKY.defaultLightValue : p_189916_1_.getLightFor(EnumSkyBlock.SKY, blockpos);
}
 
Example 7
Project: uniquecrops   File: Item3DGlasses.java   Source Code and License Vote up 5 votes
@Override
  public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
  	
if (world.isRemote)
	return;

int upgradelevel = NBTUtils.getInt(itemStack, ItemGeneric.TAG_UPGRADE, -1);
int sunlight = world.getLightFor(EnumSkyBlock.SKY, player.getPosition().add(0, player.getEyeHeight(), 0));
if (sunlight <= 3 && upgradelevel == 10) {
	player.addPotionEffect(new PotionEffect(MobEffects.NIGHT_VISION, 30));
}
  }
 
Example 8
Project: Backmemed   File: BlockSnow.java   Source Code and License Vote up 5 votes
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    if (worldIn.getLightFor(EnumSkyBlock.BLOCK, pos) > 11)
    {
        this.dropBlockAsItem(worldIn, pos, worldIn.getBlockState(pos), 0);
        worldIn.setBlockToAir(pos);
    }
}
 
Example 9
Project: DecompiledMinecraft   File: BlockSnowBlock.java   Source Code and License Vote up 5 votes
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    if (worldIn.getLightFor(EnumSkyBlock.BLOCK, pos) > 11)
    {
        this.dropBlockAsItem(worldIn, pos, worldIn.getBlockState(pos), 0);
        worldIn.setBlockToAir(pos);
    }
}
 
Example 10
Project: DecompiledMinecraft   File: BlockSnow.java   Source Code and License Vote up 5 votes
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    if (worldIn.getLightFor(EnumSkyBlock.BLOCK, pos) > 11)
    {
        this.dropBlockAsItem(worldIn, pos, worldIn.getBlockState(pos), 0);
        worldIn.setBlockToAir(pos);
    }
}
 
Example 11
Project: CustomWorldGen   File: BlockSnow.java   Source Code and License Vote up 5 votes
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    if (worldIn.getLightFor(EnumSkyBlock.BLOCK, pos) > 11)
    {
        worldIn.setBlockToAir(pos);
    }
}
 
Example 12
Project: BaseClient   File: BlockSnowBlock.java   Source Code and License Vote up 5 votes
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    if (worldIn.getLightFor(EnumSkyBlock.BLOCK, pos) > 11)
    {
        this.dropBlockAsItem(worldIn, pos, worldIn.getBlockState(pos), 0);
        worldIn.setBlockToAir(pos);
    }
}
 
Example 13
Project: CustomWorldGen   File: BlockSnowBlock.java   Source Code and License Vote up 5 votes
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    if (worldIn.getLightFor(EnumSkyBlock.BLOCK, pos) > 11)
    {
        this.dropBlockAsItem(worldIn, pos, worldIn.getBlockState(pos), 0);
        worldIn.setBlockToAir(pos);
    }
}
 
Example 14
Project: CustomWorldGen   File: BlockDaylightDetector.java   Source Code and License Vote up 5 votes
public void updatePower(World worldIn, BlockPos pos)
{
    if (!worldIn.provider.getHasNoSky())
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);
        int i = worldIn.getLightFor(EnumSkyBlock.SKY, pos) - worldIn.getSkylightSubtracted();
        float f = worldIn.getCelestialAngleRadians(1.0F);

        if (this.inverted)
        {
            i = 15 - i;
        }

        if (i > 0 && !this.inverted)
        {
            float f1 = f < (float)Math.PI ? 0.0F : ((float)Math.PI * 2F);
            f = f + (f1 - f) * 0.2F;
            i = Math.round((float)i * MathHelper.cos(f));
        }

        i = MathHelper.clamp_int(i, 0, 15);

        if (((Integer)iblockstate.getValue(POWER)).intValue() != i)
        {
            worldIn.setBlockState(pos, iblockstate.withProperty(POWER, Integer.valueOf(i)), 3);
        }
    }
}
 
Example 15
Project: BaseClient   File: BlockIce.java   Source Code and License Vote up 5 votes
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    if (worldIn.getLightFor(EnumSkyBlock.BLOCK, pos) > 11 - this.getLightOpacity())
    {
        if (worldIn.provider.doesWaterVaporize())
        {
            worldIn.setBlockToAir(pos);
        }
        else
        {
            this.dropBlockAsItem(worldIn, pos, worldIn.getBlockState(pos), 0);
            worldIn.setBlockState(pos, Blocks.water.getDefaultState());
        }
    }
}
 
Example 16
Project: BaseClient   File: BlockSnowBlock.java   Source Code and License Vote up 5 votes
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    if (worldIn.getLightFor(EnumSkyBlock.BLOCK, pos) > 11)
    {
        this.dropBlockAsItem(worldIn, pos, worldIn.getBlockState(pos), 0);
        worldIn.setBlockToAir(pos);
    }
}
 
Example 17
Project: BaseClient   File: BlockSnow.java   Source Code and License Vote up 5 votes
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    if (worldIn.getLightFor(EnumSkyBlock.BLOCK, pos) > 11)
    {
        this.dropBlockAsItem(worldIn, pos, worldIn.getBlockState(pos), 0);
        worldIn.setBlockToAir(pos);
    }
}
 
Example 18
Project: customstuff4   File: BlockSnow.java   Source Code and License Vote up 5 votes
@Override
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    if (worldIn.getLightFor(EnumSkyBlock.BLOCK, pos) > content.maxLight)
    {
        worldIn.setBlockToAir(pos);
    }
}
 
Example 19
Project: uniquecrops   File: DevilSnare.java   Source Code and License Vote up 5 votes
@Override
   public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
	
	if (world.getLightFor(EnumSkyBlock.BLOCK, pos) > 5 && this.getAge(state) >= getMaxAge()) {
		int deage = Math.max(world.getLightFor(EnumSkyBlock.BLOCK, pos) - 7, 0);
		if (!world.isRemote)
			world.setBlockState(pos, this.withAge(this.getAge(state) - deage), 2);
		return;
	}
	if (this.getAge(state) >= getMaxAge())
		this.trySpread(world, pos);

	super.updateTick(world, pos, state, rand);
}
 
Example 20
Project: uniquecrops   File: GrowthSteps.java   Source Code and License Vote up 4 votes
@Override
public boolean canAdvance(World world, BlockPos pos, IBlockState state) {

	int sunlight = world.getLightFor(EnumSkyBlock.SKY, pos);
	return sunlight == 0;
}